class CrvApiClient::Animals

Attributes

endpoint_url[R]
password[R]
username[R]

Public Class Methods

new(endpoint_url= ::CrvApiClient.configuration.endpoint_animals, username: ::CrvApiClient.configuration.username, password: ::CrvApiClient.configuration.password, customer: ::CrvApiClient.configuration.customer, provider: ::CrvApiClient.configuration.provider) click to toggle source
# File lib/crv_api_client/animals.rb, line 12
def initialize(endpoint_url= ::CrvApiClient.configuration.endpoint_animals,
               username: ::CrvApiClient.configuration.username,
               password: ::CrvApiClient.configuration.password,
               customer: ::CrvApiClient.configuration.customer,
               provider: ::CrvApiClient.configuration.provider)

  @endpoint_url = endpoint_url
  @username = username
  @password = password
  self.customer= ::CrvApiClient::Api::Animals::ParticipantId.new(customer[:participant_code], customer[:participant_code_type], customer[:country_code])
  self.provider= ::CrvApiClient::Api::Animals::ParticipantId.new(provider[:participant_code], provider[:participant_code_type], provider[:country_code])
end

Public Instance Methods

list_animals(crv_id, country_code, context_message_detail: nil,process_code: "", options: {}) click to toggle source

Fetches all animals from the crv_api_client database from a specific customer.

notes

Ensure the CRV client is configured properly.

parameters

crv_id the crv_api_client id of the farm. country_code: the country code of the farm. context_message_detail: context message, authentication. process_code: a process code if any

options

a Hash of options.

{validate: false} when set to false, the response wont be validated for status codes.
response

a CrvApiClient::Api::Animals::ListHerdPedigreeResponse will be returned.

usage

response = Class.list_animals(123,“NL”,nil,nil)

# File lib/crv_api_client/animals.rb, line 43
def list_animals(crv_id, country_code, context_message_detail: nil,process_code: "", options: {})

  keeper, context_message_detail = keeper_and_context_message_detail(crv_id,country_code)
  context = context_message(keeper,
                            username: @username,
                            password: @password,
                            context_message_detail: context_message_detail,
                            customer: customer,
                            provider: provider,
                            process_code: process_code,
                            animal: nil,
                            organisation: nil)

  requestType = CrvApiClient::Api::Animals::ListHerdPedigreeRequestType.new
  requestType.keeper = keeper

  request = CrvApiClient::Api::Animals::ListHerdPedigreeRequest.new
  request.contextMessage = context
  request.requestMessage = requestType

  result = driver.listHerdPedigree(request)

  perform_service_message_validation(result.serviceMessage) unless options[:validate] == false

  result
end

Private Instance Methods

driver() click to toggle source
# File lib/crv_api_client/animals.rb, line 73
def driver
    @driver ||= begin
      cert_store = OpenSSL::X509::Store.new
      cert_store.set_default_paths

      animal_soap_driver = CrvApiClient::Api::Animals::RsAnimalPortType.new(@endpoint_url)
      animal_soap_driver.options['protocol.http.connect_timeout'] = CrvApiClient.configuration.http_connect_timeout || 220
      animal_soap_driver.options['protocol.http.receive_timeout'] = CrvApiClient.configuration.http_receive_timeout || 220
      animal_soap_driver.options['protocol.http.ssl_config.cert_store'] = cert_store
      animal_soap_driver.wiredump_file_base = CrvApiClient.configuration.log_file
      animal_soap_driver
    end
end