Class: RubyExpressOne::Client
- Inherits:
-
Object
- Object
- RubyExpressOne::Client
- Defined in:
- lib/ruby-expressone/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#with_logger ⇒ Object
readonly
Returns the value of attribute with_logger.
Instance Method Summary collapse
- #action(path, http_method: :post, payload: {}, query_params: {}) ⇒ Object
-
#initialize(api_key, with_logger: false) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key, with_logger: false) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/ruby-expressone/client.rb', line 10 def initialize(api_key, with_logger: false) @api_key = api_key @with_logger = with_logger end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/ruby-expressone/client.rb', line 8 def api_key @api_key end |
#with_logger ⇒ Object (readonly)
Returns the value of attribute with_logger.
8 9 10 |
# File 'lib/ruby-expressone/client.rb', line 8 def with_logger @with_logger end |
Instance Method Details
#action(path, http_method: :post, payload: {}, query_params: {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby-expressone/client.rb', line 15 def action(path, http_method: :post, payload: {}, query_params: {}) begin response = ::RestClient::Request.execute( method: http_method, url: full_url(path, query_params), payload: payload.to_json, headers: headers, timeout: 5, verify_ssl: ::OpenSSL::SSL::VERIFY_NONE ) rescue => e return parse(e.response) end parse(response) end |