Class: Keepcon::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



6
7
8
9
10
11
12
13
# File 'lib/keepcon/client.rb', line 6

def initialize
  self.config = {
    'urls' => load_yml('config/urls.yml'),
    'client' => load_yml('config/client.yml')
  }

  yield self if block_given?
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/keepcon/client.rb', line 3

def config
  @config
end

#password=(value) ⇒ Object (writeonly)

Sets the attribute password

Parameters:

  • value

    the value to set the attribute password to.



4
5
6
# File 'lib/keepcon/client.rb', line 4

def password=(value)
  @password = value
end

#userObject

Returns the value of attribute user.



3
4
5
# File 'lib/keepcon/client.rb', line 3

def user
  @user
end

Instance Method Details

#async_ack(setId) ⇒ Object



28
29
30
31
32
33
# File 'lib/keepcon/client.rb', line 28

def async_ack(setId)
  url = config['urls']['content']['response']['ack']
  url = url % { setId: setId }

  request(:put, url)
end

#async_results_requestObject



21
22
23
24
25
26
# File 'lib/keepcon/client.rb', line 21

def async_results_request
  url = config['urls']['content']['response']['async']
  url = url % { context_name: user }

  request(:put, url)
end

#content_request(data, mode) ⇒ Object



15
16
17
18
19
# File 'lib/keepcon/client.rb', line 15

def content_request(data, mode)
  fail ArgumentError, 'The data can not be empty' unless data.present?

  request(:put, config['urls']['content']['request'][mode.to_s], data, mode)
end