Sha256: e8d9134ffa49dad399d91d41dcfe5b22266cea7a5359c67bd8f5c899d8d92a76

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'
gem 'typhoeus'
require 'typhoeus'

class RestClient
  class TyphoeusAdapter
    def call(url, query, headers = {}, proxy = {})
      raise NotImplementedError, 'Proxying Not Yet Implemented' if proxy[:host]

      TyphoeusAdapter::Response.new(
        Typhoeus.get(
          url,
          params: query,
          headers: headers
        )
      )
    end

    def post(url, body, headers = {}, proxy = {})
      raise NotImplementedError, 'Proxying Not Yet Implemented' if proxy[:host]

      TyphoeusAdapter::Response.new(
        Typhoeus.post(
          url,
          body: body.to_json,
          headers: headers
        )
      )
    end

    Response =
      Struct.new(:raw) do
        extend Forwardable

        def_delegators :raw, :body, :to_s, :code, :headers

        def status
          raw.code
        end
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wcc-media-client-0.1.1 lib/rest_client/typhoeus_adapter.rb
wcc-media-client-0.1.0 lib/rest_client/typhoeus_adapter.rb