Sha256: a29d315148f12f2e31a975328ee4b8fd3fda49be5c8a0d88b45da70026979ab8

Contents?: true

Size: 474 Bytes

Versions: 8

Compression:

Stored size: 474 Bytes

Contents

module Oschadbank
  class Request
    extend Dry::Initializer::Mixin

    param :request_url
    param :request_params

    def perform
      response = make_request

      unless response.status == 200
        raise InvalidResponse, "Response status: #{response.status}"
      end

      response
    end

    private

    def make_request
      Faraday.post(request_url, request_params)
    rescue Faraday::Error => e
      raise RequestError, e.message
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
oschadbank-0.1.7 lib/oschadbank/request.rb
oschadbank-0.1.6 lib/oschadbank/request.rb
oschadbank-0.1.5 lib/oschadbank/request.rb
oschadbank-0.1.4 lib/oschadbank/request.rb
oschadbank-0.1.3 lib/oschadbank/request.rb
oschadbank-0.1.2 lib/oschadbank/request.rb
oschadbank-0.1.1 lib/oschadbank/request.rb
oschadbank-0.1.0 lib/oschadbank/request.rb