Sha256: 9c947e326719760c9ecde299d6434913d2d7411b1da9efab852750e885f5c4c6

Contents?: true

Size: 933 Bytes

Versions: 8

Compression:

Stored size: 933 Bytes

Contents

require 'yao/plugins'
require 'faraday'
require 'faraday_middleware'
require 'yao/faraday_middlewares'

module Yao::Plugins
  class DefaultClientGenerator
    def call(f, token)
      f.request :accept, 'application/json'
      f.request :url_encoded
      f.request :user_agent

      if token
        f.request :os_token, token
      end

      f.request :read_only

      f.response :os_error_detector
      f.response :json, content_type: /\bjson$/

      if Yao.config.debug
        f.response :os_dumper
      end

      if Yao.config.debug_record_response
        f.response :os_response_recorder
      end

      f.adapter Faraday.default_adapter
    end

    Yao::Plugins.register(self, type: :client_generator)

    Yao.config.param :client_generator, :default do |v|
      raise("Invalid client_generator name %s.\nNote: name must be a Symbol" % v.inspect) unless Registry.instance[:client_generator][v]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yao-0.21.0 lib/yao/plugins/default_client_generator.rb
yao-0.20.0 lib/yao/plugins/default_client_generator.rb
yao-0.19.0 lib/yao/plugins/default_client_generator.rb
yao-0.18.0 lib/yao/plugins/default_client_generator.rb
yao-0.17.0 lib/yao/plugins/default_client_generator.rb
yao-0.16.0 lib/yao/plugins/default_client_generator.rb
yao-0.15.0 lib/yao/plugins/default_client_generator.rb
yao-0.14.0 lib/yao/plugins/default_client_generator.rb