Class: JsonClient::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/json_client/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pather, config) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
# File 'lib/json_client/base.rb', line 9

def initialize(pather, config)
  @api_key = config[:api_key]
  @api_password = config[:api_password]
  @pather = pather
  validate_variables
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/json_client/base.rb', line 7

def api_key
  @api_key
end

#api_passwordObject (readonly)

Returns the value of attribute api_password.



7
8
9
# File 'lib/json_client/base.rb', line 7

def api_password
  @api_password
end

#patherObject (readonly)

Returns the value of attribute pather.



7
8
9
# File 'lib/json_client/base.rb', line 7

def pather
  @pather
end

Instance Method Details

#create(model) ⇒ Object



26
27
28
29
30
31
# File 'lib/json_client/base.rb', line 26

def create(model)
  response = requestors.create.new.fetch(
    request_path, auth_params, model
  )
  responders.create.new(response.body, response.code)
end

#destroy(id) ⇒ Object



40
41
42
43
44
45
# File 'lib/json_client/base.rb', line 40

def destroy(id)
  response = requestors.destroy.new.fetch(
    request_path(id), auth_params
  )
  responders.destroy.new(response.body, response.code)
end

#indexObject



16
17
18
19
# File 'lib/json_client/base.rb', line 16

def index
  response = requestors.index.new.fetch(request_path, auth_params)
  responders.index.new(response.body, response.code)
end

#show(id) ⇒ Object



21
22
23
24
# File 'lib/json_client/base.rb', line 21

def show(id)
  response = requestors.show.new.fetch(request_path(id), auth_params)
  responders.show.new(response.body, response.code)
end

#update(id, model) ⇒ Object



33
34
35
36
37
38
# File 'lib/json_client/base.rb', line 33

def update(id, model)
  response = requestors.update.new.fetch(
    request_path(id), auth_params, model
  )
  responders.update.new(response.body, response.code)
end