ravelin 0.1.0 → 0.1.1

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: ace9b2ca5a0ad8ebc0db1a5d1b1c4d13138a1b80
4
- data.tar.gz: d5040e417b5abd918aea069c6ae8453d7537ecc1
3
+ metadata.gz: 4f6b62c84fc36e42c5afedaece47c3a190092fd2
4
+ data.tar.gz: a22a979b5c94556e8f7f8b8eed40649a91d82e53
5
5
  SHA512:
6
- metadata.gz: 024cc6dd06228437355c2ca1132b5e105c4335f0201cb3667132c5c77fbeceef3e6dbbef1627ca6f4b79d7b941178837ad7de81edac9abaabae4682e0c0f9403
7
- data.tar.gz: c8c5938e1205e7c2fa04b78bf37505290c71eefffb1e2e1b1e2cd63950e4aab562f08348360bf0c87021e95637ab29f8e293322baf8c2306f3c2bda43694d0d2
6
+ metadata.gz: 460a193f7a8ae4cea0afe0103b59eb7ea86fd645dff289a46cff2ae559752c368bebbf8527db6e5d7c8453c6d4e97d2be0c720bb9f3cb33f471c8ef4273d7bea
7
+ data.tar.gz: bc1f563c71e2e3f6e7a81456150d930a45a808c4819a7394566076693abb02bca378628b738c90611f853ee24aa143de1603d10451553a1c330b05bd8f9bcc98
data/lib/ravelin.rb CHANGED
@@ -9,6 +9,7 @@ require 'ravelin/errors/api_error'
9
9
  require 'ravelin/errors/invalid_request_error'
10
10
  require 'ravelin/errors/authentication_error'
11
11
  require 'ravelin/errors/rate_limit_error'
12
+ require 'ravelin/errors/invalid_label_value_error'
12
13
 
13
14
  require 'ravelin/ravelin_object'
14
15
  require 'ravelin/chargeback'
@@ -20,6 +21,7 @@ require 'ravelin/order'
20
21
  require 'ravelin/payment_method'
21
22
  require 'ravelin/pre_transaction'
22
23
  require 'ravelin/transaction'
24
+ require 'ravelin/label'
23
25
 
24
26
  require 'ravelin/event'
25
27
  require 'ravelin/response'
@@ -0,0 +1,4 @@
1
+ module Ravelin
2
+ class InvalidLabelValueError < ArgumentError
3
+ end
4
+ end
data/lib/ravelin/event.rb CHANGED
@@ -32,7 +32,8 @@ module Ravelin
32
32
  location: Location,
33
33
  order: Order,
34
34
  payment_method: PaymentMethod,
35
- transaction: self.name == :pretransaction ? PreTransaction : Transaction
35
+ transaction: self.name == :pretransaction ? PreTransaction : Transaction,
36
+ label: Label,
36
37
  }
37
38
  end
38
39
 
@@ -40,7 +41,7 @@ module Ravelin
40
41
 
41
42
  def validate_top_level_payload_params
42
43
  validate_customer_id_presence_on :order, :paymentmethod,
43
- :pretransaction, :transaction
44
+ :pretransaction, :transaction, :label
44
45
 
45
46
  case self.name
46
47
  when :customer
@@ -101,7 +102,8 @@ module Ravelin
101
102
  def convert_event_name(str)
102
103
  underscore_mapping = {
103
104
  payment_method: :paymentmethod,
104
- pre_transaction: :pretransaction
105
+ pre_transaction: :pretransaction,
106
+ label: 'label/customer'.to_sym
105
107
  }
106
108
 
107
109
  underscore_mapping.fetch(str.to_sym, str.to_sym)
@@ -0,0 +1,20 @@
1
+ module Ravelin
2
+ class Label < RavelinObject
3
+ attr_accessor :customer_id,
4
+ :label,
5
+ :comment,
6
+ :reviewer
7
+
8
+ attr_required :customer_id,
9
+ :label,
10
+ :comment
11
+
12
+ LABEL_VALUES = %w(UNREVIEWED GENUINE FRAUDSTER)
13
+
14
+ def validate
15
+ super
16
+
17
+ raise InvalidLabelValueError.new("Label value be one of #{LABEL_VALUES.join(', ')}") unless LABEL_VALUES.include?(label)
18
+ end
19
+ end
20
+ end
@@ -10,6 +10,8 @@ module Ravelin
10
10
  :http_body
11
11
 
12
12
  def initialize(faraday_response)
13
+ return if faraday_response.body.nil? || faraday_response.body.empty?
14
+
13
15
  data = faraday_response.body.fetch('data', {})
14
16
 
15
17
  @customer_id = data['customerId']
@@ -1,3 +1,3 @@
1
1
  module Ravelin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ravelin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Levy
8
8
  - Tommy Palmer
9
+ - Gurkan Oluc
9
10
  autorequire:
10
11
  bindir: exe
11
12
  cert_chain: []
12
- date: 2016-06-17 00:00:00.000000000 Z
13
+ date: 2016-06-29 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: faraday
@@ -99,6 +100,7 @@ description: Ravelin is a fraud detection tool. See https://www.ravelin.com for
99
100
  email:
100
101
  - sam.levy@deliveroo.co.uk
101
102
  - tommy.palmer@deliveroo.co.uk
103
+ - gurkan.oluc@deliveroo.co.uk
102
104
  executables: []
103
105
  extensions: []
104
106
  extra_rdoc_files: []
@@ -110,10 +112,12 @@ files:
110
112
  - lib/ravelin/device.rb
111
113
  - lib/ravelin/errors/api_error.rb
112
114
  - lib/ravelin/errors/authentication_error.rb
115
+ - lib/ravelin/errors/invalid_label_value_error.rb
113
116
  - lib/ravelin/errors/invalid_request_error.rb
114
117
  - lib/ravelin/errors/rate_limit_error.rb
115
118
  - lib/ravelin/event.rb
116
119
  - lib/ravelin/item.rb
120
+ - lib/ravelin/label.rb
117
121
  - lib/ravelin/location.rb
118
122
  - lib/ravelin/order.rb
119
123
  - lib/ravelin/payment_method.rb