Class: VeriTrans::ApiBase
- Inherits:
-
Object
- Object
- VeriTrans::ApiBase
- Defined in:
- lib/veri_trans/api_base.rb
Direct Known Subclasses
Capture, Charges, CreditCardDestroy, CreditCardList, Cvs, ReCharges, Status, Tokens, Void
Instance Attribute Summary collapse
-
#ca_cert_file_path ⇒ Object
Returns the value of attribute ca_cert_file_path.
-
#host ⇒ Object
Returns the value of attribute host.
-
#http_request ⇒ Object
readonly
Returns the value of attribute http_request.
-
#port ⇒ Object
Returns the value of attribute port.
-
#server_key ⇒ Object
Returns the value of attribute server_key.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
Instance Method Summary collapse
-
#do_request_get(path, params) ⇒ Object
Json decoded object.
- #do_request_post(path, entity) ⇒ Object
-
#initialize(setting) ⇒ ApiBase
constructor
A new instance of ApiBase.
Constructor Details
#initialize(setting) ⇒ ApiBase
Returns a new instance of ApiBase.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/veri_trans/api_base.rb', line 15 def initialize(setting) @server_key = setting.server_key @ca_cert_file_path = setting.ca_cert_path @host = setting.request_host @use_ssl = setting.use_https_request @port = setting.request_host_port @verify_ssl = setting.verify_ssl @http_request = HttpRequest.new( server_key: @server_key, host: @host, use_ssl: @use_ssl, port: @port, verify_ssl: @verify_ssl, ca_cert_file_path: @ca_cert_file_path, ) end |
Instance Attribute Details
#ca_cert_file_path ⇒ Object
Returns the value of attribute ca_cert_file_path.
11 12 13 |
# File 'lib/veri_trans/api_base.rb', line 11 def ca_cert_file_path @ca_cert_file_path end |
#host ⇒ Object
Returns the value of attribute host.
11 12 13 |
# File 'lib/veri_trans/api_base.rb', line 11 def host @host end |
#http_request ⇒ Object (readonly)
Returns the value of attribute http_request.
12 13 14 |
# File 'lib/veri_trans/api_base.rb', line 12 def http_request @http_request end |
#port ⇒ Object
Returns the value of attribute port.
11 12 13 |
# File 'lib/veri_trans/api_base.rb', line 11 def port @port end |
#server_key ⇒ Object
Returns the value of attribute server_key.
11 12 13 |
# File 'lib/veri_trans/api_base.rb', line 11 def server_key @server_key end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
11 12 13 |
# File 'lib/veri_trans/api_base.rb', line 11 def use_ssl @use_ssl end |
#verify_ssl ⇒ Object
Returns the value of attribute verify_ssl.
11 12 13 |
# File 'lib/veri_trans/api_base.rb', line 11 def verify_ssl @verify_ssl end |
Instance Method Details
#do_request_get(path, params) ⇒ Object
Returns Json decoded object.
49 50 51 52 53 54 55 56 57 |
# File 'lib/veri_trans/api_base.rb', line 49 def do_request_get(path, params) result_body = @http_request.send_get_request(path: path, params: params) begin JSON.parse(result_body) rescue raise VtdException::VtDirectError("Could not decode from JSON to ruby object.\r\n#{result_body}") end end |
#do_request_post(path, entity) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/veri_trans/api_base.rb', line 36 def do_request_post(path, entity) result_body = @http_request.send_post_request(path: path, body: ActiveSupport::JSON.encode(entity)) begin JSON.parse(result_body) rescue raise VtdException::VtDirectError("Could not decode from JSON to ruby object.\r\n#{result_body}") end end |