Class: GlimrApiClient::FindCase

Inherits:
Base
  • Object
show all
Defined in:
lib/glimr_api_client/find_case.rb

Overview

TODO: rename so it follow api spec

Defined Under Namespace

Classes: InvalidCaseNumber, NotFound

Constant Summary collapse

TRIBUNAL_JURISDICTION_ID =
8

Instance Attribute Summary

Attributes inherited from Base

#args

Attributes included from Api

#response_body

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call, #check_request!

Methods included from Api

#post, #timeout

Constructor Details

#initialize(case_reference, confirmation_code) ⇒ FindCase

Returns a new instance of FindCase.



14
15
16
17
# File 'lib/glimr_api_client/find_case.rb', line 14

def initialize(case_reference, confirmation_code)
  @case_reference = case_reference
  @confirmation_code = confirmation_code
end

Class Method Details

.find(case_reference, confirmation_code) ⇒ Object

TODO: Case should use ‘#call(params)` directly, like everything else.



10
11
12
# File 'lib/glimr_api_client/find_case.rb', line 10

def self.find(case_reference, confirmation_code)
  new(case_reference, confirmation_code).call
end

Instance Method Details

#callObject



19
20
21
22
# File 'lib/glimr_api_client/find_case.rb', line 19

def call
  post
  self
end

#feesObject

We only care about outstanding fee liabilities, wrt what we are asking the taxpayer to pay



37
38
39
# File 'lib/glimr_api_client/find_case.rb', line 37

def fees
  unpaid_fees
end

#titleObject

Case title is returned with each fee liability, rather than as a top-level attribute of the case. If there are any unpaid fee liabilities, we want to take the title from the first of these (because that is the most relevant title)



28
29
30
31
32
33
# File 'lib/glimr_api_client/find_case.rb', line 28

def title
  @title ||= begin
               fee = unpaid_fees.any? ? unpaid_fees.first : all_fees.first
               fee.nil? ? 'Missing Title' : fee.case_title
             end
end