class EtCcdClient::UiClient
A client to interact with the CCD UI API (front end)
Attributes
Public Class Methods
# File lib/et_ccd_client/ui_client.rb, line 15 def initialize(ui_idam_client: UiIdamClient.new, config: ::EtCcdClient.config) self.ui_idam_client = ui_idam_client self.config = config self.logger = config.logger end
Public Instance Methods
List all cases (paginated) @param [String] case_type_id The case type ID to set the search scope to @param [Integer] page - The page number to fetch @param [String] sort_direction (defaults to 'desc') - Change to 'asc' to do oldest first
@return [Array<Hash>] The json response from the server
# File lib/et_ccd_client/ui_client.rb, line 139 def caseworker_list_cases(case_type_id:, page: 1, sort_direction: 'desc') logger.tagged('EtCcdClient::UiClient') do tpl = Addressable::Template.new(config.cases_path) path = tpl.expand(uid: ui_idam_client.user_details['id'], jid: config.jurisdiction_id, ctid: case_type_id, query: { page: page, 'sortDirection' => sort_direction }).to_s url = "#{config.gateway_api_url}/aggregated#{path}" resp = get_request(url, log_subject: 'List all cases', extra_headers: { content_type: 'application/json', accept: 'application/json' }, cookies: { accessToken: ui_idam_client.user_token }) resp["results"] end end
Search for cases by bulk case title - useful for testing @param [String] case_title The bulk case title to search for @param [String] case_type_id The case type ID to set the search scope to @param [Integer] page - The page number to fetch @param [String] sort_direction (defaults to 'desc') - Change to 'asc' to do oldest first
@return [Array<Hash>] The json response from the server
# File lib/et_ccd_client/ui_client.rb, line 114 def caseworker_search_by_bulk_case_title(case_title, case_type_id:, page: 1, sort_direction: 'desc') logger.tagged('EtCcdClient::UiClient') do tpl = Addressable::Template.new(config.cases_path) path = tpl.expand(uid: ui_idam_client.user_details['id'], jid: config.jurisdiction_id, ctid: case_type_id, query: { 'case.multipleName' => case_title, page: page, 'sortDirection' => sort_direction }).to_s url = "#{config.gateway_api_url}/aggregated#{path}" resp = get_request(url, log_subject: 'Case worker search by bulk case title', extra_headers: { content_type: 'application/json', accept: 'application/json' }, cookies: { accessToken: ui_idam_client.user_token }) resp["results"] end end
Search for cases by ethos case reference - useful for testing @param [String] reference The ethos case reference number to search for @param [String] case_type_id The case type ID to set the search scope to @param [Integer] page - The page number to fetch @param [String] sort_direction (defaults to 'desc') - Change to 'asc' to do oldest first
@return [Array<Hash>] The json response from the server
# File lib/et_ccd_client/ui_client.rb, line 59 def caseworker_search_by_ethos_case_reference(reference, case_type_id:, page: 1, sort_direction: 'desc') logger.tagged('EtCcdClient::UiClient') do tpl = Addressable::Template.new(config.cases_path) path = tpl.expand(uid: ui_idam_client.user_details['id'], jid: config.jurisdiction_id, ctid: case_type_id, query: { 'case.ethosCaseReference' => reference, page: page, 'sortDirection' => sort_direction }).to_s url = "#{config.gateway_api_url}/aggregated#{path}" resp = get_request(url, log_subject: 'Caseworker search by ethos case reference', extra_headers: { content_type: 'application/json', accept: 'application/json' }, cookies: { accessToken: ui_idam_client.user_token }) unless config.document_store_url_rewrite == false resp = reverse_rewrite_document_store_urls(resp) end resp["results"] end end
Search for cases by multiples reference - useful for testing @param [String] reference The multiples reference number to search for @param [String] case_type_id The case type ID to set the search scope to @param [Integer] page - The page number to fetch @param [String] sort_direction (defaults to 'desc') - Change to 'asc' to do oldest first
@return [Array<Hash>] The json response from the server
# File lib/et_ccd_client/ui_client.rb, line 88 def caseworker_search_by_multiple_reference(reference, case_type_id:, page: 1, sort_direction: 'desc') logger.tagged('EtCcdClient::UiClient') do tpl = Addressable::Template.new(config.cases_path) path = tpl.expand(uid: ui_idam_client.user_details['id'], jid: config.jurisdiction_id, ctid: case_type_id, query: { 'case.multipleReference' => reference, page: page, 'sortDirection' => sort_direction }).to_s url = "#{config.gateway_api_url}/aggregated#{path}" resp = get_request(url, log_subject: 'Case worker search by multiple reference', extra_headers: { content_type: 'application/json', accept: 'application/json' }, cookies: { accessToken: ui_idam_client.user_token }) resp["results"] end end
Search for cases by reference - useful for testing @param [String] reference The reference number to search for @param [String] case_type_id The case type ID to set the search scope to @param [Integer] page - The page number to fetch @param [String] sort_direction (defaults to 'desc') - Change to 'asc' to do oldest first
@return [Array<Hash>] The json response from the server
# File lib/et_ccd_client/ui_client.rb, line 30 def caseworker_search_by_reference(reference, case_type_id:, page: 1, sort_direction: 'desc') logger.tagged('EtCcdClient::UiClient') do tpl = Addressable::Template.new(config.cases_path) path = tpl.expand(uid: ui_idam_client.user_details['id'], jid: config.jurisdiction_id, ctid: case_type_id, query: { 'case.feeGroupReference' => reference, page: page, 'sortDirection' => sort_direction }).to_s url = "#{config.gateway_api_url}/aggregated#{path}" resp = get_request(url, log_subject: 'Caseworker search by reference', extra_headers: { content_type: 'application/json', accept: 'application/json' }, cookies: { accessToken: ui_idam_client.user_token }) unless config.document_store_url_rewrite == false resp = reverse_rewrite_document_store_urls(resp) end resp["results"] end end
Search for the latest case matching the bulk case title. Useful for testing @param [String] case-title The bulk case title to search for @param [String] case_type_id The case type ID to set the search scope to @return [Hash] The case object returned from the server
# File lib/et_ccd_client/ui_client.rb, line 128 def caseworker_search_latest_by_bulk_case_title(case_title, case_type_id:) results = caseworker_search_by_bulk_case_title(case_title, case_type_id: case_type_id, page: 1, sort_direction: 'desc') results.first end
Search for the latest case matching the ethos case reference. Useful for testing @param [String] reference The ethos case reference number to search for @param [String] case_type_id The case type ID to set the search scope to @return [Hash] The case object returned from the server
# File lib/et_ccd_client/ui_client.rb, line 76 def caseworker_search_latest_by_ethos_case_reference(reference, case_type_id:) results = caseworker_search_by_ethos_case_reference(reference, case_type_id: case_type_id, page: 1, sort_direction: 'desc') results.first end
Search for the latest case matching the multiple reference. Useful for testing @param [String] reference The multiples reference number to search for @param [String] case_type_id The case type ID to set the search scope to @return [Hash] The case object returned from the server
# File lib/et_ccd_client/ui_client.rb, line 102 def caseworker_search_latest_by_multiple_reference(reference, case_type_id:) results = caseworker_search_by_multiple_reference(reference, case_type_id: case_type_id, page: 1, sort_direction: 'desc') results.first end
Search for the latest case matching the reference. Useful for testing @param [String] reference The reference number to search for @param [String] case_type_id The case type ID to set the search scope to @return [Hash] The case object returned from the server
# File lib/et_ccd_client/ui_client.rb, line 47 def caseworker_search_latest_by_reference(reference, case_type_id:) results = caseworker_search_by_reference(reference, case_type_id: case_type_id, page: 1, sort_direction: 'desc') results.first end
Private Instance Methods
# File lib/et_ccd_client/ui_client.rb, line 154 def reverse_rewrite_document_store_urls(json) source_host, source_port, dest_host, dest_port = config.document_store_url_rewrite JSON.parse(JSON.generate(json).gsub(/(https?):\/\/#{Regexp.quote dest_host}:#{Regexp.quote dest_port}/, "\\1://#{source_host}:#{source_port}")) end