konduto-ruby 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +86 -84
- data/lib/konduto-ruby/associations/associations.rb +2 -2
- data/lib/konduto-ruby/attributes.rb +1 -9
- data/lib/konduto-ruby/konduto_base.rb +1 -15
- data/lib/konduto-ruby/konduto_delivery.rb +3 -0
- data/lib/konduto-ruby/{konduto_navigation.rb → konduto_navigation_info.rb} +1 -1
- data/lib/konduto-ruby/konduto_order.rb +3 -2
- data/lib/konduto-ruby/konduto_order_status.rb +1 -1
- data/lib/konduto-ruby/konduto_travel_leg.rb +1 -1
- data/lib/konduto-ruby/validations/class_methods.rb +9 -11
- data/lib/konduto-ruby/validations/validations.rb +1 -1
- data/lib/konduto-ruby.rb +0 -2
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ed318163f8a657f5717e5ffcf9b8052ddcba8580bce2d610b4cd8334395f9fb
|
|
4
|
+
data.tar.gz: 3f6c9674cd5b62a5096a45a1735b21a5cdabe92b7b16c7548a73ad6c6e4f47fb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45b3265d4196188e8795c56b8f63225d94495dd8fe659208c88b059af86f84a4fb1bd159d0114b18b3ef2d01d623dd9cf50210823cedce4fcba0b1477fe50229
|
|
7
|
+
data.tar.gz: c6002c33f9afbfc95fc105691096288698a3af378cd0c86882acdf7f74f110f9859712856edc2ea70895a04347a25e0bf27d7df59e17a6245b0577fa27d5e22c
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Hey there,
|
|
2
2
|
|
|
3
|
-
This document is a rubyist adaptation of the original README file made for the Java API version. You can get access to it by clicking
|
|
3
|
+
This document is a rubyist adaptation of the original README file made for the Java API version. You can get access to it by clicking [here](https://github.com/konduto/java-sdk/blob/master/README.md). **Konduto is a trademark, all rights reserved**. This project has no intention beyond helping ruby users to get easy access to Konduto's API through a simplified interface.
|
|
4
4
|
|
|
5
5
|
## Intro
|
|
6
6
|
|
|
@@ -10,13 +10,9 @@ Our service uses the visitor's behavior to analyze browsing patterns and detect
|
|
|
10
10
|
|
|
11
11
|
This document refers to the **Ruby SDK** used for our API.
|
|
12
12
|
|
|
13
|
-
## Migration from 1.0 to 2.0
|
|
14
|
-
|
|
15
|
-
NavigationInfo class is now Navigation and validation methods are now scopped by Konduto module.
|
|
16
|
-
|
|
17
13
|
## Requirements
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
* This API was tested with Ruby MRI version 2.
|
|
20
16
|
|
|
21
17
|
## Installation
|
|
22
18
|
|
|
@@ -34,6 +30,7 @@ When a customer makes a purchase you must send the order information to us so we
|
|
|
34
30
|
|
|
35
31
|
While many of the parameters we accept are optional we recommend you send all you can, because every data point matters for the analysis. The **billing address** and **credit card information** are specially important, though we understand there are cases where you don't have that information.
|
|
36
32
|
|
|
33
|
+
|
|
37
34
|
## Set your API key
|
|
38
35
|
|
|
39
36
|
You will need an API key to authenticate the requests. Luckily for you the examples below have been populated with a working key, so you can just copy and paste to see how it works.
|
|
@@ -56,8 +53,7 @@ order = KondutoOrder.new({
|
|
|
56
53
|
totalAmount: 123.4,
|
|
57
54
|
customer: customer # customer is an instance of KondutoCustomer
|
|
58
55
|
})
|
|
59
|
-
```
|
|
60
|
-
|
|
56
|
+
```
|
|
61
57
|
One can also use the more conventional set-based approach as seen below.
|
|
62
58
|
|
|
63
59
|
```ruby
|
|
@@ -67,98 +63,105 @@ order.total_amount = 123.4
|
|
|
67
63
|
order.customer = customer
|
|
68
64
|
```
|
|
69
65
|
|
|
70
|
-
>
|
|
66
|
+
>
|
|
67
|
+
**NOTICE**: the order created above is really, really simple. The more detail you provide, more accurate Konduto's analysis will be.
|
|
68
|
+
>
|
|
71
69
|
|
|
72
70
|
### Order parameters
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
Parameter | Description
|
|
73
|
+
--- | ---
|
|
74
|
+
id | _(required)_ Unique identifier for each order.
|
|
75
|
+
visitor | _(required)_ Visitor identifier obtained from our JavaScript snippet.
|
|
76
|
+
total_amount | _(required)_ Total order amount.
|
|
77
|
+
shipping_amount | _(optional)_ Shipping and handling amount.
|
|
78
|
+
tax_amount | _(optional)_ Taxes amount.
|
|
79
|
+
currency | _(optional)_ Currency code with 3 letters (ISO-4712).
|
|
80
|
+
installments | _(optional)_ Number of installments in the payment plan.
|
|
81
|
+
ip | _(optional)_ Customer's IPv4 address.
|
|
82
|
+
customer | _(required)_ Object containing the customer details.
|
|
83
|
+
payment | _(optional)_ Array containing the payment methods.
|
|
84
|
+
billing | _(optional)_ Object containing the billing information.
|
|
85
|
+
shipping | _(optional)_ Object containing the shipping information.
|
|
86
|
+
shopping_cart | _(optional)_ Array containing the items purchased.
|
|
87
|
+
analyze | _(optional)_ A boolean indicating if the order should be analyzed. Defaults to **true**.
|
|
88
|
+
first_message | _(optional)_ Time when the first message was exchanged between customer and seller.
|
|
89
|
+
messages_exchanged | _(optional)_ Number of messages exchanged between customer and seller.
|
|
90
|
+
purchased_at | _(optional)_ Time when the customer purchased from the seller.
|
|
93
91
|
|
|
94
92
|
#### Customer information
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
94
|
+
Parameter | Description
|
|
95
|
+
--- | ---
|
|
96
|
+
id | _(required)_ **Unique** identifier for each customer. Can be anything you like (counter, id, e-mail address) as long as it's consistent in future orders.
|
|
97
|
+
name | _(required)_ Customer's full name.
|
|
98
|
+
email | _(required)_ Customer's e-mail address
|
|
99
|
+
tax_id | _(optional)_ Customer's tax id.
|
|
100
|
+
phone1 | _(optional)_ Customer's primary phone number
|
|
101
|
+
phone 2 | _(optional)_ Customer's secondary phone number
|
|
102
|
+
new | _(optional)_ Boolean indicating if the customer is using a newly created account for this purchase.
|
|
103
|
+
vip | _(optional)_ Boolean indicating if the customer is a VIP or frequent buyer.
|
|
104
|
+
created_at | _(optional)_ Date when customer was created.
|
|
105
|
+
|
|
107
106
|
|
|
108
107
|
#### Payment information
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
Parameter | Description
|
|
110
|
+
--- | ---
|
|
111
|
+
status | _(required)_ The status of the transaction returned by the payment processor. Accepts `approved`, `declined` or `pending` if the payment wasn't been processed yet.
|
|
112
|
+
bin | _(optional)_ First six digits of the customer's credit card. Used to identify the type of card being sent.
|
|
113
|
+
last4 | _(optional)_ Four last digits of the customer's credit card number.
|
|
114
|
+
expiration_date | _(optional)_ Card's expiration date under MMYYYY format.
|
|
115
|
+
|
|
116
116
|
|
|
117
117
|
#### Billing address
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
Parameter | Description
|
|
120
|
+
--- | ---
|
|
121
|
+
name | _(optional)_ Cardholder's full name.
|
|
122
|
+
address1 | _(optional)_ Cardholder's billing address on file with the bank.
|
|
123
|
+
address2 | _(optional)_ Additional cardholder address information.
|
|
124
|
+
city | _(optional)_ Cardholder's city.
|
|
125
|
+
state | _(optional)_ Cardholder's state.
|
|
126
|
+
zip | _(optional)_ Cardholder's ZIP code.
|
|
127
|
+
country | _(optional)_ Cardholder's country code (ISO 3166-2)
|
|
128
|
+
|
|
128
129
|
|
|
129
130
|
#### Shipping address
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
Parameter | Description
|
|
133
|
+
--- | ---
|
|
134
|
+
name | _(optional)_ Recipient's full name.
|
|
135
|
+
address1 | _(optional)_ Recipient's shipping address.
|
|
136
|
+
address2 | _(optional)_ Additional recipient address information.
|
|
137
|
+
city | _(optional)_ Recipient's city.
|
|
138
|
+
state | _(optional)_ Recipient's state.
|
|
139
|
+
zip | _(optional)_ Recipient's ZIP code.
|
|
140
|
+
country | _(optional)_ Recipient's country code (ISO 3166-2)
|
|
141
|
+
|
|
140
142
|
|
|
141
143
|
#### Shopping cart
|
|
142
144
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
Parameter | Description
|
|
146
|
+
--- | ---
|
|
147
|
+
sku | _(optional)_ Product or service's SKU or inventory id.
|
|
148
|
+
product_code | _(optional)_ Product or service's UPC, barcode or secondary id.
|
|
149
|
+
category | _(optional)_ Category code for the item purchased. [See here](http://docs.konduto.com/#n-tables) for the list.
|
|
150
|
+
name | _(optional)_ Name of the product or service.
|
|
151
|
+
description | _(optional)_ Detailed description of the item.
|
|
152
|
+
unit_cost | _(optional)_ Cost of a single unit of this item.
|
|
153
|
+
quantity | _(optional)_ Number of units purchased.
|
|
154
|
+
discount | _(optional)_ Discounted amount for this item.
|
|
155
|
+
created_at | _(optional)_ Date when this item was created.
|
|
154
156
|
|
|
155
157
|
### Seller
|
|
156
158
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
Parameter | Description
|
|
160
|
+
--- | ---
|
|
161
|
+
id | _(required)_ Seller's id
|
|
162
|
+
name | _(optional)_ Sellers's name
|
|
163
|
+
created_at | _(optional)_ Date when the seller was created
|
|
164
|
+
|
|
162
165
|
|
|
163
166
|
## Sending an order for analysis.
|
|
164
167
|
|
|
@@ -202,13 +205,12 @@ order = konduto.get_order order_id # orderId is a String
|
|
|
202
205
|
konduto.update_order_status(order, new_status, 'some comments');
|
|
203
206
|
```
|
|
204
207
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
Parameter | Description
|
|
209
|
+
--- | ---
|
|
210
|
+
status | _(required)_ New status for this transaction. Either `approved`, `declined` or `fraud`, when you have identified a fraud or chargeback.
|
|
211
|
+
comments | _(required)_ Reason or comments about the status update.
|
|
209
212
|
|
|
210
213
|
## Sending requests through a proxy
|
|
211
|
-
|
|
212
214
|
To send requests through a proxy just build a new Konduto instance and set the proxy host passing the proxy url as parameters of `proxy=` method. If the proxy requires username and password, just set then at the proxy url you'll pass to `proxy=` method.
|
|
213
215
|
|
|
214
216
|
```ruby
|
|
@@ -5,7 +5,7 @@ module Konduto
|
|
|
5
5
|
name = options[:alias] || model
|
|
6
6
|
|
|
7
7
|
self.send(:define_method, name) do
|
|
8
|
-
instance_variable_get("@#{name}")
|
|
8
|
+
instance_variable_get("@#{name}")
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
self.send(:define_method, "#{name}=".to_sym) do |value|
|
|
@@ -25,7 +25,7 @@ module Konduto
|
|
|
25
25
|
name = options[:alias] || model
|
|
26
26
|
|
|
27
27
|
self.send(:define_method, name) do
|
|
28
|
-
instance_variable_get("@#{name}")
|
|
28
|
+
instance_variable_get("@#{name}")
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
self.send(:define_method, "#{name}=".to_sym) do |arr|
|
|
@@ -6,8 +6,6 @@ module Konduto
|
|
|
6
6
|
klass = attribute.values[0].to_s.gsub(/_/, ' ').split.map(&:capitalize).join('')
|
|
7
7
|
type = Object::const_get(klass)
|
|
8
8
|
name = attribute.keys[0]
|
|
9
|
-
|
|
10
|
-
define_strftime_pattern(self, name, attribute[:strftime_pattern]) if attribute.has_key?(:strftime_pattern)
|
|
11
9
|
else
|
|
12
10
|
name = attribute
|
|
13
11
|
end
|
|
@@ -24,17 +22,11 @@ module Konduto
|
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
self.send(:define_method, name) do
|
|
27
|
-
instance_variable_get("@#{name.to_s.gsub(/[?|!]$/, '')}")
|
|
25
|
+
instance_variable_get("@#{name.to_s.gsub(/[?|!]$/, '')}")
|
|
28
26
|
end
|
|
29
27
|
end
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
alias :attribute :attributes
|
|
33
|
-
|
|
34
|
-
def define_strftime_pattern(klass, name, value)
|
|
35
|
-
klass.send(:define_method, "#{name.to_s.gsub(/[?|!]$/, '')}_strftime_pattern") do
|
|
36
|
-
value
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
31
|
end
|
|
40
32
|
end
|
|
@@ -28,17 +28,11 @@ class KondutoBase
|
|
|
28
28
|
instance_variables.map do |name|
|
|
29
29
|
value = instance_variable_get(name)
|
|
30
30
|
|
|
31
|
-
strftime_pattern = defined_strftime_pattern(name) if defined_strftime_pattern?(name)
|
|
32
|
-
|
|
33
31
|
if value.respond_to? :each
|
|
34
32
|
value = value.map {|v| v.to_hash }
|
|
35
33
|
elsif !value.instance_variables.empty?
|
|
36
34
|
value = value.to_hash
|
|
37
|
-
elsif value.is_a?(
|
|
38
|
-
value = value.strftime(strftime_pattern || '%Y-%m-%dT%H:%MZ')
|
|
39
|
-
elsif value.is_a?(Date)
|
|
40
|
-
value = value.strftime(strftime_pattern || '%Y-%m-%d')
|
|
41
|
-
elsif value.is_a?(Symbol)
|
|
35
|
+
elsif value.is_a?(Date) || value.is_a?(Symbol)
|
|
42
36
|
value = value.to_s
|
|
43
37
|
end
|
|
44
38
|
|
|
@@ -59,12 +53,4 @@ class KondutoBase
|
|
|
59
53
|
|
|
60
54
|
true
|
|
61
55
|
end
|
|
62
|
-
|
|
63
|
-
def defined_strftime_pattern?(attr)
|
|
64
|
-
respond_to? "#{attr.to_s.gsub(/^@/, '')}_strftime_pattern"
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def defined_strftime_pattern(attr)
|
|
68
|
-
send("#{attr.to_s.gsub(/^@/, '')}_strftime_pattern")
|
|
69
|
-
end
|
|
70
56
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class KondutoNavigationInfo < KondutoBase
|
|
2
2
|
attributes :session_time, :referrer, :time_site_1d, :new_accounts_1d, :password_resets_1d, :sales_declined_1d,\
|
|
3
3
|
:sessions_1d, :time_since_last_sale, :time_site_7d, :time_per_page_7d, :new_accounts_7d, \
|
|
4
4
|
:password_resets_7d, :checkout_count_7d, :sales_declined_7d, :sessions_7d
|
|
@@ -10,12 +10,13 @@ class KondutoOrder < KondutoBase
|
|
|
10
10
|
has_one :device
|
|
11
11
|
has_one :geolocation
|
|
12
12
|
has_one :navigation
|
|
13
|
+
has_one :delivery
|
|
13
14
|
|
|
14
15
|
attributes :id, :visitor, :timestamp, :total_amount, :tax_amount, :currency, :installments,
|
|
15
16
|
:ip, :score, :analyze, :messages_exchanged, :shipping_amount
|
|
16
17
|
|
|
17
|
-
attribute first_message: :date_time
|
|
18
|
-
attribute purchased_at: :date_time
|
|
18
|
+
attribute first_message: :date_time
|
|
19
|
+
attribute purchased_at: :date_time
|
|
19
20
|
attribute status: :symbol
|
|
20
21
|
attribute recommendation: :symbol
|
|
21
22
|
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
attributes
|
|
6
|
-
end
|
|
1
|
+
module ClassMethods
|
|
2
|
+
def validates_presence_of(*attributes)
|
|
3
|
+
self.send(:define_method, :required_attr) do
|
|
4
|
+
attributes
|
|
7
5
|
end
|
|
6
|
+
end
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
8
|
+
def validates(*attributes, &block)
|
|
9
|
+
if block_given?
|
|
10
|
+
self.send(:define_method, :custom_validations) do
|
|
11
|
+
{ Proc.new(&block) => attributes }
|
|
14
12
|
end
|
|
15
13
|
end
|
|
16
14
|
end
|
data/lib/konduto-ruby.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: konduto-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriel Custodio
|
|
@@ -9,22 +9,22 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
15
|
+
name: factory_girl
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
18
|
- - "~>"
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '4.
|
|
20
|
+
version: '4.7'
|
|
21
21
|
type: :development
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
25
|
- - "~>"
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '4.
|
|
27
|
+
version: '4.7'
|
|
28
28
|
description: A wrapper for konduto antifraud API
|
|
29
29
|
email:
|
|
30
30
|
- gcmartins93@gmail.com jonathancardosodecampos@gmail.com
|
|
@@ -40,12 +40,13 @@ files:
|
|
|
40
40
|
- lib/konduto-ruby/konduto_base.rb
|
|
41
41
|
- lib/konduto-ruby/konduto_bus_leg.rb
|
|
42
42
|
- lib/konduto-ruby/konduto_customer.rb
|
|
43
|
+
- lib/konduto-ruby/konduto_delivery.rb
|
|
43
44
|
- lib/konduto-ruby/konduto_device.rb
|
|
44
45
|
- lib/konduto-ruby/konduto_flight_leg.rb
|
|
45
46
|
- lib/konduto-ruby/konduto_geolocation.rb
|
|
46
47
|
- lib/konduto-ruby/konduto_item.rb
|
|
47
48
|
- lib/konduto-ruby/konduto_loyalty.rb
|
|
48
|
-
- lib/konduto-ruby/
|
|
49
|
+
- lib/konduto-ruby/konduto_navigation_info.rb
|
|
49
50
|
- lib/konduto-ruby/konduto_order.rb
|
|
50
51
|
- lib/konduto-ruby/konduto_order_status.rb
|
|
51
52
|
- lib/konduto-ruby/konduto_passenger.rb
|
|
@@ -76,9 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
76
77
|
- !ruby/object:Gem::Version
|
|
77
78
|
version: '0'
|
|
78
79
|
requirements: []
|
|
79
|
-
|
|
80
|
-
rubygems_version: 2.7.7
|
|
80
|
+
rubygems_version: 3.2.15
|
|
81
81
|
signing_key:
|
|
82
82
|
specification_version: 4
|
|
83
|
-
summary:
|
|
83
|
+
summary: ''
|
|
84
84
|
test_files: []
|