conekta 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +5 -11
  3. data/CHANGELOG +5 -0
  4. data/Gemfile +6 -1
  5. data/LICENSE.txt +22 -0
  6. data/README.md +59 -0
  7. data/Rakefile +1 -14
  8. data/conekta.gemspec +22 -22
  9. data/lib/conekta.rb +36 -290
  10. data/lib/conekta/card.rb +10 -34
  11. data/lib/conekta/charge.rb +14 -38
  12. data/lib/conekta/conekta_object.rb +64 -136
  13. data/lib/conekta/customer.rb +23 -25
  14. data/lib/conekta/error.rb +65 -0
  15. data/lib/conekta/event.rb +2 -2
  16. data/lib/conekta/operations/create.rb +19 -0
  17. data/lib/conekta/operations/create_member.rb +30 -0
  18. data/lib/conekta/operations/custom_action.rb +17 -0
  19. data/lib/conekta/operations/delete.rb +43 -0
  20. data/lib/conekta/operations/find.rb +28 -0
  21. data/lib/conekta/operations/update.rb +13 -0
  22. data/lib/conekta/operations/where.rb +28 -0
  23. data/lib/conekta/payment_method.rb +4 -0
  24. data/lib/conekta/plan.rb +8 -5
  25. data/lib/conekta/requestor.rb +55 -0
  26. data/lib/conekta/resource.rb +13 -0
  27. data/lib/conekta/subscription.rb +12 -26
  28. data/lib/conekta/token.rb +3 -2
  29. data/lib/conekta/util.rb +19 -91
  30. data/lib/conekta/version.rb +1 -1
  31. data/lib/ssl_data/ca_bundle.crt +66 -0
  32. data/spec/conekta_spec.rb +299 -808
  33. data/spec/spec_helper.rb +12 -0
  34. metadata +55 -72
  35. data/CONTRIBUTORS +0 -9
  36. data/Gemfile.lock +0 -57
  37. data/History.txt +0 -4
  38. data/LICENSE +0 -23
  39. data/README.rdoc +0 -30
  40. data/VERSION +0 -1
  41. data/bin/conekta-console +0 -7
  42. data/bin/test calls +0 -205
  43. data/gemfiles/default-with-activesupport.gemfile +0 -3
  44. data/gemfiles/json.gemfile +0 -4
  45. data/gemfiles/yajl.gemfile +0 -4
  46. data/lib/conekta/account.rb +0 -4
  47. data/lib/conekta/api_operations/create.rb +0 -16
  48. data/lib/conekta/api_operations/create_member.rb +0 -18
  49. data/lib/conekta/api_operations/delete.rb +0 -11
  50. data/lib/conekta/api_operations/list.rb +0 -16
  51. data/lib/conekta/api_operations/modify_member.rb +0 -12
  52. data/lib/conekta/api_operations/update.rb +0 -22
  53. data/lib/conekta/api_resource.rb +0 -33
  54. data/lib/conekta/errors/api_connection_error.rb +0 -4
  55. data/lib/conekta/errors/api_error.rb +0 -4
  56. data/lib/conekta/errors/authentication_error.rb +0 -4
  57. data/lib/conekta/errors/card_error.rb +0 -11
  58. data/lib/conekta/errors/conekta_error.rb +0 -20
  59. data/lib/conekta/errors/malformed_request_error.rb +0 -10
  60. data/lib/conekta/errors/parameter_validation_error.rb +0 -10
  61. data/lib/conekta/errors/resource_not_found_error.rb +0 -10
  62. data/lib/conekta/json.rb +0 -21
  63. data/lib/conekta/list_object.rb +0 -35
  64. data/lib/conekta/log.rb +0 -5
  65. data/lib/conekta/singleton_api_resource.rb +0 -20
  66. data/lib/data/ca-certificates.crt +0 -3918
  67. data/spec/conekta_with_active_support_spec.rb +0 -3
  68. data/spec/test_helper.rb +0 -338
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODc4YjY0NDAxY2FkMjI4YWE0ZjA0ZDcyNDgyNzZmNzBmYjZkYzgyNw==
4
+ ZjY5ODgxZWFmM2I5Y2QxNDYwMmI2OGE3YWRiYmQxODhiMmE3ZGRkMw==
5
5
  data.tar.gz: !binary |-
6
- MDAyYmE3ZjZiNmQ2NmExMTJjMjM4N2U5YmRhMTc5ZmY2NWZkNWU4NA==
6
+ NWYyNTQyMTIzMzhiNGMwNTJlNGFjZjgzNDdlMDgwZjU3OWYxYzNkOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGY0Y2FiYTJlYTg0ZDI4MjZmNDI3ZDgyZjlhYzY3ZjEzOTlhMjhhNTBkODEw
10
- OTliMGY0N2JiMTZlMDkyODFlNzg3OTM5YTIxNjY3ZTgzMDMyNDhmZDNjNWY2
11
- MGQ5NjE3YmM1MmYxMTI2YTM4N2U4ZjcyYzVkZmVkZjI1NzAzMWM=
9
+ MWYxMDZmMzBmNmIyZDFiNTllNmUyZjg1OGFjMzcxZTQyYzExOTA5MTY1ODc1
10
+ MzZjZTgwMDJiYjFjMjIzNmE3ZmVmM2FiNDU4MTI5NDIyZjJiNzYxNzkwZGFm
11
+ NDAzY2U0Y2ZlNWYyMTU5YjY3NGY0Y2EwYzg1OGIyZWI5MzQzZDA=
12
12
  data.tar.gz: !binary |-
13
- YmE0YTE5YmY2NjBmOTM1YmI5OThkZjE2NjFhMTM5YmZmMzQ5YjM0YmVjMDU5
14
- NGZhNWE5ZWQ1ODUzMzAzMjNiMjk0NTljYmEzYWRlMzg4MTMxOGFiZjQwMjg5
15
- NWM1MWFiOTUzYWM3M2Y2YjQzYjFiNjljYjkzZTA4YmJjYTE3Zjk=
13
+ NTY5Y2NhYjUyNDQ3NDRjZTJkYWQwN2RiN2RiNzNlYjUwYzIwNzNmMTcyY2E0
14
+ MzIxM2E3YTUyMDBiMjBhMTViN2I1NDE5ODIyYTRjMGM3MTEyYmFiMDc1Y2Zj
15
+ OWJlNmNjNzlkNzMwN2I5M2FmNmYzZWMxYjJhMTA3YmEwZDNhZDk=
data/.gitignore CHANGED
@@ -1,14 +1,13 @@
1
1
  *.gem
2
- *.swo
3
- *.swn
4
- *.swm
5
- *.swp
6
- *~
7
2
  *.rbc
8
3
  .bundle
9
4
  .config
10
- coverage
5
+ .yardoc
6
+ Gemfile.lock
11
7
  InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
12
11
  lib/bundler/man
13
12
  pkg
14
13
  rdoc
@@ -16,8 +15,3 @@ spec/reports
16
15
  test/tmp
17
16
  test/version_tmp
18
17
  tmp
19
-
20
- # YARD artifacts
21
- .yardoc
22
- _yardoc
23
- doc/
data/CHANGELOG ADDED
@@ -0,0 +1,5 @@
1
+ === 0.3.5 2013-01-13
2
+
3
+ * Deprecate retrieve and all methods and replaced them with find and where respectively.
4
+ * Add payment method model.
5
+ * Objects' properties are now accessible via methods of the same of name
data/Gemfile CHANGED
@@ -1,2 +1,7 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
+ gem 'sys-uname'
3
+ gem 'rspec'
4
+ gem 'faraday'
5
+ gem 'json'
6
+ # Specify your gem's dependencies in conekta.gemspec
2
7
  gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013- Conekta (https://www.conekta.io)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Conekta
2
+
3
+ This is a ruby library that allows interaction with https://api.conekta.io API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'conekta'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install conekta
18
+
19
+ ## Usage
20
+
21
+ Conekta.api_key = '1tv5yJp3xnVZ7eK67m4h'
22
+ @my_card = {number: '4242424242424242', exp_month: 5, exp_year: 2015, cvc: 123, name: 'Mario Moreno'}
23
+ begin
24
+ charge = Conekta::Charge.create({card: @my_card, description: 'Some desc', amount: 2000, currency: 'mxn'})
25
+ p charge
26
+ rescue Conekta::Error
27
+ # Catch all exceptions including validation errors.
28
+ e.message
29
+ end
30
+
31
+ {
32
+ "id": "5286828b8ee31e64b7001739",
33
+ "livemode": false,
34
+ "created_at": 1384546955,
35
+ "status": "paid",
36
+ "currency": "MXN",
37
+ "description": "Some desc",
38
+ "reference_id": null,
39
+ "failure_code": null,
40
+ "failure_message": null,
41
+ "object": "charge",
42
+ "amount": 2000,
43
+ "fee": 371,
44
+ "payment_method": {
45
+ "name": "Mario Moreno",
46
+ "exp_month": "05",
47
+ "exp_year": "15",
48
+ "auth_code": "861491",
49
+ "object": "card_payment",
50
+ "last4": "4242",
51
+ "brand": "visa"
52
+ },
53
+ "details": {
54
+ "name": null,
55
+ "phone": null,
56
+ "email": null,
57
+ "line_items": []
58
+ }
59
+ }
data/Rakefile CHANGED
@@ -1,14 +1 @@
1
- require 'rspec/core/rake_task'
2
- task :default => [:spec]
3
-
4
-
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
-
8
- #task :test do
9
- # ret = true
10
- # Dir["test/**/*.rb"].each do |f|
11
- # ret = ret && ruby(f, '')
12
- # end
13
- # exit(ret)
14
- # end
1
+ require "bundler/gem_tasks"
data/conekta.gemspec CHANGED
@@ -1,27 +1,27 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
4
  require 'conekta/version'
4
5
 
5
- spec = Gem::Specification.new do |s|
6
- s.name = 'conekta'
7
- s.version = Conekta::VERSION
8
- s.summary = 'Ruby bindings for the Conekta API'
9
- s.description = 'Easy payments and shipping, see http://conekta.mx for details.'
10
- s.authors = ['Leo Fischer', 'Mauricio Murga']
11
- s.email = %w(leo@conekta.mx mauricio@conekta.com)
12
- s.homepage = 'http://conekta.mx/doc'
13
-
14
- s.add_dependency('rest-client', '~> 1.4')
15
- s.add_dependency('multi_json', '>= 1.0.4', '< 2')
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "conekta"
8
+ spec.version = Conekta::VERSION
9
+ spec.authors = ["MauricioMurga"]
10
+ spec.email = ["mauricio@conekta.io"]
11
+ spec.description = %q{Ruby library for https://api.conekta.io}
12
+ spec.summary = %q{This library provides https://api.conekta.io operations}
13
+ spec.homepage = "https://www.conekta.io"
14
+ spec.license = "MIT"
16
15
 
17
- # s.add_development_dependency('mocha', '~> 0.13.2')
18
- s.add_development_dependency('shoulda', '~> 3.4.0')
19
- # s.add_development_dependency('test-unit')
20
- s.add_development_dependency('rspec')
21
- s.add_development_dependency('rake')
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ spec.require_paths = ["lib"]
22
20
 
23
- s.files = `git ls-files`.split("\n")
24
- s.test_files = `git ls-files -- test/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
- s.require_paths = ['lib']
21
+ spec.add_dependency "bundler", "~> 1.3"
22
+ spec.add_dependency "rake"
23
+ spec.add_dependency "rspec"
24
+ spec.add_dependency "faraday"
25
+ spec.add_dependency "json"
26
+ spec.add_dependency "sys-uname"
27
27
  end
data/lib/conekta.rb CHANGED
@@ -1,299 +1,45 @@
1
- # Conekta Ruby bindings
2
- # API spec at https://conekta.io/docs/api
3
- require 'cgi'
4
- require 'set'
5
- require 'openssl'
6
- require 'rest_client'
7
- require 'multi_json'
8
- require 'base64'
9
-
10
- # Version
11
- require 'conekta/version'
12
-
13
- # API operations
14
- require 'conekta/api_operations/create'
15
- require 'conekta/api_operations/update'
16
- require 'conekta/api_operations/delete'
17
- require 'conekta/api_operations/list'
18
- require 'conekta/api_operations/modify_member'
19
- require 'conekta/api_operations/create_member'
20
-
21
- # Resources
22
- require 'conekta/util'
23
- require 'conekta/json'
24
- require 'conekta/conekta_object'
25
- require 'conekta/api_resource'
26
- require 'conekta/singleton_api_resource'
27
- require 'conekta/account'
28
- require 'conekta/list_object'
29
- require 'conekta/charge'
30
- require 'conekta/subscription'
31
- require 'conekta/customer'
32
- require 'conekta/card'
33
- require 'conekta/token'
34
- require 'conekta/plan'
35
- require 'conekta/event'
36
- require 'conekta/log'
37
-
38
- # Errors
39
- require 'conekta/errors/conekta_error'
40
- require 'conekta/errors/api_error'
41
- require 'conekta/errors/api_connection_error'
42
- require 'conekta/errors/card_error'
43
- require 'conekta/errors/resource_not_found_error'
44
- require 'conekta/errors/malformed_request_error'
45
- require 'conekta/errors/parameter_validation_error'
46
- require 'conekta/errors/authentication_error'
1
+ require 'json'
2
+
3
+ require "conekta/version"
4
+
5
+ require "conekta/operations/find"
6
+ require "conekta/operations/where"
7
+ require "conekta/operations/create"
8
+ require "conekta/operations/delete"
9
+ require "conekta/operations/update"
10
+ require "conekta/operations/custom_action"
11
+ require "conekta/operations/create_member"
12
+
13
+ require "conekta/conekta_object"
14
+ require "conekta/resource"
15
+ require "conekta/requestor"
16
+ require "conekta/util"
17
+ require "conekta/error"
18
+ require "conekta/payment_method"
19
+ require "conekta/charge"
20
+ require "conekta/customer"
21
+ require "conekta/card"
22
+ require "conekta/subscription"
23
+ require "conekta/plan"
24
+ require "conekta/token"
25
+ require "conekta/event"
47
26
 
48
27
  module Conekta
49
28
  @api_base = 'https://api.conekta.io'
50
-
51
- @ssl_bundle_path = File.dirname(__FILE__) + '/data/ca-certificates.crt'
52
- @verify_ssl_certs = true
53
-
54
- class << self
55
- attr_accessor :api_key, :api_base, :verify_ssl_certs, :api_version
56
- end
57
-
58
- def self.api_url(url='')
59
- url = @api_base + url
60
- if not url.match(/\.json/)
61
- url = url + '.json'
62
- end
63
- url
64
- end
65
-
66
- def self.request(method, url, api_key, params={}, headers={})
67
- unless api_key ||= @api_key
68
- raise AuthenticationError.new('No API key provided. ' +
69
- 'Set your API key using "Conekta.api_key = <API-KEY>". ' +
70
- 'You can generate API keys from the Conekta web interface. ' +
71
- 'See https://conekta.io/api for details, or email support@conekta.io ' +
72
- 'if you have any questions.')
73
- end
74
-
75
- if api_key =~ /\s/
76
- raise AuthenticationError.new('Your API key is invalid, as it contains ' +
77
- 'whitespace. (HINT: You can double-check your API key from the ' +
78
- 'Conekta web interface. See https://conekta.io/api for details, or ' +
79
- 'email support@conekta.io if you have any questions.)')
80
- end
81
-
82
- request_opts = { :verify_ssl => false }
83
-
84
- if ssl_preflight_passed?
85
- request_opts.update(:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
86
- :ssl_ca_file => @ssl_bundle_path)
87
- end
88
-
89
- params = Util.objects_to_ids(params)
90
- url = api_url(url)
91
-
92
- case method.to_s.downcase.to_sym
93
- when :get, :head, :delete
94
- # Make params into GET parameters
95
- url += "#{URI.parse(url).query ? '&' : '?'}#{uri_encode(params)}" if params && params.any?
96
- payload = nil
97
- else
98
- payload = params.to_json#uri_encode(params)
99
- headers[:content_type] = 'application/json'
100
- end
101
-
102
- request_opts.update(:headers => request_headers(api_key).update(headers),
103
- :method => method, :open_timeout => 30,
104
- :payload => payload, :url => url, :timeout => 80)
105
-
106
- begin
107
- response = execute_request(request_opts)
108
- rescue SocketError => e
109
- handle_restclient_error(e)
110
- rescue NoMethodError => e
111
- # Work around RestClient bug
112
- if e.message =~ /\WRequestFailed\W/
113
- e = APIConnectionError.new('Unexpected HTTP response code')
114
- handle_restclient_error(e)
115
- else
116
- raise
117
- end
118
- rescue RestClient::ExceptionWithResponse => e
119
- if rcode = e.http_code and rbody = e.http_body
120
- handle_api_error(rcode, rbody)
121
- else
122
- handle_restclient_error(e)
123
- end
124
- rescue RestClient::Exception, Errno::ECONNREFUSED => e
125
- handle_restclient_error(e)
126
- end
127
-
128
- [parse(response), api_key]
129
- end
130
-
131
- private
132
-
133
- def self.ssl_preflight_passed?
134
- if !verify_ssl_certs && !@no_verify
135
- $stderr.puts "WARNING: Running without SSL cert verification. " +
136
- "Execute 'Conekta.verify_ssl_certs = true' to enable verification."
137
-
138
- @no_verify = true
139
-
140
- elsif !Util.file_readable(@ssl_bundle_path) && !@no_bundle
141
- $stderr.puts "WARNING: Running without SSL cert verification " +
142
- "because #{@ssl_bundle_path} isn't readable"
143
-
144
- @no_bundle = true
145
- end
146
-
147
- !(@no_verify || @no_bundle)
148
- end
149
-
150
- def self.user_agent
151
- @uname ||= get_uname
152
- lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
153
-
154
- {
155
- :bindings_version => Conekta::VERSION,
156
- :lang => 'ruby',
157
- :lang_version => lang_version,
158
- :platform => RUBY_PLATFORM,
159
- :publisher => 'conekta',
160
- :uname => @uname
161
- }
162
-
163
- end
164
-
165
- def self.get_uname
166
- `uname -a 2>/dev/null`.strip if RUBY_PLATFORM =~ /linux|darwin/i
167
- rescue Errno::ENOMEM => ex # couldn't create subprocess
168
- "uname lookup failed"
169
- end
170
-
171
- def self.uri_encode(params)
172
- Util.flatten_params(params).
173
- map { |k,v| "#{k}=#{Util.url_encode(v)}" }.join('&')
174
- end
175
-
176
- def self.request_headers(api_key)
177
- headers = {
178
- :user_agent => "Conekta RubyBindings/#{Conekta::VERSION}",
179
- :authorization => "Basic #{Base64.encode64(api_key+':')}"
180
- }
181
-
182
- if api_version
183
- headers.update(:accept=>"application/vnd.conekta-v#{api_version}+json")
184
- else
185
- headers.update(:accept=>"application/vnd.conekta-v0.3.0+json")
186
- end
187
-
188
- begin
189
- headers.update(:conekta_client_user_agent => Conekta::JSON.dump(user_agent))
190
- rescue => e
191
- headers.update(:conekta_client_raw_user_agent => user_agent.inspect,
192
- :error => "#{e} (#{e.class})")
193
- end
194
- end
195
-
196
- def self.execute_request(opts)
197
- RestClient::Request.execute(opts)
198
- end
199
-
200
- def self.parse(response)
201
- begin
202
- # Would use :symbolize_names => true, but apparently there is
203
- # some library out there that makes symbolize_names not work.
204
- response = Conekta::JSON.load(response.body)
205
- rescue MultiJson::DecodeError
206
- raise general_api_error(response.code, response.body)
207
- end
208
-
209
- Util.symbolize_names(response)
210
- end
211
-
212
- def self.general_api_error(rcode, rbody)
213
- APIError.new("Invalid response object from API: #{rbody.inspect} " +
214
- "(HTTP response code was #{rcode})", rcode, rbody)
215
- end
216
-
217
- def self.handle_api_error(rcode, rbody)
218
- begin
219
- error_obj = Conekta::JSON.load(rbody)
220
- error_obj = Util.symbolize_names(error_obj)
221
- error = error_obj or raise ConektaError.new # escape from parsing
222
-
223
- rescue MultiJson::DecodeError, ConektaError
224
- raise general_api_error(rcode, rbody)
225
- end
226
-
227
- case rcode
228
- when 400
229
- raise malformed_request_error error, rcode, rbody, error_obj
230
- when 401
231
- raise authentication_error error, rcode, rbody, error_obj
232
- when 402
233
- raise card_error error, rcode, rbody, error_obj
234
- when 404
235
- raise resource_not_found_error error, rcode, rbody, error_obj
236
- when 422
237
- raise parameter_validation_error error, rcode, rbody, error_obj
238
- else
239
- raise api_error error, rcode, rbody, error_obj
240
- end
241
-
242
- end
243
-
244
- def self.resource_not_found_error(error, rcode, rbody, error_obj)
245
- ResourceNotFoundError.new(error[:message], error[:param], rcode,
246
- rbody, error_obj)
247
- end
248
-
249
- def self.malformed_request_error(error, rcode, rbody, error_obj)
250
- MalformedRequestError.new(error[:message], error[:param], rcode,
251
- rbody, error_obj)
252
- end
253
-
254
- def self.parameter_validation_error(error, rcode, rbody, error_obj)
255
- ParameterValidationError.new(error[:message], error[:param], rcode,
256
- rbody, error_obj)
29
+ @api_version = '0.3.0'
30
+ def self.api_base
31
+ @api_base
257
32
  end
258
-
259
- def self.authentication_error(error, rcode, rbody, error_obj)
260
- AuthenticationError.new(error[:message], rcode, rbody, error_obj)
33
+ def self.api_base=(api_base)
34
+ @api_base = api_base
261
35
  end
262
-
263
- def self.card_error(error, rcode, rbody, error_obj)
264
- CardError.new(error[:message], error[:param], error[:code],
265
- rcode, rbody, error_obj)
36
+ def self.api_version
37
+ @api_version
266
38
  end
267
-
268
- def self.api_error(error, rcode, rbody, error_obj)
269
- APIError.new(error[:message], rcode, rbody, error_obj)
39
+ def self.api_key
40
+ @api_key
270
41
  end
271
-
272
- def self.handle_restclient_error(e)
273
- case e
274
- when RestClient::ServerBrokeConnection, RestClient::RequestTimeout
275
- message = "Could not connect to Conekta (#{@api_base}). " +
276
- "Please check your internet connection and try again. " +
277
- "If this problem persists, you should check Conekta's service status at " +
278
- "https://twitter.com/conektastatus, or let us know at support@conekta.io."
279
-
280
- when RestClient::SSLCertificateNotVerified
281
- message = "Could not verify Conekta's SSL certificate. " +
282
- "Please make sure that your network is not intercepting certificates. " +
283
- "(Try going to https://api.conekta.io/ in your browser.) " +
284
- "If this problem persists, let us know at support@conekta.io."
285
-
286
- when SocketError
287
- message = "Unexpected error communicating when trying to connect to Conekta. " +
288
- "You may be seeing this message because your DNS is not working. " +
289
- "To check, try running 'host conekta.io' from the command line."
290
-
291
- else
292
- message = "Unexpected error communicating with Conekta. " +
293
- "If this problem persists, let us know at support@conekta.io."
294
-
295
- end
296
-
297
- raise APIConnectionError.new(message + "\n\n(Network error: #{e.message})")
42
+ def self.api_key=(api_key)
43
+ @api_key = api_key
298
44
  end
299
45
  end