Class: Rodzilla::Resource::Base
- Inherits:
-
Object
- Object
- Rodzilla::Resource::Base
- Defined in:
- lib/rodzilla/resource/base.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#format ⇒ Object
Returns the value of attribute format.
-
#password ⇒ Object
Returns the value of attribute password.
-
#service ⇒ Object
Returns the value of attribute service.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(base_url, username, password, format = :json) ⇒ Base
constructor
A new instance of Base.
-
#raw_http_request(http_method, url, options = {}) ⇒ Object
Makes a GET request to the service endpoint and checks if the return status is 200.
- #rpc_call(rpc_method_name, params = {}, http_method = :post) ⇒ Object
Constructor Details
#initialize(base_url, username, password, format = :json) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 |
# File 'lib/rodzilla/resource/base.rb', line 6 def initialize(base_url, username, password, format=:json) @base_url = base_url @username = username @password = password @format = format setup_service(format) end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
4 5 6 |
# File 'lib/rodzilla/resource/base.rb', line 4 def base_url @base_url end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/rodzilla/resource/base.rb', line 4 def format @format end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/rodzilla/resource/base.rb', line 4 def password @password end |
#service ⇒ Object
Returns the value of attribute service.
4 5 6 |
# File 'lib/rodzilla/resource/base.rb', line 4 def service @service end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/rodzilla/resource/base.rb', line 4 def username @username end |
Instance Method Details
#raw_http_request(http_method, url, options = {}) ⇒ Object
Makes a GET request to the service endpoint and checks if the return status is 200
21 22 23 |
# File 'lib/rodzilla/resource/base.rb', line 21 def raw_http_request(http_method, url, ={}) @service.send_raw_request(http_method, url, ) end |
#rpc_call(rpc_method_name, params = {}, http_method = :post) ⇒ Object
15 16 17 |
# File 'lib/rodzilla/resource/base.rb', line 15 def rpc_call(rpc_method_name, params={}, http_method=:post) service.send_request!( get_resource_rpc_method_name(rpc_method_name), params, http_method) end |