conekta 2.0.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +120 -0
  4. data/Gemfile +4 -0
  5. data/README.md +12 -12
  6. data/lib/conekta.rb +2 -1
  7. data/lib/conekta/card.rb +3 -12
  8. data/lib/conekta/charge.rb +4 -2
  9. data/lib/conekta/conekta_object.rb +2 -1
  10. data/lib/conekta/destination.rb +3 -15
  11. data/lib/conekta/discount_line.rb +1 -14
  12. data/lib/conekta/error.rb +48 -17
  13. data/lib/conekta/error_details.rb +14 -0
  14. data/lib/conekta/line_item.rb +1 -14
  15. data/lib/conekta/payee.rb +40 -4
  16. data/lib/conekta/payment_source.rb +1 -14
  17. data/lib/conekta/payout_method.rb +4 -12
  18. data/lib/conekta/requestor.rb +3 -8
  19. data/lib/conekta/resource.rb +23 -12
  20. data/lib/conekta/return.rb +1 -14
  21. data/lib/conekta/shipping_contact.rb +1 -14
  22. data/lib/conekta/shipping_line.rb +1 -14
  23. data/lib/conekta/subscription.rb +2 -12
  24. data/lib/conekta/tax_line.rb +1 -12
  25. data/lib/conekta/transfer.rb +7 -0
  26. data/lib/conekta/util.rb +1 -0
  27. data/lib/conekta/version.rb +1 -1
  28. data/lib/ssl_data/ca_bundle.crt +3891 -2
  29. data/readme_cover.png +0 -0
  30. data/spec/conekta/1.0.0/charge_spec.rb +17 -0
  31. data/spec/conekta/2.0.0/discount_line_spec.rb +1 -1
  32. data/spec/conekta/2.0.0/error_spec.rb +61 -0
  33. data/spec/conekta/2.0.0/line_item_spec.rb +1 -1
  34. data/spec/conekta/2.0.0/order_spec.rb +9 -6
  35. data/spec/conekta/2.0.0/payee_spec.rb +9 -10
  36. data/spec/conekta/2.0.0/shipping_contact_spec.rb +1 -1
  37. data/spec/conekta/2.0.0/shipping_line_spec.rb +1 -1
  38. data/spec/conekta/2.0.0/source_spec.rb +1 -1
  39. data/spec/conekta/2.0.0/tax_line_spec.rb +1 -1
  40. data/spec/conekta/2.0.0/transfer_spec.rb +59 -0
  41. data/spec/spec_helper.rb +2 -12
  42. data/spec/support/fixtures/orders.json +1082 -2024
  43. metadata +11 -9
  44. data/CHANGELOG +0 -98
  45. data/lib/conekta/error_list.rb +0 -33
  46. data/lib/conekta/fiscal_entity.rb +0 -37
  47. data/readme_files/cover.png +0 -0
  48. data/spec/conekta/2.0.0/error_list_spec.rb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e0356d7e62f2a683a66d4be7583998322284110
4
- data.tar.gz: 971ca5e785e1877e1bf4e6f8630b00081545ca4c
3
+ metadata.gz: 128afba5fc294c5b0915d48fa91a36b032930fc2
4
+ data.tar.gz: 53ca47e31d870affb3d83bb994a3d713412d582b
5
5
  SHA512:
6
- metadata.gz: 3b1b4132f3ed6aebc55db64fedbfbf59b3e9a46b415c1ff52e52c1ee5e5ccca4f1891f275c2d534aa482165152cb0f120466665e41096bad337a7b37238b2f1f
7
- data.tar.gz: e4023ac675e8ae0d18b22d26718bdf2d1a5a42b9a0df990740db9ea51404c719fec2826bfe573535919ade85a053c1977e6b8ab0dcf6cbe98410e943997252e5
6
+ metadata.gz: 37f925817728abcfd6aa5d740bdb237d3e4ac41590764e3537dd8a57356269862536d2d6472ef14b7755c1639b4dea27186f5011911e9c4d66f3229e592f2c33
7
+ data.tar.gz: 85618a790e13015b275d2f17156ed56aae1774148d927001cb38081fb30853e1004e314b233ec5d76e3132457608fc590b6ab9de8b872d8b38e9fc4ebe77e1aa
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .byebug_history
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
@@ -0,0 +1,120 @@
1
+ ## [2.3.0](https://github.com/conekta/conekta-ruby/releases/tag/2.3.0) - 2017-10-05
2
+ ### Fix
3
+ - Capture allow pass amount in api v1
4
+
5
+ ## [2.2.0](https://github.com/conekta/conekta-ruby/releases/tag/2.2.0) - 2017-10-05
6
+ ### Fix
7
+ - Payee module implementation for api 2
8
+
9
+ ## [2.1.0](https://github.com/conekta/conekta-ruby/releases/tag/2.1.0) - 2017-10-05
10
+ ### Change
11
+ - Error list refactor and byebug implementation
12
+
13
+ ## [2.0.1](https://github.com/conekta/conekta-ruby/releases/tag/2.0.1) - 2017-02-15
14
+ ### Feature
15
+ - Order model, submodels and methods as well as enhanced Errors and lists
16
+
17
+ ## [2.0.0](https://github.com/conekta/conekta-ruby/releases/tag/2.0.0) - 2017-02-13
18
+ ### Update
19
+ - Update vertical info to antifraud info
20
+
21
+ ## [1.1.3]() - 2017-02-08
22
+ ### Change
23
+ - Change vertical_info to antifraud_info
24
+
25
+ ## [1.1.2]() - 2017-02-08
26
+ ### Change
27
+ - Avoid class name conflicts
28
+
29
+ ## [1.1.1](https://github.com/conekta/conekta-ruby/releases/tag/1.1.1) - 2017-02-01
30
+ ### Fix
31
+ - Fix submodels updates
32
+
33
+ ## [1.1.0]() - 2017-01-24
34
+ ### Update
35
+ - Version bump
36
+
37
+ ## [1.0.0]() - 2017-01-24
38
+ ###
39
+ - Add support for API 2.0.0
40
+
41
+ ## [0.5.8]() - 2016-07-19
42
+ ### Feature
43
+ - Add new models for parsing
44
+
45
+ ## [0.5.7]() - 2016-07-19
46
+ ### Fix
47
+ - Fix parameter handling for get requests
48
+
49
+ ## [0.5.6]() - 2015-12-29
50
+ ### Change
51
+ - Change parameter serialization using request body instead of connection params
52
+
53
+ ## [0.5.5]() - 2015-12-01
54
+ ### Feature
55
+ - Add find method to Event class
56
+
57
+ ## [0.5.4]() - 2015-09-08
58
+ ### Feature
59
+ - Update ConektaObject with the attribute 'values'
60
+
61
+ ## [0.5.3]() - 2015-08-13
62
+ ### Change
63
+ - Refactorization
64
+
65
+ ## [0.5.2](https://github.com/conekta/conekta-ruby/releases/tag/v0.5.2) - 2015-02-13
66
+ ### Change
67
+ - Change rspec dependency to development
68
+
69
+ ## [0.5.0]() - 2015-01-20
70
+ ### Feature
71
+ - Add Webhook module
72
+
73
+ ## [0.4.9]() - 2014-07-08
74
+ ### Change
75
+ - Update API version to 1.0.0
76
+
77
+ ## [0.4.6](https://github.com/conekta/conekta-ruby/releases/tag/v0.4.6) - 2014-07-08
78
+ ### Feature
79
+ - Add message_to_purchaser internal errors
80
+
81
+ ## [0.4.5](https://github.com/conekta/conekta-ruby/releases/tag/v0.4.5) - 2014-07-08
82
+ ### Feature
83
+ - Sprinkling small Ruby style conventions here and there (antillas21)
84
+
85
+ ## [0.4.4](https://github.com/conekta/conekta-ruby/releases/tag/v0.4.4) - 2014-06-04
86
+ ### Fix
87
+ - Fix requestor and where method
88
+
89
+ ## [0.4.3](https://github.com/conekta/conekta-ruby/releases/tag/v0.4.3) - 2014-05-25
90
+ ### Feature
91
+ - Add locale and message_to_purchaser
92
+
93
+ ## [0.4.2]() - 2014-04-28
94
+ ### Fix
95
+ - Fix Payout specs
96
+
97
+ ## [0.4.1](https://github.com/conekta/conekta-ruby/releases/tag/v0.4.1) - 2014-04-16
98
+ ### Remove
99
+ - Remove active support and add custom methods in util file
100
+
101
+ ## [0.4.0](https://github.com/conekta/conekta-ruby/releases/tag/v0.4.0) - 2014-04-16
102
+ ### Feature
103
+ - Add payout and payee models with specs
104
+ - Add webhook logs for events
105
+ - Ameliorate convert_to_conekta_object logic
106
+
107
+ ## [0.3.7](https://github.com/conekta/conekta-ruby/releases/tag/v0.3.7) - 2013-01-27
108
+ ### Feature
109
+ - Added api_version setter
110
+
111
+ ## [0.3.6](https://github.com/conekta/conekta-ruby/releases/tag/v0.3.6) - 2013-01-17
112
+ ### Fix
113
+ - Fix cert path
114
+
115
+ ## [0.3.5]() - 2013-01-13
116
+ ### Deprecate
117
+ - Deprecate retrieve and all methods and replaced them with find and where respectively
118
+ ### Feature
119
+ - Add payment method model
120
+ - Objects' properties are now accessible via methods of the same of name
data/Gemfile CHANGED
@@ -5,5 +5,9 @@ gem 'faraday'
5
5
  gem 'json'
6
6
  gem 'i18n'
7
7
 
8
+ group :development, :test do
9
+ gem 'byebug'
10
+ end
11
+
8
12
  # Specify your gem's dependencies in conekta.gemspec
9
13
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- ![alt tag](https://raw.github.com/conekta/conekta-ruby/master/readme_files/cover.png)
1
+ ![README Cover Image](readme_cover.png)
2
2
 
3
- # Conekta Ruby v.1.1.3
3
+ # Conekta Ruby v.2.3.0
4
4
 
5
5
  This is a ruby library that allows interaction with https://api.conekta.io API.
6
6
 
@@ -37,8 +37,8 @@ end
37
37
  begin
38
38
  order = Conekta::Order.create(order_data_with_charges.
39
39
  merge(customer_info: customer_info))
40
- rescue Conekta::ErrorList => error_list
41
- for error_detail in error_list.details do
40
+ rescue Conekta::Error => error
41
+ for error_detail in error.details do
42
42
  puts error_detail.message
43
43
  end
44
44
  end
@@ -101,10 +101,6 @@ end
101
101
  }
102
102
  ```
103
103
 
104
- License
105
- -------
106
- Developed by [Conekta](https://www.conekta.io). Available with [MIT License](LICENSE).
107
-
108
104
  Development and Testing
109
105
  -----------------------
110
106
  Feel free to play with our library and make pull requests if you find any bugs. You can run the test suite with rspec from the library's root directory:
@@ -121,8 +117,12 @@ docker pull conekta/conekta-ruby
121
117
  docker run -ti conekta/conekta-ruby /bin/bash --login
122
118
  ```
123
119
 
124
- We are hiring
125
- -------------
120
+ ## License
121
+
122
+ Developed in Mexico by [Conekta](https://www.conekta.com) in. Available with [MIT License](LICENSE).
123
+
124
+ ***
125
+
126
+ ## We are always hiring!
126
127
 
127
- If you are a comfortable working with a range of backend languages (Java, Python, Ruby, PHP, etc) and frameworks, you have solid foundation in data structures, algorithms and software design with strong analytical and debugging skills.
128
- Send your CV, github to quieroser@conekta.io
128
+ If you are a comfortable working with a range of backend languages (Java, Python, Ruby, PHP, etc) and frameworks, you have solid foundation in data structures, algorithms and software design with strong analytical and debugging skills. Send us your CV and GitHub to quieroser@conekta.com
@@ -17,7 +17,7 @@ require "conekta/resource"
17
17
  require "conekta/requestor"
18
18
  require "conekta/util"
19
19
  require "conekta/error"
20
- require "conekta/error_list"
20
+ require "conekta/error_details"
21
21
 
22
22
  require "conekta/customer_info"
23
23
  require "conekta/details"
@@ -41,6 +41,7 @@ require "conekta/payment_source"
41
41
  require "conekta/subscription"
42
42
  require "conekta/tax_line"
43
43
  require "conekta/token"
44
+ require "conekta/transfer"
44
45
  require "conekta/webhook"
45
46
  require "conekta/webhook_log"
46
47
  require "conekta/refund"
@@ -9,20 +9,11 @@ module Conekta
9
9
  :parent_id, :default
10
10
 
11
11
  def _url
12
- if (id.nil? || id.to_s.empty?)
13
- exception = Error.new({
14
- "message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
15
- "message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
16
- })
17
- if Conekta.api_version == "2.0.0"
18
- error_list = Conekta::ErrorList.new
19
- error_list.details << exception
20
- exception = error_list
21
- end
22
- raise exception
23
- end
12
+ ensure_id
13
+
24
14
  self.customer._url + self.class._url + "/" + id
25
15
  end
16
+
26
17
  def delete
27
18
  self.delete_member('customer','cards')
28
19
  end
@@ -11,8 +11,10 @@ module Conekta
11
11
  :exchange_rate, :foreign_currency, :amount_in_foreign_currency,
12
12
  :checkout_id, :checkout_order_count
13
13
 
14
- def capture
15
- custom_action(:post, 'capture')
14
+ # Usage: charge_reference.capture(2000)
15
+ def capture(capture_amount=nil)
16
+ params = { 'amount' => (capture_amount || self.amount) }
17
+ custom_action(:post, 'capture', params)
16
18
  end
17
19
 
18
20
  def refund(params=nil)
@@ -7,6 +7,7 @@ module Conekta
7
7
  end
8
8
 
9
9
  def set_val(k,v)
10
+ @values ||= {}
10
11
  @values[k] = v
11
12
  self[k] = v
12
13
  end
@@ -21,7 +22,7 @@ module Conekta
21
22
  end
22
23
 
23
24
  def last
24
- self[self.count - 1]
25
+ self[self.keys.last]
25
26
  end
26
27
 
27
28
  def load_from(response)
@@ -4,24 +4,12 @@ module Conekta
4
4
  include Conekta::Operations::Update
5
5
  include Conekta::Operations::CustomAction
6
6
 
7
- attr_accessor :payee_id, :created_at, :type, :currency,
8
- :last4, :account_holder_name, :bank
9
-
10
7
  def _url
11
- if (id.nil? || id.to_s.empty?)
12
- exception = Error.new({
13
- "message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
14
- "message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
15
- })
16
- if Conekta.api_version == "2.0.0"
17
- error_list = Conekta::ErrorList.new
18
- error_list.details << exception
19
- exception = error_list
20
- end
21
- raise exception
22
- end
8
+ ensure_id
9
+
23
10
  self.payee._url + self.class._url + "/" + id
24
11
  end
12
+
25
13
  def delete
26
14
  self.delete_member('payee','destinations')
27
15
  end
@@ -7,20 +7,7 @@ module Conekta
7
7
  attr_accessor :code, :amount, :type, :parent_id
8
8
 
9
9
  def _url
10
- if (id.nil? || id.to_s.empty?)
11
- exception = Error.new({
12
- "message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
13
- "message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
14
- })
15
-
16
- if Conekta.api_version == "2.0.0"
17
- error_list = Conekta::ErrorList.new
18
- error_list.details << exception
19
- exception = error_list
20
- end
21
-
22
- raise exception
23
- end
10
+ ensure_id
24
11
 
25
12
  "#{self.order._url}#{self.class._url}/#{id}"
26
13
  end
@@ -1,32 +1,53 @@
1
1
  module Conekta
2
- class Error < Exception
3
- attr_reader :message, :message_to_purchaser, :param, :code
4
- # NEW FIELDS
5
- attr_reader :validation_error, :custom_message
6
- # <b>DEPRECATED</b>.
7
- attr_reader :type
2
+ class Error < StandardError
3
+ attr_reader :message, :type, :log_id, :details, :data
8
4
 
9
-
10
5
  def initialize(options={})
11
- @message = options["message"]
12
- @message_to_purchaser = options["message_to_purchaser"]
13
- @param = options["param"]
14
- @code = options["code"]
15
- @validation_error = options["validation_error"]
16
- @validation_error = options["custom_message"]
17
6
  @type = options["type"]
7
+ @log_id = options["log_id"]
8
+ if options["details"]
9
+ @details = options["details"].collect{|details|
10
+ Conekta::ErrorDetails.new(details)
11
+ }
12
+ else
13
+ temp_details = Conekta::ErrorDetails.new({
14
+ "message" => options["message_to_purchaser"],
15
+ "debug_message" => options["message"],
16
+ "param" => options["param"]
17
+ })
18
+ @details = [temp_details]
19
+ end
20
+ @message = @details.first.debug_message
21
+ @data = options["data"]
22
+
23
+ super
18
24
  end
25
+
19
26
  def class_name
20
27
  self.class.name.split('::')[-1]
21
28
  end
29
+
22
30
  def self.error_handler(response, http_status)
23
31
  if http_status.to_s.empty? || http_status == 0
24
32
  NoConnectionError.new({
25
- "message" => I18n.t('error.requestor.connection', { base: Conekta.api_base, locale: :en }),
26
- "message_to_purchaser" => I18n.t('error.requestor.connection_purchaser', { locale: Conekta.locale.to_sym })
27
- })
33
+ "details" => [
34
+ {
35
+ "debug_message" => I18n.t(
36
+ 'error.requestor.connection',
37
+ { base: Conekta.api_base, locale: :en }
38
+ ),
39
+ "message" => I18n.t(
40
+ 'error.requestor.connection_purchaser',
41
+ { locale: Conekta.locale.to_sym }
42
+ ),
43
+ "code" => "error.requestor.connection"
44
+ }
45
+ ]
46
+ })
28
47
  else
29
48
  case http_status
49
+ when -1, 0
50
+ NoConnectionError.new(response)
30
51
  when 400
31
52
  MalformedRequestError.new(response)
32
53
  when 401
@@ -35,8 +56,12 @@ module Conekta
35
56
  ProcessingError.new(response)
36
57
  when 404
37
58
  ResourceNotFoundError.new(response)
59
+ when 409
60
+ VersionConflictError.new(response)
38
61
  when 422
39
62
  ParameterValidationError.new(response)
63
+ when 428
64
+ PreconditionRequiredError.new(response)
40
65
  when 500
41
66
  ApiError.new(response)
42
67
  else
@@ -63,6 +88,12 @@ module Conekta
63
88
  class ResourceNotFoundError < Error
64
89
  end
65
90
 
91
+ class VersionConflictError < Error
92
+ end
93
+
94
+ class PreconditionRequiredError < Error
95
+ end
96
+
66
97
  class MalformedRequestError < Error
67
98
  end
68
- end
99
+ end
@@ -0,0 +1,14 @@
1
+ module Conekta
2
+ class ErrorDetails < ConektaObject
3
+ attr_reader :debug_message, :message, :param, :code
4
+
5
+ def initialize(options={})
6
+ load_from(options)
7
+ @debug_message = options["debug_message"]
8
+ @message = options["message"]
9
+ @param = options["param"]
10
+ @code = options["code"]
11
+ super()
12
+ end
13
+ end
14
+ end
@@ -9,20 +9,7 @@ module Conekta
9
9
  :parent_id
10
10
 
11
11
  def _url
12
- if (id.nil? || id.to_s.empty?)
13
- exception = Error.new({
14
- "message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
15
- "message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
16
- })
17
-
18
- if Conekta.api_version == "2.0.0"
19
- error_list = Conekta::ErrorList.new
20
- error_list.details << exception
21
- exception = error_list
22
- end
23
-
24
- raise exception
25
- end
12
+ ensure_id
26
13
 
27
14
  "#{self.order._url}#{self.class._url}/#{id}"
28
15
  end