ravelin 0.1.24 → 0.1.29

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: 50dd02ccda765ab9f311b5f6effe5a2c49422ad3d97b73b8b8664c73cb6615b8
4
- data.tar.gz: ea95006dbd9d8ecd78e9f1df9b8b2dc19b469493714f756beb800e95c3f2a5f9
3
+ metadata.gz: 8eab5366dba9c0e8631c5ad551e93fb2a8beecd48f70c7c61e7a9c39eae5fe0f
4
+ data.tar.gz: 49db126736420b0d98d07ffabb66500b53ce219ac2e869bfe6b34053bf787610
5
5
  SHA512:
6
- metadata.gz: 2d59f8679c6847bb6261c77af1dd88449913b934a2723b1dd8796ae5b8d6891bd4bfe557e7c1f1cbf1e7172a1cb9b5a1baf39039938706cbb842b33497cde57b
7
- data.tar.gz: 1c610bc2c8d08a5c7473803756485255399a7e72641ea51f91b08b4a49c6f88832485463370cbc41b46ff95de72201290cf105979557450e92d44f9f9b4ad982
6
+ metadata.gz: e40ab3391a40c2fcba279acd83528e199461603a3f0540a946d6927c1f4d7b0ae28a3f1cc01789cce96c4d729d145083f14aacb77ae012002c33c9bbbd18c48c
7
+ data.tar.gz: 6955052fe1c17d4ddfcb5c957e2d7da15fa3f8a20600a3f9067ce7368f451beb47a46b7298b4ea703c04c93babb4169bf7131c18a8ca98d1a19c5ec9e6337564
@@ -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
@@ -3,6 +3,7 @@ module Ravelin
3
3
  attr_accessor :name, :timestamp, :payload
4
4
 
5
5
  def initialize(name:, payload:, timestamp: nil)
6
+ @internal_name = name
6
7
  @name = convert_event_name(name)
7
8
  @payload = convert_to_ravelin_objects(payload)
8
9
  @timestamp = timestamp.nil? ? Time.now.to_i : convert_to_epoch(timestamp)
@@ -45,10 +46,10 @@ module Ravelin
45
46
  end
46
47
 
47
48
  def format_timestamp(timestamp)
48
- case name
49
- when :login
49
+ case @internal_name
50
+ when :ato_login
50
51
  timestamp * 1000
51
- when :reclaim
52
+ when :ato_reclaim
52
53
  Time.at(timestamp).utc.to_datetime.to_s
53
54
  else
54
55
  timestamp
@@ -60,24 +61,23 @@ module Ravelin
60
61
  def validate_top_level_payload_params
61
62
  validate_customer_id_presence_on :order, :paymentmethod,
62
63
  :pretransaction, :transaction, :label
63
- case name
64
+ case @internal_name
64
65
  when :customer
65
66
  validate_payload_inclusion_of :customer
66
67
  when :voucher
67
68
  validate_payload_inclusion_of :voucher
68
69
  when :'paymentmethod/voucher'
69
70
  validate_payload_inclusion_of :'voucher_redemption'
70
- when :pretransaction, :transaction
71
+ when :pre_transaction, :transaction
71
72
  validate_payload_must_include_one_of(
72
73
  :payment_method_id, :payment_method
73
74
  )
74
75
  validate_payload_inclusion_of :order_id
75
- when :checkout
76
- validate_payload_inclusion_of :customer, :order,
77
- :payment_method, :transaction
78
76
  when :login
77
+ validate_payload_inclusion_of :username, :success, :authentication_mechanism
78
+ when :ato_login
79
79
  validate_payload_inclusion_of :login
80
- when :reclaim
80
+ when :ato_reclaim
81
81
  validate_payload_inclusion_of :customers, :source
82
82
  end
83
83
  end
@@ -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.24"
2
+ VERSION = '0.1.29'
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.24
4
+ version: 0.1.29
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-07 00:00:00.000000000 Z
14
+ date: 2020-07-13 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