Sha256: c7207a61ec497a7f5a3a36239601f59041d506f1db08cc8bbd8696e01ba7aafe

Contents?: true

Size: 988 Bytes

Versions: 2

Compression:

Stored size: 988 Bytes

Contents

module Immoscout
  module Api
    module Request
      def get(path, payload = nil, multipart = nil)
        request(:get, path, payload, multipart)
      end

      def post(path, payload = nil, multipart = nil)
        request(:post, path, payload, multipart)
      end

      def put(path, payload = nil, multipart = nil)
        request(:put, path, payload, multipart)
      end

      def delete(path, payload = nil, multipart = nil)
        request(:delete, path, payload, multipart)
      end

      def request(method, path, payload = nil, multipart = nil)
        connection.send(method, path, multipart) do |request|
          if multipart
            request.headers['Content-Type'] = "multipart/form-data"
          else
            request.body                    = payload if payload
            request.headers['Content-Type'] = "application/json;charset=UTF-8"
          end
          request.headers['Accept'] = "application/json"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
immoscout-1.1.0 lib/immoscout/api/request.rb
immoscout-1.0.0 lib/immoscout/api/request.rb