Class: SmsAero2::Request
- Inherits:
-
Object
- Object
- SmsAero2::Request
- Defined in:
- lib/sms_aero2/request.rb
Defined Under Namespace
Classes: HttpError, InvalidResponse
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #call(url, **params) ⇒ Object
-
#initialize(client) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(client) ⇒ Request
Returns a new instance of Request.
12 13 14 15 |
# File 'lib/sms_aero2/request.rb', line 12 def initialize(client) @client = client @logger = client.logger end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/sms_aero2/request.rb', line 10 def client @client end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
10 11 12 |
# File 'lib/sms_aero2/request.rb', line 10 def logger @logger end |
Instance Method Details
#call(url, **params) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sms_aero2/request.rb', line 17 def call(url, **params) uri = URI(url) uri.query = URI.encode_www_form(params) response = send_request(uri) logger&.info( "Send http request to GET #{url} with params: #{params}" ) response_body(response) rescue SmsAero2::Error => e logger&.error("http request to #{url} with params: #{params} is failed message: #{e.}") raise e end |