Class: Flydata::ApiClient
- Inherits:
-
Object
- Object
- Flydata::ApiClient
- Includes:
- Helpers, Singleton
- Defined in:
- lib/flydata/api_client.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#flydata_api_host ⇒ Object
readonly
Returns the value of attribute flydata_api_host.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize ⇒ ApiClient
constructor
A new instance of ApiClient.
-
#method_missing(cls_name, *args, &block) ⇒ Object
high level api.
-
#post(path, headers = nil, params = nil) ⇒ Object
row level api.
- #put(path, params = nil) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Methods included from Helpers
development?, env_mode, env_suffix, flydata_api_host_file, flydata_conf_file, format_menu_list, parse_command, retry_on, to_command_class, usage_text
Constructor Details
#initialize ⇒ ApiClient
Returns a new instance of ApiClient.
14 15 16 17 |
# File 'lib/flydata/api_client.rb', line 14 def initialize @credentials = Flydata::Credentials.new read_flydata_api_host end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(cls_name, *args, &block) ⇒ Object
high level api
40 41 42 43 44 |
# File 'lib/flydata/api_client.rb', line 40 def method_missing(cls_name, *args, &block) method_name = args.shift.to_s api_cls = "Flydata::Api::#{cls_name.to_s.camelize}".constantize api_cls.new(self) end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
11 12 13 |
# File 'lib/flydata/api_client.rb', line 11 def credentials @credentials end |
#flydata_api_host ⇒ Object (readonly)
Returns the value of attribute flydata_api_host.
12 13 14 |
# File 'lib/flydata/api_client.rb', line 12 def flydata_api_host @flydata_api_host end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/flydata/api_client.rb', line 10 def response @response end |
Instance Method Details
#get(path) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/flydata/api_client.rb', line 32 def get(path) uri = generate_auth_url(path) resource = RestClient::Resource.new(uri, resource_opts) @response = resource.get(:accept => :json) handle_response response end |
#post(path, headers = nil, params = nil) ⇒ Object
row level api
20 21 22 23 24 25 |
# File 'lib/flydata/api_client.rb', line 20 def post(path, headers = nil, params=nil) uri = generate_auth_url(path) resource = RestClient::Resource.new(uri, resource_opts(headers)) @response = resource.post(params, :accept => :json) handle_response response end |
#put(path, params = nil) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/flydata/api_client.rb', line 26 def put(path, params=nil) uri = generate_auth_url(path) resource = RestClient::Resource.new(uri, resource_opts) @response = resource.put(params, :accept => :json) handle_response response end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
45 |
# File 'lib/flydata/api_client.rb', line 45 def respond_to_missing?(method_name, include_private=false); true end |