Class: Fondy::Request
- Inherits:
-
Object
- Object
- Fondy::Request
- Defined in:
- lib/fondy/request.rb
Constant Summary collapse
- API_HOST =
'https://api.fondy.eu'
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(method, url, body) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(method, url, body) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 |
# File 'lib/fondy/request.rb', line 10 def initialize(method, url, body) @method = method @url = url @body = body end |
Class Method Details
.call(*args) ⇒ Object
6 7 8 |
# File 'lib/fondy/request.rb', line 6 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fondy/request.rb', line 16 def call connection = Faraday::Connection.new(API_HOST) connection.public_send(method) do |request| request.url url if body request.body = JSON.generate(request: body) request.headers['Content-Type'] = 'application/json' end end rescue Faraday::Error => e raise Fondy::RequestError, e. end |