Class: Sinch::Gateway
- Inherits:
-
Object
- Object
- Sinch::Gateway
- Defined in:
- lib/sinch/gateway.rb
Overview
Sinch Api Gateway
Class Method Summary collapse
Instance Method Summary collapse
- #do_request ⇒ Object
-
#initialize(request, response, params) ⇒ Gateway
constructor
A new instance of Gateway.
Constructor Details
#initialize(request, response, params) ⇒ Gateway
Returns a new instance of Gateway.
15 16 17 18 19 |
# File 'lib/sinch/gateway.rb', line 15 def initialize(request, response, params) @request = request @response = response @params = params end |
Class Method Details
.request(endpoint, params) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/sinch/gateway.rb', line 7 def request(endpoint, params) request = "Sinch::Request::#{endpoint.to_s.camelize}".constantize.new params response = "Sinch::Response::#{endpoint.to_s.camelize}".constantize.new new(request, response, params).do_request end |
Instance Method Details
#do_request ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sinch/gateway.rb', line 21 def do_request begin response.response = ::HTTParty.send( method, url, headers: headers, body: payload.to_json ) rescue ::HTTParty::ResponseError => e response.error = e end response end |