Module: Epayco
- Defined in:
- lib/epayco.rb,
lib/epayco/resources.rb,
lib/epayco/operations.rb
Defined Under Namespace
Modules: Operations Classes: Bank, Cash, Charge, Customers, Error, Plan, Resource, Subscriptions, Token
Class Attribute Summary collapse
-
.apiKey ⇒ Object
Returns the value of attribute apiKey.
-
.lang ⇒ Object
Returns the value of attribute lang.
-
.privateKey ⇒ Object
Returns the value of attribute privateKey.
-
.test ⇒ Object
Returns the value of attribute test.
Class Method Summary collapse
-
.request(method, url, extra = nil, params = {}, headers = {}, switch) ⇒ Object
Eject request and show response or error.
Class Attribute Details
.apiKey ⇒ Object
Returns the value of attribute apiKey.
35 36 37 |
# File 'lib/epayco.rb', line 35 def apiKey @apiKey end |
.lang ⇒ Object
Returns the value of attribute lang.
35 36 37 |
# File 'lib/epayco.rb', line 35 def lang @lang end |
.privateKey ⇒ Object
Returns the value of attribute privateKey.
35 36 37 |
# File 'lib/epayco.rb', line 35 def privateKey @privateKey end |
.test ⇒ Object
Returns the value of attribute test.
35 36 37 |
# File 'lib/epayco.rb', line 35 def test @test end |
Class Method Details
.request(method, url, extra = nil, params = {}, headers = {}, switch) ⇒ Object
Eject request and show response or error
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/epayco.rb', line 39 def self.request(method, url, extra=nil, params={}, headers={}, switch) method = method.to_sym if !apiKey || !privateKey || !lang raise Error.new('100', lang) end payload = JSON.generate(params) if method == :post || method == :patch params = nil unless method == :get # Switch secure or api if switch if method == :post || method == :patch enc = encrypt_aes(payload) payload = enc.to_json end url = @api_base_secure + url else if method == :post || method == :patch rb_hash = JSON.parse(payload) rb_hash["test"] = test ? "TRUE" : "FALSE" rb_hash["ip"] = local_ip payload = rb_hash.to_json end url = @api_base + url end headers = { :params => params, :content_type => 'application/json', :type => 'sdk' }.merge(headers) = { :headers => headers, :user => apiKey, :method => method, :url => url, :payload => payload } # Open library rest client begin response = execute_request() return {} if response.code == 204 and method == :delete JSON.parse(response.body, :symbolize_names => true) rescue RestClient::Exception => e handle_errors e end end |