All files transformer.ts

100% Statements 42/42
100% Branches 38/38
100% Functions 1/1
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96                                                                          2x       39x   39x 39x 39x 39x 39x 39x 39x   39x 39x 39x 39x 39x 39x 39x 39x 39x   39x   273x   39x                                                            
import {
  QuoteV2Item as OriginalQuoteItem,
  QuotePriceType,
  ServiceLevelAgreements,
  QuotePickUpType,
} from '@karhoo/demand-api'
 
export interface QuoteItem {
  currencyCode: string
  eta?: number | null
  etaBreakdown: {
    from?: number | null
    to?: number | null
  }
  finalPrice?: null
  fleetCapabilities: string[]
  fleetId: string
  fleetLogo: string
  fleetName: string
  fleetPhoneNumber: string
  fleetTermsAndConditions: string
  id: string
  quotedPrice: number | null
  pickUpType?: QuotePickUpType
  type: QuotePriceType | ''
  vehicleClass: string
  vehicleTags: string[]
  vehicleType: string
  vehicleList: string[]
  vehicleImage: string
  vehicleLuggageCapacity: number
  vehiclePassengerCapacity: number
  fleetDescription: string
  originalQuote: OriginalQuoteItem
  serviceLevelAgreements?: ServiceLevelAgreements | null
}
 
export const transformer = (quote: OriginalQuoteItem): QuoteItem => {
  const {
    id,
    quote_type,
    price: { currency_code = '', high = null },
    fleet: {
      id: fleet_id,
      name,
      logo_url = '',
      terms_conditions_url = '',
      phone_number = '',
      description = '',
      capabilities = [],
    },
    vehicle: {
      qta: { high_minutes = null, low_minutes = null } = {},
      passenger_capacity = 0,
      luggage_capacity = 0,
      class: vehicle_class = '',
      tags = [],
      type = '',
      vehicle_list = [],
      image = '',
    } = {},
    service_level_agreements = null,
    pick_up_type,
  } = quote
 
  return {
    currencyCode: currency_code,
    eta: high_minutes,
    etaBreakdown: {
      from: low_minutes,
      to: high_minutes,
    },
    finalPrice: null,
    fleetCapabilities: capabilities,
    fleetId: fleet_id,
    fleetLogo: logo_url,
    fleetName: name,
    fleetPhoneNumber: phone_number,
    fleetTermsAndConditions: terms_conditions_url,
    id,
    quotedPrice: high,
    pickUpType: pick_up_type,
    type: quote_type,
    vehicleClass: vehicle_class,
    vehicleTags: tags,
    vehicleType: type,
    vehicleList: vehicle_list,
    vehicleImage: image,
    vehicleLuggageCapacity: luggage_capacity,
    vehiclePassengerCapacity: passenger_capacity,
    fleetDescription: description,
    originalQuote: quote,
    serviceLevelAgreements: service_level_agreements,
  }
}