Class: Hopo::API

Inherits:
Object show all
Includes:
Connections::Request, Connections::Response
Defined in:
lib/hopo/api.rb

Direct Known Subclasses

Rater

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Connections::Response

included

Methods included from Connections::Request

#delete, #get, included, #patch, #post, #put

Constructor Details

#initialize(url, path = nil, ssl = false) ⇒ API



9
10
11
12
13
14
15
16
# File 'lib/hopo/api.rb', line 9

def initialize(url, path=nil, ssl=false)
  @default_params = {}
  @params = {}
  @url = url
  @path = path
  @ssl = ssl
  setup_connections
end

Instance Attribute Details

#default_paramsObject (readonly)

Returns the value of attribute default_params.



6
7
8
# File 'lib/hopo/api.rb', line 6

def default_params
  @default_params
end

#httpObject

Returns the value of attribute http.



7
8
9
# File 'lib/hopo/api.rb', line 7

def http
  @http
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/hopo/api.rb', line 6

def path
  @path
end

#sslObject (readonly)

Returns the value of attribute ssl.



6
7
8
# File 'lib/hopo/api.rb', line 6

def ssl
  @ssl
end

#uriObject

Returns the value of attribute uri.



7
8
9
# File 'lib/hopo/api.rb', line 7

def uri
  @uri
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/hopo/api.rb', line 6

def url
  @url
end

Instance Method Details

#full_pathObject



27
28
29
# File 'lib/hopo/api.rb', line 27

def full_path
  "#{url}#{path}"
end

#paramsObject



23
24
25
# File 'lib/hopo/api.rb', line 23

def params
  @params
end

#params=(parameters) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
# File 'lib/hopo/api.rb', line 18

def params=(parameters)
  raise ArgumentError, 'parameters must be a hash {}' unless parameters.is_a?(Hash)
  @params = parameters
end