class GlimrApiClient::Update

TODO: rename so it follow api spec

Attributes

request_body[R]

TODO: Move this and initialize into Base. It’s the same for all but Case.

Public Class Methods

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

Private Instance Methods

check_request!() click to toggle source

TODO: Set the attributes in a constant and move this to Base.

# File lib/glimr_api_client/update.rb, line 20
def check_request!
  errors = []
  [
    :feeLiabilityId,
    :paymentReference,
    :govpayReference,
    :paidAmountInPence
  ].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/update.rb, line 33
def endpoint
  '/paymenttaken'
end
re_raise_error(body) click to toggle source
Calls superclass method GlimrApiClient::Api#re_raise_error
# File lib/glimr_api_client/update.rb, line 37
def re_raise_error(body)
  error = body.fetch(:message, nil)
  case body.fetch(:glimrerrorcode, nil)
  when 311 # FeeLiability not found
    raise FeeLiabilityNotFound, error
  when 312 # Invalid format for PaymentReference
    raise PaymentReferenceInvalidFormat, error
  when 314 # Invalid format for GovPayReference
    raise GovPayReferenceInvalidFormat, error
  when 315 # Invalid PaidAmount
    raise InvalidAmount, error
  when 321 # GovPay reference already exists on system
    raise GovPayReferenceExistsOnSystem, error
  end
  super(message: error)
end