Sha256: 943af119ddb7169eb7325efb7677d6343f8cc8b6878aaa5e3682912043bacead

Contents?: true

Size: 673 Bytes

Versions: 4

Compression:

Stored size: 673 Bytes

Contents

module Rainforest
  class ApiClient
    attr_accessor :headers, :params

    def initialize(headers, params)
      self.refresh_from(headers, params)
    end

    def refresh_from(headers, params)
      @headers = headers
      @params = params
      self
    end

    def execute(api_method)
      api_method.headers = ParamsBuilder.merge(api_method.headers, @headers)
      api_method.params = ParamsBuilder.merge(api_method.params, @params)
      api_method.execute
    end

    def inspect
      "#<#{self.class}:0x#{self.object_id.to_s(16)}> Headers: " +
        JSON.pretty_generate(@headers) + ", Params: " +
        JSON.pretty_generate(@params)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rainforest-2.1.0 lib/rainforest/apibits/api_client.rb
rainforest-2.0.2 lib/rainforest/apibits/api_client.rb
rainforest-2.0.1 lib/rainforest/apibits/api_client.rb
rainforest-2.0.0 lib/rainforest/apibits/api_client.rb