Class: DCMClient::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/dcm_client/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Connection

Returns a new instance of Connection.



20
21
22
23
24
25
# File 'lib/dcm_client/connection.rb', line 20

def initialize(opts={})
  self.username = opts[:username]
  self.password = opts[:password]
  self.api_root = opts[:api_root]
  self.logger   = opts[:logger]
end

Instance Attribute Details

#api_rootObject

Returns the value of attribute api_root.



3
4
5
# File 'lib/dcm_client/connection.rb', line 3

def api_root
  @api_root
end

#connectionObject

Returns the value of attribute connection.



3
4
5
# File 'lib/dcm_client/connection.rb', line 3

def connection
  @connection
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/dcm_client/connection.rb', line 3

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/dcm_client/connection.rb', line 3

def password
  @password
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/dcm_client/connection.rb', line 3

def username
  @username
end

Instance Method Details

#delete(href) ⇒ Object



14
15
16
17
18
# File 'lib/dcm_client/connection.rb', line 14

def delete(href)
  wrap do
    connection.delete("#{href}.json")
  end
end

#post(href, body) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/dcm_client/connection.rb', line 5

def post(href, body)
  wrap do
    connection.post do |req|
      req.url href
      req.body = body.to_json
    end
  end
end