Sha256: dd0e5f320b61b71da71ed034087c2fe8abfbe3fdf74a4fd0dd5a6ccb9aaa9745

Contents?: true

Size: 845 Bytes

Versions: 7

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

gem 'typhoeus'
require 'typhoeus'

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
      delegate :body, to: :raw
      delegate :to_s, to: :body
      delegate :code, to: :raw
      delegate :headers, to: :raw

      def status
        raw.code
      end
    end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wcc-contentful-0.4.0.pre.rc lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-0.4.0.pre.beta lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-0.4.0.pre.alpha lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-0.3.0 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-0.3.0.pre.rc3 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-0.3.0.pre.rc2 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-0.3.0.pre.rc lib/wcc/contentful/simple_client/typhoeus_adapter.rb