Sha256: e0e555197191d3191c82c0bc213cddf82bc3b1e81fcdcdde0af5f3065f78001a

Contents?: true

Size: 780 Bytes

Versions: 29

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

gem 'typhoeus'
require 'typhoeus'

class WCC::Contentful::SimpleClient::TyphoeusAdapter
  def get(url, params = {}, headers = {})
    req = OpenStruct.new(params: params, headers: headers)
    yield req if block_given?
    Response.new(
      Typhoeus.get(
        url,
        params: req.params,
        headers: req.headers
      )
    )
  end

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

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

  class Response < SimpleDelegator
    delegate :to_s, to: :body

    def raw
      __getobj__
    end

    def status
      code
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
wcc-contentful-1.6.1 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.6.0 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.5.1 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.5.0 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.5.0.rc1 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.4.0 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.4.0.rc3 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.4.0.rc2 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.3.2 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.4.0.rc1 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.3.1 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.3.0 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.2.1 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.2.0 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.1.2 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.1.1 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.1.0 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.0.8 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.0.7 lib/wcc/contentful/simple_client/typhoeus_adapter.rb
wcc-contentful-1.0.6 lib/wcc/contentful/simple_client/typhoeus_adapter.rb