Sha256: 2a008347f66fddcc4ee066b2a56f9932efe578e4afd2d1e6694f498a42122120

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'mappers/spec_pdf_mapper'
require 'vin_service'

module UVCService
  include SpecPdfMapper
  include VinService
  include HttpRestClient

  VEHICLE_BY_UVC_URL =
    "#{BASE_URL}/UsedCarWS/UsedCarWS/UsedVehicle/UVC".freeze

  PDF_SPEC_BY_UVC_URL =
    "#{BASE_URL}/UsedCarWS/UsedCarWS/PDFSpecs".freeze

  def range_by_uvc(uvc_id, query_params = {})
    url = "#{VEHICLE_BY_UVC_URL}/#{uvc_id}"

    response = make_request(:get, url, query_params)
    return response unless response.last == 200
    [RangeValuesMapper.map_fields(response.first), response.last]
  end

  def spec_pdf_data(uvc, query_params = {})
    url = "#{PDF_SPEC_BY_UVC_URL}/#{uvc}"

    response = make_request(:get, url, query_params)
    return response unless response.last == 200
    [SpecPdfMapper.map_fields(response.first), response.last]
  end

  # This method is used by web-system to generate vehicle spec pdfs for appraisers
  def pdf_data_by_vin(vin, query_params = {})
    response = uvc_by_vin(vin, query_params)
    return response unless response.last == 200
    spec_pdf_data(response.first[:uvc], query_params)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blackbook_client-1.0.1 lib/uvc_service.rb
blackbook_client-1.0.0 lib/uvc_service.rb