Class: ApiRecipes::Api
- Inherits:
-
Object
- Object
- ApiRecipes::Api
- Defined in:
- lib/api_recipes/api.rb
Constant Summary collapse
- BASE_CONFIGS_KEYS =
[:protocol, :host, :port, :api_version, :timeout, :on_bad_code, :mime_type, :verify_with]
Instance Attribute Summary collapse
-
#authorization ⇒ Object
Returns the value of attribute authorization.
-
#base_configs ⇒ Object
readonly
Returns the value of attribute base_configs.
-
#basic_auth ⇒ Object
Returns the value of attribute basic_auth.
-
#configs ⇒ Object
Returns the value of attribute configs.
-
#name ⇒ Object
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(name, configs, object) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(name, configs, object) ⇒ Api
Returns a new instance of Api.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/api_recipes/api.rb', line 9 def initialize(name, configs, object) @name = name @configs = ApiRecipes::Settings::DEFAULT.merge configs @object = object # Generate some_api.some_endpoint methods # e.g. github.users endpoints = @configs[:endpoints] if endpoints && endpoints.is_a?(Hash) endpoints.each do |ep_name, params| unless respond_to? ep_name # TODO: store endpoints, routes and routes_urls define_singleton_method ep_name do |*request_params, &block| # puts "API params: #{params}" Endpoint.new api: self, name: ep_name, path: path, params: params, request_params: request_params, &block end end end end end |
Instance Attribute Details
#authorization ⇒ Object
Returns the value of attribute authorization.
4 5 6 |
# File 'lib/api_recipes/api.rb', line 4 def @authorization end |
#base_configs ⇒ Object (readonly)
Returns the value of attribute base_configs.
5 6 7 |
# File 'lib/api_recipes/api.rb', line 5 def base_configs @base_configs end |
#basic_auth ⇒ Object
Returns the value of attribute basic_auth.
4 5 6 |
# File 'lib/api_recipes/api.rb', line 4 def basic_auth @basic_auth end |
#configs ⇒ Object
Returns the value of attribute configs.
4 5 6 |
# File 'lib/api_recipes/api.rb', line 4 def configs @configs end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/api_recipes/api.rb', line 4 def name @name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
5 6 7 |
# File 'lib/api_recipes/api.rb', line 5 def object @object end |