Class: RTrail::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, user, password) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
# File 'lib/rtrail/client.rb', line 11

def initialize(base_url, user, password)
  @base_url = base_url
  @user = user
  @password = password
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



16
17
18
# File 'lib/rtrail/client.rb', line 16

def base_url
  @base_url
end

#passwordObject (readonly)

Returns the value of attribute password.



16
17
18
# File 'lib/rtrail/client.rb', line 16

def password
  @password
end

#userObject (readonly)

Returns the value of attribute user.



16
17
18
# File 'lib/rtrail/client.rb', line 16

def user
  @user
end

Instance Method Details

#get(path) ⇒ Object

Send a GET request to the API and return a Hashie::Mash (for individual object requests) or an Array of Hashie::Mash (for requests returning a list of objects).

Parameters:

  • path (String)

    The API method to call including parameters (e.g. get_case/1)



25
26
27
# File 'lib/rtrail/client.rb', line 25

def get(path)
  _request(:get, path)
end

#post(path, data) ⇒ Object

Send a POST request to the API and return a Hashie::Mash.

Parameters:

  • path (String)

    The API method to call including parameters (e.g. add_case/1)

  • data (Hash)

    The data to submit as part of the request. Strings must be UTF-8 encoded.



37
38
39
# File 'lib/rtrail/client.rb', line 37

def post(path, data)
  _request(:post, path, data)
end