ravelin 0.1.25 → 0.1.30

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: 2ca30db8a09466a96d2042c91b177bfc4a1478c063cdc848cf80bee5762a9ac4
4
- data.tar.gz: 6248744866c0924db62099bf3b2029b0ce8868a1acc4568b60e16c1bf5a27d5e
3
+ metadata.gz: 3a3456e5fa9c2c1b7f23d929e8a1cfba7b6eee2a43a90b57f31d659124aedffc
4
+ data.tar.gz: 8d368471d59baa6eb46c7d42b2c7d99f7334d15946851c6dad4aa1db053999f9
5
5
  SHA512:
6
- metadata.gz: 06fe356e63f52fbae095cea6b997950e8990a847cd9c34a168f5a000bf21d981edc8e43834388a4e08def5a643253cac4494761539dd7ee73abbd405282e45db
7
- data.tar.gz: 82dd34a7c4e9d9d7018bd2af3c0ce466112289faa1f9d2d6ba4c2986cf39f1b78d6abb31143fda0840e143a2b8687de65d53f80157b10b467d8e3b8d71947170
6
+ metadata.gz: b3cc621baf50e30c4448eb70f2bba0cf7cd2f474b22247a7e6616bcd2d08a3a7113a636cb80a8fa901942f2499b333915b0660c1f6375c3c6a7661c401e57bef
7
+ data.tar.gz: ed3a44566a6e8c70697b54d78c50fc17c827865c46cd4deeb4bbe1e378da2f2014f000d8e3ad519d08ef6ba880c03112219afdd64d68b767f891b5aa5f483def
@@ -35,6 +35,7 @@ require 'ravelin/event'
35
35
  require 'ravelin/tag'
36
36
  require 'ravelin/response'
37
37
  require 'ravelin/client'
38
+ require 'ravelin/proxy_client'
38
39
 
39
40
  module Ravelin
40
41
  @faraday_adapter = Faraday.default_adapter
@@ -13,6 +13,7 @@ module Ravelin
13
13
 
14
14
  def initialize(api_key:, api_version: 2)
15
15
  @api_key = api_key
16
+ @url_prefix = ''
16
17
 
17
18
  raise ArgumentError.new("api_version must be 2 or 3") unless [2,3].include? api_version
18
19
  @api_version = api_version
@@ -29,7 +30,7 @@ module Ravelin
29
30
 
30
31
  score_param = score ? "?score=true" : nil
31
32
 
32
- post("/v#{@api_version}/#{event.name}#{score_param}", event.serializable_hash)
33
+ post("#{@url_prefix}/v#{@api_version}/#{event.name}#{score_param}", event.serializable_hash)
33
34
  end
34
35
 
35
36
  def send_backfill_event(**args)
@@ -39,13 +40,13 @@ module Ravelin
39
40
 
40
41
  event = Event.new(**args)
41
42
 
42
- post("/v#{@api_version}/backfill/#{event.name}", event.serializable_hash)
43
+ post("#{@url_prefix}/v#{@api_version}/backfill/#{event.name}", event.serializable_hash)
43
44
  end
44
45
 
45
46
  def send_tag(**args)
46
47
  tag = Tag.new(**args)
47
48
 
48
- post("/v#{@api_version}/tag/customer", tag.serializable_hash)
49
+ post("#{@url_prefix}/v#{@api_version}/tag/customer", tag.serializable_hash)
49
50
  end
50
51
 
51
52
  def delete_tag(**args)
@@ -53,14 +54,14 @@ module Ravelin
53
54
  customer_id = tag["customerId"]
54
55
  tags = tag["tagNames"].join(",")
55
56
 
56
- delete("/v#{@api_version}/tag/customer?customerId=#{customer_id}&tagName=#{tags}")
57
+ delete("#{@url_prefix}/v#{@api_version}/tag/customer?customerId=#{customer_id}&tagName=#{tags}")
57
58
  end
58
59
 
59
60
  def get_tag(**args)
60
61
  tag = Tag.new(**args).serializable_hash
61
62
  customer_id = tag["customerId"]
62
63
 
63
- get("/v#{@api_version}/tag/customer/#{customer_id}")
64
+ get("#{@url_prefix}/v#{@api_version}/tag/customer/#{customer_id}")
64
65
  end
65
66
 
66
67
  private
@@ -73,9 +73,6 @@ module Ravelin
73
73
  :payment_method_id, :payment_method
74
74
  )
75
75
  validate_payload_inclusion_of :order_id
76
- when :checkout
77
- validate_payload_inclusion_of :customer, :order,
78
- :payment_method, :transaction
79
76
  when :login
80
77
  validate_payload_inclusion_of :username, :success, :authentication_mechanism
81
78
  when :ato_login
@@ -15,7 +15,7 @@ module Ravelin
15
15
  @password_hashed = passwd
16
16
  end
17
17
 
18
- FAILURE_REASONS = %w(BAD_PASSWORD UNKNOWN_USERNAME INTERNAL_ERROR RATE_LIMIT)
18
+ FAILURE_REASONS = %w(BAD_PASSWORD UNKNOWN_USERNAME AUTHENTICATION_FAILURE INTERNAL_ERROR RATE_LIMIT BANNED_USER)
19
19
 
20
20
  def validate
21
21
  super
@@ -0,0 +1,26 @@
1
+ module Ravelin
2
+ class ProxyClient < Client
3
+ def initialize(base_url:, username:, password:, api_version: 2)
4
+
5
+ raise ArgumentError, "api_version must be 2 or 3" unless [2,3].include? api_version
6
+ @api_version = api_version
7
+ @url_prefix = '/ravelinproxy'
8
+
9
+ @connection = Faraday.new(base_url, faraday_proxy_options) do |conn|
10
+ conn.response :json, context_type: /\bjson$/
11
+ conn.adapter Ravelin.faraday_adapter
12
+ conn.basic_auth(username, password)
13
+ end
14
+ end
15
+
16
+ def faraday_proxy_options
17
+ {
18
+ request: { timeout: Ravelin.faraday_timeout },
19
+ headers: {
20
+ 'Content-Type' => 'application/json; charset=utf-8'.freeze,
21
+ 'User-Agent' => "Ravelin Proxy RubyGem/#{Ravelin::VERSION}".freeze
22
+ }
23
+ }
24
+ end
25
+ end
26
+ end
@@ -12,7 +12,8 @@ module Ravelin
12
12
  :tag_names,
13
13
  :tags,
14
14
  :http_status,
15
- :http_body
15
+ :http_body,
16
+ :warnings
16
17
 
17
18
  def initialize(faraday_response)
18
19
  return if faraday_response.body.nil? || faraday_response.body.empty?
@@ -36,6 +37,7 @@ module Ravelin
36
37
  @source = data['source']
37
38
  @comment = data['comment']
38
39
  @customer_id = data['customerId']
40
+ @warnings = data['warnings']
39
41
  end
40
42
 
41
43
  def tag(response_body)
@@ -1,3 +1,3 @@
1
1
  module Ravelin
2
- VERSION = "0.1.25"
2
+ VERSION = '0.1.30'
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.25
4
+ version: 0.1.30
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: 2020-04-08 00:00:00.000000000 Z
14
+ date: 2020-10-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday
@@ -89,14 +89,14 @@ dependencies:
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: '1.22'
92
+ version: '2.3'
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: '1.22'
99
+ version: '2.3'
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
@@ -129,6 +129,7 @@ files:
129
129
  - lib/ravelin/password.rb
130
130
  - lib/ravelin/payment_method.rb
131
131
  - lib/ravelin/pre_transaction.rb
132
+ - lib/ravelin/proxy_client.rb
132
133
  - lib/ravelin/ravelin_object.rb
133
134
  - lib/ravelin/response.rb
134
135
  - lib/ravelin/tag.rb
@@ -156,7 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  - !ruby/object:Gem::Version
157
158
  version: '0'
158
159
  requirements: []
159
- rubygems_version: 3.0.6
160
+ rubyforge_project:
161
+ rubygems_version: 2.7.6.2
160
162
  signing_key:
161
163
  specification_version: 4
162
164
  summary: Ruby bindings for the Ravelin API