konduto-ruby 2.1.0 → 2.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
  SHA256:
3
- metadata.gz: 2979ec6a852c1d1aec13ff2fee745918d33ccd68dc60b8a3fb59902cdcc0d12c
4
- data.tar.gz: 18724ed8955265a9ee632454d3bc6fe4a1277d268de87d5d86a81318d2b0e53d
3
+ metadata.gz: 3ed318163f8a657f5717e5ffcf9b8052ddcba8580bce2d610b4cd8334395f9fb
4
+ data.tar.gz: 3f6c9674cd5b62a5096a45a1735b21a5cdabe92b7b16c7548a73ad6c6e4f47fb
5
5
  SHA512:
6
- metadata.gz: adbba6bf4810427c18a3aff47ae11526ca32bc9cef0a09f44920cc71bca4d4b11d56e651c8d1d85197d9f1dba71dffd3265169596254bc39c56a0a1083bf5ca9
7
- data.tar.gz: edabb1c41aa2d930240e5897c204f65df269e8a065a8e11d267b20ecd97e543f6d0c007759d0615dc26187289dd25a8ae3e8b808c9966028a77cf57633e03226
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 [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.
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
- - This API was tested with Ruby MRI version 2.
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
- > **NOTICE**: the order created above is really, really simple. The more detail you provide, more accurate Konduto's analysis will be.
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
- | Parameter | Description |
75
- | ------------------ | ---------------------------------------------------------------------------------------- |
76
- | id | _(required)_ Unique identifier for each order. |
77
- | visitor | _(required)_ Visitor identifier obtained from our JavaScript snippet. |
78
- | total_amount | _(required)_ Total order amount. |
79
- | shipping_amount | _(optional)_ Shipping and handling amount. |
80
- | tax_amount | _(optional)_ Taxes amount. |
81
- | currency | _(optional)_ Currency code with 3 letters (ISO-4712). |
82
- | installments | _(optional)_ Number of installments in the payment plan. |
83
- | ip | _(optional)_ Customer's IPv4 address. |
84
- | customer | _(required)_ Object containing the customer details. |
85
- | payment | _(optional)_ Array containing the payment methods. |
86
- | billing | _(optional)_ Object containing the billing information. |
87
- | shipping | _(optional)_ Object containing the shipping information. |
88
- | shopping_cart | _(optional)_ Array containing the items purchased. |
89
- | analyze | _(optional)_ A boolean indicating if the order should be analyzed. Defaults to **true**. |
90
- | first_message | _(optional)_ Time when the first message was exchanged between customer and seller. |
91
- | messages_exchanged | _(optional)_ Number of messages exchanged between customer and seller. |
92
- | purchased_at | _(optional)_ Time when the customer purchased from the seller. |
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
- | Parameter | Description |
97
- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
98
- | 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. |
99
- | name | _(required)_ Customer's full name. |
100
- | email | _(required)_ Customer's e-mail address |
101
- | tax_id | _(optional)_ Customer's tax id. |
102
- | phone1 | _(optional)_ Customer's primary phone number |
103
- | phone 2 | _(optional)_ Customer's secondary phone number |
104
- | new | _(optional)_ Boolean indicating if the customer is using a newly created account for this purchase. |
105
- | vip | _(optional)_ Boolean indicating if the customer is a VIP or frequent buyer. |
106
- | created_at | _(optional)_ Date when customer was created. |
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
- | Parameter | Description |
111
- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
112
- | 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. |
113
- | bin | _(optional)_ First six digits of the customer's credit card. Used to identify the type of card being sent. |
114
- | last4 | _(optional)_ Four last digits of the customer's credit card number. |
115
- | expiration_date | _(optional)_ Card's expiration date under MMYYYY format. |
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
- | 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) |
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
- | Parameter | Description |
132
- | --------- | ------------------------------------------------------ |
133
- | name | _(optional)_ Recipient's full name. |
134
- | address1 | _(optional)_ Recipient's shipping address. |
135
- | address2 | _(optional)_ Additional recipient address information. |
136
- | city | _(optional)_ Recipient's city. |
137
- | state | _(optional)_ Recipient's state. |
138
- | zip | _(optional)_ Recipient's ZIP code. |
139
- | country | _(optional)_ Recipient's country code (ISO 3166-2) |
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
- | Parameter | Description |
144
- | ------------ | -------------------------------------------------------------------------------------------------------------- |
145
- | sku | _(optional)_ Product or service's SKU or inventory id. |
146
- | product_code | _(optional)_ Product or service's UPC, barcode or secondary id. |
147
- | category | _(optional)_ Category code for the item purchased. [See here](http://docs.konduto.com/#n-tables) for the list. |
148
- | name | _(optional)_ Name of the product or service. |
149
- | description | _(optional)_ Detailed description of the item. |
150
- | unit_cost | _(optional)_ Cost of a single unit of this item. |
151
- | quantity | _(optional)_ Number of units purchased. |
152
- | discount | _(optional)_ Discounted amount for this item. |
153
- | created_at | _(optional)_ Date when this item was created. |
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
- | Parameter | Description |
158
- | ---------- | --------------------------------------------- |
159
- | id | _(required)_ Seller's id |
160
- | name | _(optional)_ Sellers's name |
161
- | created_at | _(optional)_ Date when the seller was created |
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
- | Parameter | Description |
206
- | --------- | --------------------------------------------------------------------------------------------------------------------------------------- |
207
- | status | _(required)_ New status for this transaction. Either `approved`, `declined` or `fraud`, when you have identified a fraud or chargeback. |
208
- | comments | _(required)_ Reason or comments about the status update. |
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}") if instance_variable_defined?("@#{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}") if instance_variable_defined?("@#{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(/[?|!]$/, '')}") if instance_variable_defined?("@#{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?(DateTime)
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
@@ -0,0 +1,3 @@
1
+ class KondutoDelivery < KondutoBase
2
+ attributes :delivery_company, :delivery_method, :estimated_shipping_date, :estimated_delivery_date
3
+ end
@@ -1,4 +1,4 @@
1
- class KondutoNavigation < KondutoBase
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, strftime_pattern: '%Y-%m-%dT%H:%M:%SZ'
18
- attribute purchased_at: :date_time, strftime_pattern: '%Y-%m-%dT%H:%M:%SZ'
18
+ attribute first_message: :date_time
19
+ attribute purchased_at: :date_time
19
20
  attribute status: :symbol
20
21
  attribute recommendation: :symbol
21
22
 
@@ -2,6 +2,6 @@ class KondutoOrderStatus < KondutoBase
2
2
  attributes :status, :comments
3
3
 
4
4
  def self.allowed_status
5
- %w(APPROVED DECLINED NOT_AUTHORIZED CANCELLED FRAUD)
5
+ %w(APPROVED DECLINED NOT_AUTHORIZED CANCELED FRAUD)
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  class KondutoTravelLeg < KondutoBase
2
2
  attributes :number_of_connections, :fare_basis
3
- attribute date: :date_time
3
+ attribute date: :date
4
4
  attribute klass: :symbol
5
5
  end
@@ -1,16 +1,14 @@
1
- module Konduto
2
- module ClassMethods
3
- def validates_presence_of(*attributes)
4
- self.send(:define_method, :required_attr) do
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
- def validates(*attributes, &block)
10
- if block_given?
11
- self.send(:define_method, :custom_validations) do
12
- { Proc.new(&block) => attributes }
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
@@ -4,7 +4,7 @@ module Konduto
4
4
  module Validations
5
5
  def self.included(base)
6
6
  base.class_eval do
7
- extend Konduto::ClassMethods
7
+ extend ClassMethods
8
8
  end
9
9
  end
10
10
 
data/lib/konduto-ruby.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require 'json'
2
2
  require 'konduto-ruby/konduto_base'
3
- require 'konduto-ruby/konduto_travel_leg'
4
-
5
3
  Dir[__dir__ + '/konduto-ruby/*.rb'].each { |file| require file }
6
4
 
7
5
  class KondutoRuby
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.0
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: 2018-06-23 00:00:00.000000000 Z
12
+ date: 2022-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: factory_bot
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.10'
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.10'
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/konduto_navigation.rb
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
- rubyforge_project:
80
- rubygems_version: 2.7.7
80
+ rubygems_version: 3.2.15
81
81
  signing_key:
82
82
  specification_version: 4
83
- summary: Konduto Ruby SDK
83
+ summary: ''
84
84
  test_files: []