class GlimrApiClient::RegisterNewCase

Constants

TRIBUNAL_JURISDICTION_ID

Attributes

request_body[R]

Public Class Methods

new(params) click to toggle source
# File lib/glimr_api_client/register_new_case.rb, line 11
def initialize(params)
  @request_body = params
end

Public Instance Methods

timeout() click to toggle source

This addresses the problem that RegisterNewCase calls can take a much longer time to respond than availability calls. At the time this was written, the connection was periodically timing out at just over 30 seconds.

# File lib/glimr_api_client/register_new_case.rb, line 19
def timeout
  Integer(ENV.fetch('GLIMR_REGISTER_NEW_CASE_TIMEOUT_SECONDS', 32))
end

Private Instance Methods

check_request!() click to toggle source
# File lib/glimr_api_client/register_new_case.rb, line 25
def check_request!
  errors = []
  [
    :jurisdictionId,
    :onlineMappingCode
  ].each do |required|
    errors << required if request_body.fetch(required, nil).nil?
  end
  raise RequestError, errors unless errors.empty?
end
endpoint() click to toggle source
# File lib/glimr_api_client/register_new_case.rb, line 36
def endpoint
  '/registernewcase'
end
re_raise_error(body) click to toggle source
Calls superclass method GlimrApiClient::Api#re_raise_error
# File lib/glimr_api_client/register_new_case.rb, line 40
def re_raise_error(body)
  error = body.fetch(:message, nil)
  case body.fetch(:glimrerrorcode, nil)
  when 411 # Jusidiction not found
    raise JurisdictionNotFound, error
  when 412 # Online Mapping not found or invalid
    raise OnlineMappingNotFoundOrInvalid, error
  when 421 # Creation failed (due to a database problem)
    raise CaseCreationFailed, error
  end
  super(message: error)
end