Class: JsonClient::Base
- Inherits:
-
Object
- Object
- JsonClient::Base
- Defined in:
- lib/json_client/base.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_password ⇒ Object
readonly
Returns the value of attribute api_password.
-
#pather ⇒ Object
readonly
Returns the value of attribute pather.
Instance Method Summary collapse
- #create(model) ⇒ Object
- #destroy(id) ⇒ Object
- #index ⇒ Object
-
#initialize(pather, config) ⇒ Base
constructor
A new instance of Base.
- #show(id) ⇒ Object
- #update(id, model) ⇒ Object
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_key ⇒ Object (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_password ⇒ Object (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 |
#pather ⇒ Object (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 |
#index ⇒ Object
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 |