Class: Mrt::Ingest::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mrt/ingest/client.rb

Overview

A client for ingesting objects into a Merritt.

Instance Method Summary collapse

Constructor Details

#initialize(base_uri, username = nil, password = nil) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
# File 'lib/mrt/ingest/client.rb', line 13

def initialize(base_uri, username=nil, password=nil)
  @base_uri = base_uri
  @username = username
  @password = password
end

Instance Method Details

#ingest(ingest_req) ⇒ Object

Send a request to the client.



20
21
22
# File 'lib/mrt/ingest/client.rb', line 20

def ingest(ingest_req)
  return Response.new(mk_rest_request(ingest_req).execute())
end

#mk_rest_request(ingest_req) ⇒ Object

:nodoc:



25
26
27
28
29
30
31
32
33
34
# File 'lib/mrt/ingest/client.rb', line 25

def mk_rest_request(ingest_req)
  args = { 
    :method   => :post,
    :url      => @base_uri,
    :user     => @username,
    :password => @password,
    :payload  => ingest_req.mk_args(),
    :headers  => { :multipart => true } }.delete_if { |k,v| (v.nil? || v == "") }
  return RestClient::Request.new(args)
end