Class: Forms::Client
- Inherits:
-
Common::Client::Base
- Object
- Common::Client::Base
- Forms::Client
- Defined in:
- lib/forms/client.rb
Overview
Proxy Service for Forms API.
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.forms'
Instance Attribute Summary collapse
-
#search_term ⇒ Object
readonly
Returns the value of attribute search_term.
Instance Method Summary collapse
-
#get_all ⇒ Object
Get all forms with an optional query parameter “query” for wildcard filtering.
- #handle_error(error) ⇒ Object private
-
#initialize(search_term) ⇒ 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) ⇒ Client
Returns a new instance of Client.
23 24 25 |
# File 'lib/forms/client.rb', line 23 def initialize(search_term) @search_term = search_term end |
Instance Attribute Details
#search_term ⇒ Object (readonly)
Returns the value of attribute search_term.
21 22 23 |
# File 'lib/forms/client.rb', line 21 def search_term @search_term end |
Instance Method Details
#get_all ⇒ Object
Get all forms with an optional query parameter “query” for wildcard filtering.
29 30 31 32 33 34 35 36 |
# File 'lib/forms/client.rb', line 29 def get_all with_monitoring do raw_response = perform(:get, 'forms', query: search_term) Forms::Responses::Response.new(raw_response.status, raw_response.body, 'forms') end rescue => e handle_error(e) end |
#handle_error(error) ⇒ Object (private)
40 41 42 43 44 45 46 47 48 |
# File 'lib/forms/client.rb', line 40 def handle_error(error) case error when Common::Client::Errors::ClientError save_error_details(error) raise_backend_exception('FORMS_502', self.class, error) else raise error end end |