Class: Multicolor::REST::Transport

Inherits:
Object
  • Object
show all
Includes:
Endpoints::Filepath, Endpoints::Indexing, Endpoints::Metadata
Defined in:
lib/multicolor/rest/transport.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Endpoints::Metadata

#count, #count_collection_colors, #count_metadata, #get_return_metadata, #get_search_metadata, #list, #ping

Methods included from Endpoints::Indexing

#add, #delete

Methods included from Endpoints::Filepath

#color_search, #extract_collection_colors, #get_metadata, #update_metadata

Constructor Details

#initialize(config) ⇒ Transport

Returns a new instance of Transport.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/multicolor/rest/transport.rb', line 16

def initialize(config)
  @config = config

  @client = Faraday.new(url: url) do |conn|
    conn.request  :multipart
    conn.request  :url_encoded
    conn.response :json
    conn.adapter  :net_http

    conn.use Faraday::Response::RaiseError

    conn.options[:timeout]      = config.timeout
    conn.options[:open_timeout] = config.open_timeout

    conn.basic_auth(config.username, config.password) if config.authenticate?
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



12
13
14
# File 'lib/multicolor/rest/transport.rb', line 12

def client
  @client
end

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/multicolor/rest/transport.rb', line 12

def config
  @config
end