module CrvApiClient::Helpers::Crv

Public Instance Methods

context_message(keeper, context_message_detail: [], username: "", password: "", provider: nil, customer: nil, animal: nil, process_code: "", organisation: nil) click to toggle source
# File lib/crv_api_client/helpers/crv.rb, line 38
def context_message(keeper,
                    context_message_detail: [],
                    username: "",
                    password: "",
                    provider: nil,
                    customer: nil,
                    animal: nil,
                    process_code: "",
                    organisation: nil)
  context = endpoint_context_message.new
  context.sessionId = ""
  context.processId = ""
  context.instanceId = ""
  context.username = username
  context.userType = "C"
  context.password = password
  context.organisation = organisation
  context.provider = provider
  context.customer = customer
  context.keeper = keeper
  context.animal = animal
  context.processCode = process_code
  context.messageSource = ""
  context.languageCode = ""
  context.timeZone = ""
  context.contextMessageDetail = context_message_detail
  context
end
get_crv_organisation_code(country) click to toggle source
# File lib/crv_api_client/helpers/crv.rb, line 27
def get_crv_organisation_code(country)
  country = country.upcase unless country.nil?
  value = case country
            when nil, "NL" then "crv.nl" # Netherlands
            when "BE" then "crv.be" # Belgium
            when "DE" then "crv.de" # Germany
            when "CZ" then "crv.cz" # Czech
          end
  value
end
get_keeper(crv_id, country) click to toggle source
# File lib/crv_api_client/helpers/crv.rb, line 6
def get_keeper(crv_id, country)
  keeper = endpoint_participant_id.new
  keeper.participantCode = crv_id
  country = country.upcase unless country.nil?
  case(country)
    when nil, "NL" # Netherlands
      keeper.participantCodeType = "UBN"
      keeper.countryCode = "NLD"
    when "BE" # Belgium
      keeper.participantCodeType = "UVN"
      keeper.countryCode = "BE"
    when "DE" # Germany
      keeper.participantCodeType = "LDE"
      keeper.countryCode = "DE"
    when "CZ" # Czech
      keeper.participantCodeType = "LCZ"
      keeper.countryCode = "CZ"
  end
  keeper
end

Protected Instance Methods

perform_service_message_validation(serviceMessage) click to toggle source
# File lib/crv_api_client/helpers/crv.rb, line 68
def perform_service_message_validation(serviceMessage)
  case(serviceMessage.serviceStatus.to_i)
    when 1..200
      raise ::CrvApiClient::Errors::CrvRequestError.new(serviceMessage.serviceStatus,
                                serviceMessage.messageText,
                                serviceMessage.messageType)
  end

end

Private Instance Methods

keeper_and_context_message_detail(crv_id,countryCode= nil) click to toggle source
# File lib/crv_api_client/helpers/crv.rb, line 82
def keeper_and_context_message_detail(crv_id,countryCode= nil)
  keeper = get_keeper("#{crv_id}", countryCode)
  contextMessageDetail = endpoint_context_message_detail.new("organisation", get_crv_organisation_code(countryCode))
  [keeper,contextMessageDetail]
end