Class: Apps::Client
- Inherits:
-
Common::Client::Base
- Object
- Common::Client::Base
- Apps::Client
- Defined in:
- lib/apps/client.rb
Overview
Proxy Service for Apps API.
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.apps'
Instance Attribute Summary collapse
-
#search_term ⇒ Object
readonly
Returns the value of attribute search_term.
Instance Method Summary collapse
-
#get_all ⇒ Object
Get all apps.
-
#get_app ⇒ Object
Get an individual app.
-
#get_scopes ⇒ Object
Get the scopes an app with a given service_category could request.
- #handle_error(error) ⇒ Object private
-
#initialize(search_term = nil) ⇒ Client
constructor
A new instance of Client.
- #save_error_details(error) ⇒ Object private
Methods included from Common::Client::Concerns::Monitoring
#increment, #increment_failure, #increment_total, #with_monitoring
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods inherited from Common::Client::Base
#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name
Constructor Details
#initialize(search_term = nil) ⇒ Client
Returns a new instance of Client.
21 22 23 |
# File 'lib/apps/client.rb', line 21 def initialize(search_term = nil) @search_term = search_term end |
Instance Attribute Details
#search_term ⇒ Object (readonly)
Returns the value of attribute search_term.
19 20 21 |
# File 'lib/apps/client.rb', line 19 def search_term @search_term end |
Instance Method Details
#get_all ⇒ Object
Get all apps
27 28 29 30 31 32 33 34 |
# File 'lib/apps/client.rb', line 27 def get_all with_monitoring do raw_response = perform(:get, 'directory', nil) Apps::Responses::Response.new(raw_response.status, raw_response.body, 'apps') end rescue => e handle_error(e) end |
#get_app ⇒ Object
Get an individual app
38 39 40 41 42 43 44 45 46 |
# File 'lib/apps/client.rb', line 38 def get_app with_monitoring do escaped_code = ERB::Util.url_encode(@search_term) raw_response = perform(:get, "directory/#{escaped_code}", nil) Apps::Responses::Response.new(raw_response.status, raw_response.body, 'app') end rescue => e handle_error(e) end |
#get_scopes ⇒ Object
Get the scopes an app with a given service_category could request
50 51 52 53 54 55 56 57 |
# File 'lib/apps/client.rb', line 50 def get_scopes with_monitoring do raw_response = perform(:get, "directory/scopes/#{@search_term}", nil) Apps::Responses::Response.new(raw_response.status, raw_response.body, 'scopes') end rescue => e handle_error(e) end |
#handle_error(error) ⇒ Object (private)
61 62 63 64 65 66 67 68 69 |
# File 'lib/apps/client.rb', line 61 def handle_error(error) case error when Common::Client::Errors::ClientError save_error_details(error) raise_backend_exception('APPS_502', self.class, error) else raise error end end |