Class: Alula::ClientConfiguration
- Inherits:
-
Object
- Object
- Alula::ClientConfiguration
- Defined in:
- lib/alula/client_configuration.rb
Constant Summary collapse
- REQUEST_ATTRIBUTES =
%i[api_key video_api_key customer_id internal impersonator_api_key]
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.
-
#video_api_url ⇒ Object
Returns the value of attribute video_api_url.
Instance Method Summary collapse
- #ensure_api_key_set ⇒ Object
- #ensure_api_url_set ⇒ Object
- #ensure_customer_id_set ⇒ Object
- #ensure_role_set ⇒ Object
- #ensure_video_api_key_set ⇒ Object
- #ensure_video_api_url_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 |
#video_api_url ⇒ Object
Returns the value of attribute video_api_url.
3 4 5 |
# File 'lib/alula/client_configuration.rb', line 3 def video_api_url @video_api_url end |
Instance Method Details
#ensure_api_key_set ⇒ Object
33 34 35 36 37 38 |
# File 'lib/alula/client_configuration.rb', line 33 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
40 41 42 43 44 |
# File 'lib/alula/client_configuration.rb', line 40 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
60 61 62 63 64 65 |
# File 'lib/alula/client_configuration.rb', line 60 def ensure_customer_id_set return if internal || customer_id raise Alula::NotConfiguredError, 'Set your customer_id before making requests to the video API' end |
#ensure_role_set ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/alula/client_configuration.rb', line 67 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 |
#ensure_video_api_key_set ⇒ Object
53 54 55 56 57 58 |
# File 'lib/alula/client_configuration.rb', line 53 def ensure_video_api_key_set return if video_api_key raise Alula::NotConfiguredError, 'Set your video API access token before making requests to the video API' end |
#ensure_video_api_url_set ⇒ Object
46 47 48 49 50 51 |
# File 'lib/alula/client_configuration.rb', line 46 def ensure_video_api_url_set return unless video_api_url.nil? raise Alula::NotConfiguredError, 'did you forget to set the Alula::Client.config.video_api_url config option?' end |
#role ⇒ Object
29 30 31 |
# File 'lib/alula/client_configuration.rb', line 29 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.
21 22 23 24 25 26 27 |
# File 'lib/alula/client_configuration.rb', line 21 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 |