Class: Apps::Client

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::Monitoring, SentryLogging
Defined in:
lib/apps/client.rb

Overview

Proxy Service for Apps API.

Constant Summary collapse

STATSD_KEY_PREFIX =
'api.apps'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common::Client::Concerns::Monitoring

#with_monitoring

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

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_termObject (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_allObject

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_appObject

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_scopesObject

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