Class: Alula::ClientConfiguration
- Inherits:
-
Object
- Object
- Alula::ClientConfiguration
- Defined in:
- lib/alula/client_configuration.rb
Constant Summary collapse
- REQUEST_ATTRIBUTES =
%i[api_key customer_id]
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #ensure_api_key_set ⇒ Object
- #ensure_api_url_set ⇒ Object
- #ensure_customer_id_set ⇒ Object
- #ensure_role_set ⇒ Object
- #role ⇒ Object
-
#role=(user_type) ⇒ Object
Stash the user type as a role for us to infer from later You can set a symbolized role via role = :user, or provide the string userType We cast to a symbolized role for ease of use in consumers.
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
3 4 5 |
# File 'lib/alula/client_configuration.rb', line 3 def api_url @api_url end |
#debug ⇒ Object
Returns the value of attribute debug.
3 4 5 |
# File 'lib/alula/client_configuration.rb', line 3 def debug @debug end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
3 4 5 |
# File 'lib/alula/client_configuration.rb', line 3 def user_agent @user_agent end |
Instance Method Details
#ensure_api_key_set ⇒ Object
32 33 34 35 36 37 |
# File 'lib/alula/client_configuration.rb', line 32 def ensure_api_key_set if api_key.nil? raise Alula::NotConfiguredError, 'Set your API access token before making requests with Alula::Client.config.api_key = {access_token}' end end |
#ensure_api_url_set ⇒ Object
39 40 41 42 43 |
# File 'lib/alula/client_configuration.rb', line 39 def ensure_api_url_set if api_url.nil? raise Alula::NotConfiguredError, 'did you forget to set the Alula::Client.config.api_url config option?' end end |
#ensure_customer_id_set ⇒ Object
45 46 47 48 49 50 |
# File 'lib/alula/client_configuration.rb', line 45 def ensure_customer_id_set unless customer_id raise Alula::NotConfiguredError, 'Set your customer_id before making requests to the video API' end end |
#ensure_role_set ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/alula/client_configuration.rb', line 52 def ensure_role_set if role.nil? = 'User role not configured! You must set '\ 'Alula::Client.config.role '\ 'before attempting to save any resources' raise Alula::NotConfiguredError, end end |
#role ⇒ Object
28 29 30 |
# File 'lib/alula/client_configuration.rb', line 28 def role RequestStore.store['alula_role'] end |
#role=(user_type) ⇒ Object
Stash the user type as a role for us to infer from later You can set a symbolized role via role = :user, or provide the string userType We cast to a symbolized role for ease of use in consumers.
20 21 22 23 24 25 26 |
# File 'lib/alula/client_configuration.rb', line 20 def role=(user_type) unless user_type.is_a?(Symbol) || user_type.is_a?(String) raise Alula::InvalidRoleError, 'Role must be symbol or string' end RequestStore.store['alula_role'] = Util.underscore(user_type).to_sym end |