definitions:

  TaskId:
    description: An id for a task
    required:
      - clientId
      - taskId
    properties:
      clientId:
        type: string
      taskId:
        type: string

  MinimalTask:
    description: A minimal task object
    required:
      - clientId
      - id
      - date
      - teamId
      - status
      - effectiveStatus
      - fleetInfo
      - taskSource
      - version
    properties:
      clientId:
        type: string
        description: Id of the client who added this task
      id:
        type: string
        description: Id of the task
      originalTaskId:
        type: string
        description: Original id of the task
      sourceOrderId:
        description: Order Id for which this task is being generated
        type: string
      scanId:
        description: Client configurable scanId to allow search by scan on app
        type: string
      date:
        description: Execution date of the task in the format YYYY-MM-DD
        type: string
      teamId:
        $ref: '#/definitions/TeamId'
      planId:
        $ref: '#/definitions/PlanId'
      tourId:
        $ref: '#/definitions/TourId'
      shiftId:
        $ref: '#/definitions/ShiftId'
      skills:
        $ref: '#/definitions/Skills'
      status:
        $ref: '#/definitions/MinimalTaskStatus'
      effectiveStatus:
        $ref: '#/definitions/EffectiveTaskStatusEnum'
      statusUpdates:
        $ref: '#/definitions/TaskStatusUpdates'
      homebaseVisit:
        $ref: '#/definitions/MinimalVisit'
      customerVisit:
        $ref: '#/definitions/CustomerVisit'
      fleetInfo:
        $ref: '#/definitions/TaskFleetInfo'
      summary:
        $ref: '#/definitions/MinimalTravelSummary'
      taskSource:
        $ref: '#/definitions/TaskSourceEnum'
      taskMetadata:
        $ref: '#/definitions/MinimalTaskMetadata'
      crossDockMetadata:
        $ref: '#/definitions/CrossDockTaskMetadata'
      crossDockOrderData:
        $ref: '#/definitions/CrossDockOrderData'
      version:
        type: integer
        format: int32
      completedLocation:
        $ref: '#/definitions/MinimalLocation'
      drift:
        type: number
        format: double
      startedLocation:
        $ref: '#/definitions/MinimalLocation'
      reachedLocation:
        $ref: '#/definitions/MinimalLocation'
      cancelledLocation:
        $ref: '#/definitions/MinimalLocation'
      reassigned:
        type: boolean
        default: false
      partiallyDelivered:
        type: boolean
        default: false
      rejected:
        description: Boolean denoting if the task is rejected by a rider at least once
        type: boolean
        default: false
      unassigned:
        description: Boolean denoting if the task is unassigned at least once
        type: boolean
        default: false
      unassignedBy:
        description: Actor who first assigned the task to a rider
        $ref: '#/definitions/Actor'
      customFields:
        description: Key value pair for custom properties that clients may want to maintain
        type: object
        additionalProperties:
          type: string
      tags:
        description: Tags associated with the task
        type: array
        items:
          type: string
      subStatus:
        description: Field denoting substatus of the task
        type: string
      returnTask:
        type: boolean
      initialAssignmentBy:
        description: Actor who first assigned the task to a rider
        $ref: '#/definitions/Actor'
      initialAssignmentAt:
        description: Time when the task was first assigned
        type: string
        format: date-time
      sequenceInBatch:
        type: integer
        format: int32
      eventBasedChecklists:
        $ref: '#/definitions/MinimalEventBasedChecklists'
      compartmentId:
        type: string
      category:
        type: string
      podVerificationMetadata:
        $ref: '#/definitions/PodVerificationMetadata'
      taskTimeSlotAsString:
        type: string
        description: task time slot captured in string range format
      quantity:
        $ref: '#/definitions/Quantity'
      customerPromisedDate:
        type: string

  Quantity:
    required:
      - value
      - unit
    properties:
      value:
        description: Total Quantity of the items in the task.
        type: integer
        format: int32
      unit:
        type: string

  PodVerificationMetadata:
    description: Information related to pod authentication
    properties:
      isProcessed:
        type: boolean
        default: false
        description: Boolean to denote whether PODA api was called for this task or not
      isTaskVerified:
        type: boolean
        default: false
        description: Boolean to denote whether PODs followed the stated rules in rule-engine or not
      customerArrivedVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      customerStartedVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      customerTransactingVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      customerCompletionVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      customerCancellationVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      homebaseArrivedVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      homebaseStartedVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      homebaseTransactingVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      homebaseCompletionVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'
      homebaseCancellationVerificationStatus:
        $ref: '#/definitions/PodVerificationStatusEnum'

  PodVerificationResult:
    properties:
      isProcessed:
        type: boolean
        default: false
        description: Boolean to denote whether PODA api was called for this visit or not
      isVerified:
        type: boolean
        default: false
        description: Boolean to denote whether PODA api validated the defined rules in rule engine or not
      podConfigurationName:
        type: string
        description: Name of the configuration used to verify PODA
      ruleWiseResults:
        type: array
        items:
          $ref: '#/definitions/RuleResult'

  RuleResult:
    properties:
      ruleId:
        type: string
      ruleCategory:
        $ref: '#/definitions/RuleCategory'
      ruleType:
        $ref: '#/definitions/RuleType'
      result:
        $ref: '#/definitions/RuleResultStatus'

  RuleResultStatus:
    type: string
    enum:
      - PASSED
      - FAILED
      - NOT_APPLICABLE
      - IN_PROGRESS

  RuleCategory:
    type: string
    enum:
      - TEXT_VERIFICATION
      - ADDRESS_VERIFICATION
      - OBJECT_DETECTION
      - OBJECT_COUNT
      - OBJECT_MATCHING
      - LOGO_VERIFICATION
      - STAMP_VERIFICATION
      - DOCUMENT_VERIFICATION
      - OBSCENITY_CHECK
      - BLURRINESS_CHECK

  RuleType:
    type: string
    enum:
      - BOX_PRESENT
      - BLURRINESS
      - TEXT_SEARCH
      - ORDER_ID
      - ALTERNATIVE_ID
      - SCAN_ID
      - AMOUNT
      - CUSTOMER_NAME
      - SHIPMENT_ID
      - RIDER_ID
      - VEHICLE_ID
      - HOMEBASE_ADDRESS
      - CUSTOMER_ADDRESS
      - BOX
      - PARCEL
      - PACKAGE
      - SIGNATURE
      - DOCUMENT
      - INVOICE
      - SKU_QTY
      - SKU_IMAGE
      - LOGO_IMAGE
      - STAMP_IMAGE
      - DOCUMENT_IMAGE
      - OBSCENE
      - BLURRY

  MinimalTaskStatus:
    allOf:
    - $ref: '#/definitions/MinimalStatusUpdate'
    - type: object
      properties:
        status:
          $ref: '#/definitions/TaskStatusEnum'
  
  MinimalStatusUpdate:
    required:
      - triggerTime
    properties:
      triggerTime:
        description: Time when the task update was triggered on the client side
        type: string
        format: date-time
      actor:
        $ref: '#/definitions/Actor'
      actorType:
        $ref: '#/definitions/ActorTypeEnum'

  ActorTypeEnum:
    type: string
    enum:
      - LOCUS
      - PERSONNEL
      - RIDER
      - CLIENT
      - ClIENT

  TaskType:
    description: Enum to denote type of the task
    type: string
    enum:
      - PICKUP
      - DROP

  TaskStatusEnum:
    type: string
    enum:
      - RECEIVED
      - WAITING
      - ACCEPTED
      - STARTED
      - COMPLETED
      - CANCELLED
      - ERROR

  EffectiveTaskStatusEnum:
    type: string
    enum:
      - WAITING
      - ONGOING
      - COMPLETED
      - CANCELLED

  TaskStatusUpdates:
    properties:
      received:
        $ref: '#/definitions/MinimalTaskStatus'
      waiting:
        $ref: '#/definitions/MinimalTaskStatus'
      accepted:
        $ref: '#/definitions/MinimalTaskStatus'
      started:
        $ref: '#/definitions/MinimalTaskStatus'
      completed:
        $ref: '#/definitions/MinimalTaskStatus'
      cancelled:
        $ref: '#/definitions/MinimalTaskStatus'

  MinimalVisit:
    description: A location, or a visit or a stop in the delivery person's tour
    required:
      - id
      - type
      - status
      - effectiveStatus
      - transactionInfo
    properties:
      id:
        type: string
      type:
        $ref: '#/definitions/ExtendedVisitTypeEnum'
      trackLinkId:
        type: string
      trackLink:
        type: string
        description: Url for the live view of the trip
      status:
        $ref: '#/definitions/MinimalVisitStatus'
      effectiveStatus:
        $ref: '#/definitions/EffectiveVisitStatusEnum'
      statusUpdates:
        $ref: '#/definitions/VisitStatusUpdates'
      etas:
        $ref: '#/definitions/VisitEtas'
      locationId:
        $ref: '#/definitions/LocationId'
      location:
        type: object
      routeId:
        $ref: '#/definitions/MapRouteId'
      chosenLocation:
        $ref: '#/definitions/MinimalVisitLocation'
      orderDetail:
        $ref: '#/definitions/OrderDetail'
      transactionInfo:
        $ref: '#/definitions/VisitTransactionInfo'
      checklists:
        $ref: '#/definitions/MinimalVisitChecklists'
      resources:
        $ref: '#/definitions/VisitResources'
      geofenceSummary:
        $ref: '#/definitions/GeofenceSummary'
      summary:
        $ref: '#/definitions/MinimalVisitSummary'
      eventBasedChecklists:
        $ref: '#/definitions/MinimalEventBasedChecklists'
      minimalPayments:
        $ref: '#/definitions/MinimalPayments'
      paymentCollectionStatus:
        $ref: '#/definitions/PaymentCollectionStatus'
      mergeId:
        description: Visits sharing a non-null mergeId are executed as one merged visit
        type: string


  MinimalVisitStatus:
    allOf:
    - $ref: '#/definitions/MinimalStatusUpdate'
    - type: object
      properties:
        status:
          $ref: '#/definitions/VisitStatusEnum'

  VisitStatusEnum:
    description: Actual status. ACCEPTED - delivery person has accepted the task. STARTED - delivery person is moving towards the location. ARRIVED - delivery person has reached the location, and just waiting there. TRANSACTING - delivery person is at the location, and the transaction is in progress. COMPLETED - delivery person has completed the transaction at the location.
    type: string
    enum:
      - RECEIVED
      - WAITING
      - ACCEPTED
      - STARTED
      - ARRIVED
      - TRANSACTING
      - COMPLETED
      - CANCELLED

  ExtendedVisitTypeEnum:
    type: string
    enum:
      - SERVICE
      - PICKUP
      - DROP
      - USER
      - HOMEBASE

  EffectiveVisitStatusEnum:
    type: string
    enum:
      - WAITING
      - QUEUED
      - TRAVELLING
      - TRANSACTING
      - COMPLETED
      - CANCELLED

  PodVerificationStatusEnum:
    type: string
    enum:
      - PASSED
      - FAILED
      - PARTIALLY_VERIFIED

  VisitStatusUpdates:
    properties:
      started:
        $ref: '#/definitions/MinimalVisitStatus'
      arrived:
        $ref: '#/definitions/MinimalVisitStatus'
      transacting:
        $ref: '#/definitions/MinimalVisitStatus'
      completed:
        $ref: '#/definitions/MinimalVisitStatus'
      cancelled:
        $ref: '#/definitions/MinimalVisitStatus'
      transactionEnd:
        $ref: '#/definitions/MinimalStatusUpdate'

  VisitEtas:
    properties:
      started:
        $ref: '#/definitions/VisitEta'
      arrived:
        $ref: '#/definitions/VisitEta'
      transacting:
        $ref: '#/definitions/VisitEta'
      completed:
        $ref: '#/definitions/VisitEta'

  VisitEta:
    properties:
      initial:
        type: string
        format: date-time
      current:
        type: string
        format: date-time

  MinimalVisitLocation:
    description: Location and time related information for a visit
    properties:
      id:
        description: An optional id for the location. This will be used to identify same locations, which can help in improving the fleet plan optimization.
        type: string
      latLng:
        $ref: '#/definitions/LatLng'
      locationAddress:
        $ref: '#/definitions/StructuredAddress'
      contact:
        $ref: '#/definitions/ContactPoint'
      geocodingMetadata:
        $ref: '#/definitions/GeocodingMetadata'

  HomebaseVisitDetails:
    properties:
      homebaseId:
        type: string
      transactionDuration:
        description: Duration required for transaction at the location, in seconds.
        type: integer
        format: int32

  VisitDetails:
    properties:
      transactionDuration:
        description: Duration required for transaction at the location, in seconds.
        type: integer
        format: int32
      sla:
        description: SLA for task in seconds 
        type: integer
        format: int32

  VisitTransactionInfo:
    properties:
      slot:
        $ref: '#/definitions/VisitSlot'
      transactionDuration:
        description: Duration required for transaction at the location, in seconds.
        type: integer
        format: int32
      amountTransaction:
        $ref: '#/definitions/AmountTransaction'
      amountToBeCollected:
        type: number
        format: double
      amountToBeGiven:
        type: number
        format: double
      actualAmountCollected:
        type: number
        format: double
      actualAmountGiven:
        type: number
        format: double
      originalAmountToBeCollected:
        type: number
        format: double
      netAmount:
        type: number
        format: double
      grossAmount:
        type: number
        format: double

  VisitSlot:
    properties:
      current:
        $ref: '#/definitions/TimeSlot'
      initial:
        $ref: '#/definitions/TimeSlot'

  AmountTransaction:
    description: Transaction of an amount.
    properties:
      refId:
        description: id of amount transaction
        type: string
      amount:
        description: Amount that needs to be transacted
        $ref: '#/definitions/Amount'
      exchangeType:
        $ref: '#/definitions/ExchangeTypeEnum'

  ExchangeTypeEnum:
    type: string
    enum:
      - COLLECT
      - GIVE
      - NONE

  OrderDetail:
    description: Details about the order, line items, amount etc
    properties:
      lineItems:
        type: array
        items:
          $ref: '#/definitions/LineItem'
      transactionDetail:
        $ref: '#/definitions/OrderTransactionDetail'
      taskTransactionDetail:
        $ref: '#/definitions/TransactionDetail'
      assets:
        type: array
        items:
          $ref: '#/definitions/AssetInfo'
      cratingInfo:
        $ref: '#/definitions/CratingInfo'
      summary:
        $ref: '#/definitions/OrderSummary'
      linetItemTransactionUpdateCounter:
        description: Number of times line item transaction was updated
        type: integer
        format: int32
        default: 0
      orderAttemptId:
        type: string
      transactionId:
        type: integer
        format: int32

  LineItem:
    description: A single item contained in the order
    required:
      - name
      - quantity
    properties:
      name:
        type: string
        description: Name of the item
      description:
        description: Description of the item
        type: string
      quantity:
        type: integer
        format: int32
        description: Quantity of the item
        default: 1
      quantityUnit:
        type: string
        default: PC
      id:
        type: string
        description: An identifier for the line item
      version:
        type: integer
        format: int32
        description: Version of Line Item
      price:
        $ref: '#/definitions/Amount'
        description: Price of the item
      imageUrl:
        type: string
        description: A url for an image of the item
      transactionStatus:
        $ref: '#/definitions/TransactionStatus'
      packageInfo:
        $ref: '#/definitions/ItemPackagingInfo'
      parts:
        type: array
        items:
          $ref: '#/definitions/LineItemPart'
      scanId:
        type: string
        description: Scan Id of the line item
      customProperties:
        description: A map containing Customised Properties in Line Item.
        type: object
        additionalProperties:
          type: string
      handlingUnit:
        $ref: '#/definitions/HandlingUnitEnum'
        default: QUANTITY
      totalWeight:
        description: Total weight of the lineItem
        $ref: '#/definitions/Weight'
      totalVolume:
        description: Total volume of the lineItem
        $ref: '#/definitions/ItemVolume'
      handlingUnits:
        type: array
        items:
          $ref: '#/definitions/HandlingUnitEnum'
      lineItemId:
        type: string
        description: Id of the line item
      skuId:
        type: string
        description: sku Id of the line item
      batchId:
        type: string
        description: batch Id of the line item
      tags:
        description: Tags of the line item
        type: array
        items:
          type: string
      skills:
        description: Line item skills
        type: array
        items:
          type: string
      category:
        description: An user provided category for line item
        type: string
      imageUrls:
        description: Image urls of the line item with a maximum of 5 counts
        type: array
        items:
          type: string
      unitsOfTransactions:
        type: array
        items:
          description: Transaction unit containing type at which transaction will be applied
          $ref: '#/definitions/UnitsOfTransaction'
      attributesUnit:
        $ref: '#/definitions/ItemAttributesUnit'
      attributes:
        $ref: '#/definitions/ItemAttributes'
      boxesInfo:
        $ref: '#/definitions/BoxesInfo'
      canRiderEdit:
        description: flag to denote whether the rider is allowed to edit the line item
        type: boolean
        default: true
  
  HandlingUnitEnum:
    description: delivery handling units to identify deliverable field
    type: string
    enum:
      - QUANTITY
      - WEIGHT
      - VOLUME

  OrderTransactionDetail:
    required:
      - canTransactPartial
      - checklist
    properties:
      canTransactPartial:
        description: A flag to denote whether order can be transacted partially or not
        type: boolean
        default: false
      checklist:
        $ref: '#/definitions/Checklist'
      transactionDuration:
        description: Duration required for transacting all line items for that Order
        type: integer
        default: 0
        format: int32
      frozen:
        description: Boolean denoting if lineItem quantity update is frozen
        type: boolean
        default: false

  ItemPackagingInfo:
    description: Item packaging information
    required:
      - isCrated
      - cartons
      - pieces
    properties:
      isCrated:
        type: boolean
        description: indicates if the item is crated
        default: false
      cartons:
        type: integer
        format: int32
        description: number of cartons of the item
        default: 0
      pieces:
        type: integer
        format: int32
        description: number of pieces of the item that is crated or remaining items
        default: 0

  CratingInfo:
    description: crating info
    required:
      - crates
    properties:
      crates:
        type: integer
        format: int32
        description: number of crates
        default: 0
      crateDetails:
        type: array
        items:
          $ref: '#/definitions/Crate'
      looseItems:
        type: array
        items:
          $ref: '#/definitions/BaseLineItem'

  CratingInfoRequest:
    description: crating info
    properties:
      crateDetails:
        type: array
        items:
          $ref: '#/definitions/CrateRequest'
      looseItems:
        type: array
        items:
          $ref: '#/definitions/BaseLineItem'

  CrateRequest:
    properties:
      id:
        type: string
      modelId:
        type: string
      items:
        type: array
        items:
          $ref: '#/definitions/BaseLineItem'

  Crate:
    allOf:
    - $ref: '#/definitions/CrateRequest'
    - type: object
      properties:
        type:
          type: string
        subType:
          type: string
        typeColor:
          type: string
        subTypeColor:
          type: string

  BaseLineItem:
    properties:
      id:
        type: string
        description: An identifier for the line item
      quantity:
        type: integer
        format: int32
        description: quantity of the item
        default: 1
      weight:
        $ref: '#/definitions/Weight'

  OrderSummary:
    description: order summary for the order detail
    required:
      - deliveredCount
    properties:
      deliveredCount:
        type: integer
        format: int32
        description: number of line items delivered
        default: 0
      itemsDeliveredQuantity:
        type: integer
        format: int32
        description: Total number of items delivered across line items
        default: 0
      transactionStatus:
        enum: [ALL, PARTIAL, NONE]
        type: string
        description: Transaction Status of the line items. Were all/none/partial of them delivered? Only comes into picture for terminal visits
        default: NONE

  TransactionStatus:
    required:
      - triggerTime
      - receiveTime
      - transactedQuantity
      - checklistValues
    properties:
      transactedQuantity:
        description: Quantity of the item that has been transacted
        type: integer
        format: int32
      checklistValues:
        description: A map containing selected values for each checklist item.
        type: object
        additionalProperties:
          type: string
      triggerTime:
        description: Time when the transaction status update was triggered on the client side
        type: string
        format: date-time
      receiveTime:
        description: Time when the transaction status update was received on Locus server
        type: string
        format: date-time
      actor:
        description: Actor who triggered this status update
        $ref: '#/definitions/Actor'
      status:
        $ref: '#/definitions/OrderDetailStatusEnum'
      transactedWeight:
        description: Weight of the item that has been transacted in grams
        type: number
        format: double
      actualTransactedVolume:
        description: volume of the line item that has been transacted in same unit as line item
        type: number
        format: double
      actualTransactedWeight:
        description: weight of the line item that has been transacted in same unit as line item
        type: number
        format: double

  OrderDetailStatusEnum:
    type: string
    enum:
      - DELIVERED
      - NOT_DELIVERED
      - PARTIALLY_DELIVERED

  MinimalVisitChecklists:
    properties:
      completed:
        $ref: '#/definitions/MinimalVisitChecklist'
      cancelled:
        $ref: '#/definitions/MinimalVisitChecklist'
      started:
        $ref: '#/definitions/MinimalVisitChecklist'
      arrived:
        $ref: '#/definitions/MinimalVisitChecklist'
      transacting:
        $ref: '#/definitions/MinimalVisitChecklist'

  MinimalVisitChecklist:
    properties:
      status:
        type: string
      items:
        type: array
        items:
          $ref: '#/definitions/ChecklistValue'

  ChecklistValue:
    properties:
      id:
        description: id of the checklist
        type: string
      parentChecklistId:
        description: parent checklist Id of the checklist
        type: string
      name:
        description: name of the checklist item
        type: string
      selectedValue:
        description: value chosen for the checklist item
        type: string
      selectedValues:
        description: values chosen for the checklist item in the case of MULTI_CHOICE type checklist
        type: array
        items:
          type: string
      type:
        description: type of the checklist item
        type: string
        enum: [BOOLEAN, SINGLE_CHOICE, TEXT_FIELD, PIN, SIGNATURE, PHOTO, RATING, URL, URL_WITH_FEEDBACK, DATE, TIME, DATETIME, PHOTO_GALLERY, MULTI_CHOICE, MULTI_PHOTO]
      podVerificationResult:
        description: Pod authentication results with checklist item id and result
        $ref: '#/definitions/PodVerificationResult'

  VisitResources:
    description: A list of resource exchanges
    required:
      - resources
    properties:
      volume:
        $ref: '#/definitions/VisitVolume'
      weight:
        $ref: '#/definitions/Resource'
      resources:
        description: List of generic resource exchanges
        type: array
        items:
          $ref: '#/definitions/Resource'

  VisitVolume:
    description: Volume of a visit
    properties:
      value:
        description: Value of the volume in the given unit.
        type: number
        format: double
      exchangeType:
        $ref: '#/definitions/ResourceExchangeType'

  MinimalVisitSummary:
    allOf:
    - $ref: '#/definitions/MinimalTravelSummary'
    - type: object
      properties:
        amountCollected:
          $ref: '#/definitions/Amount'
        effectiveTat:
          type: integer
          format: int32
        drifts:
          $ref: '#/definitions/VisitDrifts'
        driftsSummary:
          $ref: '#/definitions/VisitDriftsSummary'
        parkingDuration:
          description: Time spent in seconds from arrival to start transacting
          type: integer
          format: int32
        waitingDuration:
          description: Time spent in seconds after transaction to completion of visit
          type: integer
          format: int32
        actualDwellTime:
          description: Time spent in seconds after arrived to completion of visit
          type: integer
          format: int32
        allowedDwellTime:
          description: Time allowed to be spent in seconds after arrived to completion of visit
          type: integer
          format: int32
        detentionTime:
          description: Delta between actualDwellTime and allowedDwellTime
          type: integer
          format: int32
        detentionCharges:
          description: Charges due to detentionTime
          type: integer
          format: int32

  MinimalTravelSummary:
    properties:
      slaStatus:
        $ref: '#/definitions/SlaStatusEnum'
      tardiness:
        description: Amount of time (in seconds)by which SLA has been breached.
        type: integer
        format: int32
      earliness:
        description: Amount of time (in seconds) by which Arrival is earlier than the start of slot.
        type: integer
        format: int32

  MinimalEventBasedChecklists:
    properties:
      delayedReasonChecklist:
        $ref: '#/definitions/MinimalVisitChecklist'
      rescheduleEventChecklist:
        $ref: '#/definitions/MinimalVisitChecklist'
      rejectEventChecklist:
        $ref: '#/definitions/MinimalVisitChecklist'
      noPaymentCollectionChecklist:
        $ref: '#/definitions/MinimalVisitChecklist'
      partialPaymentCollectionChecklist:
        $ref: '#/definitions/MinimalVisitChecklist'
      fullPaymentCollectionChecklist:
        $ref: '#/definitions/MinimalVisitChecklist'

  GeofenceSummary:
    description: Geofence summary for a visit
    properties:
      entryTime:
        description: The time when first geofence entry occured
        type: string
        format: date-time
      exitTime:
        description: The time when last geofence exit occured
        type: string
        format: date-time

  SlaStatusEnum:
    description : SLA status of the order
    type: string
    enum:
      - ON_TIME
      - LATE
      - NOT_APPLICABLE
      - EARLY

  VisitDrifts:
    properties:
      arrived:
        type: number
        format: double
      completed:
        type: number
        format: double
      cancelled:
        type: number
        format: double

  VisitDriftsSummary:
    properties:
      completedDriftBreachingThreshold:
        type: boolean

  CustomerVisit:
    allOf:
    - $ref: '#/definitions/MinimalVisit'
    - type: object
      properties:
        appFields:
          $ref: '#/definitions/AppFields'
        customerChecklists:
          $ref: '#/definitions/MinimalVisitChecklists'
        customerNotes:
          type: array
          items:
            type: string
        callSummary:
          $ref: '#/definitions/CallSummary'
        minimalPayments:
          $ref: '#/definitions/MinimalPayments'

  AppFields:
    description: Container for values that are required specifically for rendering on the FE app.
    properties:
      items:
        type: array
        items:
          $ref: '#/definitions/AppFieldItem'

  AppFieldItem:
    required:
      - item
      - format
    properties:
      item:
        description: String representation of the item, to be displayed on the app
        type: string
      format:
        description: |

          Format for the item.
          URL - Url that can be opened as web view on app

          TEXT - Static text that can be displayed on the app (e.g. any custom notes)

        type: string
        enum: [ URL , TEXT]
      additionalValues:
        description: Extra properties required depending on the type. For URL, a key "url" should be provided with the url to open. For TEXT, a key "text" should be provided with actuall text that needs to be displayed.
        type: object
        additionalProperties:
          type: string

  CallSummary:
    description: Call summary of this visit
    properties:
      firstCallAttemptAt:
        type: string
        format: date-time
      lastCallAttemptAt:
        type: string
        format: date-time
      totalAttempts:
        type: integer
        format: int32

  TaskFleetInfo:
    properties:
      primaryFleet:
        $ref: '#/definitions/PrimaryFleetEnum'
      riderId:
        $ref: '#/definitions/RiderId'
      rider:
        description: Read-only field. Refer to Rider Apis
        type: object
      vehicleModelId:
        $ref: '#/definitions/VehicleModelId'
      vehicleModel:
        description: Read-only field. Refer to Vehicle Model Apis
        type: object
      vehicleId:
        $ref: '#/definitions/VehicleId'
      vehicle:
        description: Read-only field. Refer to Vehicle Apis
        type: object
      firstAssignedRiderId:
        $ref: '#/definitions/RiderId'
      firstAssignedRider:
        description: Read-only field. Refer to Rider Apis
        type: object
      transporterId:
        $ref: '#/definitions/TransporterId'
      transporter:
        description: Read-only field. Refer to Transporter Apis
        type: object
      vehicleTransporterId:
        $ref: '#/definitions/TransporterId'
      vehicleTransporter:
        description: Read-only field. Refer to Transporter Apis
        type: object

  TaskSourceEnum:
    description: Enum to denote whether the task is ondemand or scheduled
    type: string
    enum:
      - ONDEMAND
      - SCHEDULED
      - SERVICEABILITY

  MinimalTaskMetadata:
    properties:
      taskPriority:
        description: Priority of task.
        type: number
        format: double
      autoAssign:
        description: Flag to denote if task been automatically assigned
        type: boolean
      crossDockMetadata:
        $ref: '#/definitions/CrossDockTaskMetadata'

  CrossDockTaskMetadata:
    description: It will contain crossdock information related to tasks
    properties:
      parentOrderId:
        description: The taskId submitted by client which would be split into multiple
        type: string
      nextLegTaskId:
        $ref: '#/definitions/TaskId'
      previousLegTaskId:
        $ref: '#/definitions/TaskId'
      isLastLeg:
        description: Indicates whether if it's the last leg of the parent order
        type: boolean
        default: true
      taskLeg:
        description: Which leg does this belong to
        type: integer
        format: int32
        default: 1
      usecase:
        $ref: '#/definitions/CrossDockType'
      crossDockId:
        $ref: '#/definitions/HomebaseId'
      totalLegs:
        description: Number of legs in the parent order
        type: integer
        format: int32
        default: 1

  TaskCount:
    required:
      - status
      - count
    properties:
      status:
        type: string
      count:
        type: integer
        format: int32

  ExtendedTask:
    allOf:
    - $ref: '#/definitions/MinimalTask'
    - type: object
      properties:
        plannedTourName:
          type: string
        taskSummary:
          $ref: '#/definitions/ExtendedTaskSummary'
        returnVisitChecklist:
          type: array
          items:
            $ref: '#/definitions/ChecklistValue'
        tourUpdatedOn:
          type: string
          format: date-time
        etaUpdatedOn:
          type: string
          format: date-time

  ExtendedTaskSummary:
    required:
      - plannedDistance
      - travelledDistance
      - plannedTime
      - travelledTime
    properties:
      plannedDistance:
        type: integer
        format: int32
      travelledDistance:
        type: integer
        format: int32
      plannedTime:
        type: integer
        format: int32
      travelledTime:
        type: integer
        format: int32

  GetExtendedTasksResponse:
    properties:
      tasks:
        type: array
        items:
          $ref: '#/definitions/ExtendedTask'
      counts:
        type: array
        items:
          $ref: '#/definitions/TaskCount'
      paginationInfo:
        $ref: '#/definitions/PaginationInfo'

  GetMinimalTasksResponse:
    properties:
      tasks:
        type: array
        items:
          $ref: '#/definitions/MinimalTask'
      counts:
        type: array
        items:
          $ref: '#/definitions/TaskCount'
      paginationInfo:
        $ref: '#/definitions/PaginationInfo'

  ContactPoint:
    description: Contact point at a visit location.
    properties:
      name:
        description: Name of contact
        type: string
      number:
        description: Number for contact person
        type: string
      email:
        description: Email id of contact
        type: string

  Checklist:
    description: A list of checklist items
    required:
      - status
      - items
    properties:
      status:
        description: Status to which this checklist needs to apply
        type: string
      items:
        type: array
        items:
          $ref: '#/definitions/ChecklistItem'

  ChecklistItem:
    required:
      - key
      - item
      - format
      - possibleValues
      - optional
    properties:
      key:
        description: An identifier for this checklist item
        type: string
      item:
        description: String representation of the checklist item, to be displayed on the app
        type: string
      format:
        description: |

          Input format for the checklist item. Can be BOOLEAN, SINGLE_CHOICE, PIN, SIGNATURE, or PHOTO.

          BOOLEAN field will be displayed as a checkbox, which delivery person can either check or uncheck.

          SINGLE_CHOICE will be displayed as a group of radio buttons from which delivery person can choose one.

          TEXT_FIELD will be displayed as a free form text box.

          PIN will be a code sent to customer which will need to be entered into the app.

          SIGNATURE will let the delivery person collect a signature from customer.

          PHOTO will let delivery person click a picture of the item.

          RATING will be displayed as stars for taking feedback.

          URL will be displayed as a clickable url
          
          URL_WITH_FEEDBACK will be displayed as a clickable url with feedback

          DATE will be displayed as a date entry box

          TIME will be displayed a time selection field

          DATETIME will be displayed as a calendar entry box with time

          PHOTO_GALLERY will let rider upload photo from phone gallery

          MULTI_CHOICE will let rider select multiple items from give options

          MULTI_PHOTO will let rider click multiple photos

        type: string
        enum: [BOOLEAN, SINGLE_CHOICE, TEXT_FIELD, PIN, SIGNATURE, PHOTO, RATING, URL, URL_WITH_FEEDBACK, DATE, TIME, DATETIME, PHOTO_GALLERY, MULTI_CHOICE, MULTI_PHOTO]
      possibleValues:
        description: Possible values for the item, depending on the format field. For a SINGLE_CHOICE, values will be strings to display. For PIN, it should be the actual code. For URL, it should be the URL to display and link to. For BOOLEAN, TEXT_FIELD, SIGNATURE and PHOTO, value isn't required.
        type: array
        items:
          type: string
      allowedValues:
        type: array
        items:
          $ref: '#/definitions/ChecklistPossibleValue'
      optional:
        type: boolean
        default: false
      lineItemLevel:
        type: boolean
        default: false
      additionalOptions:
        description: |

          Any additional options to customize the behavior of the checklist item.
          For TEXT_FIELD, the key "inputType" can have values "DEFAULT", "PHONE", "NUMBER", "DECIMAL", "EMAIL_ADDRESS" or "PASSWORD" that determines the type of keyboard that appears.
          The key "regex" can be given a regular expression as the value that will be used to validate the TEXT_FIELD contents.
          The key "errorMessage" sets a custom error message if the text does not conform to the given regex.

        type: object
        additionalProperties:
          type: string

  ChecklistPossibleValue:
    required:
      - key
      - value
    properties:
      key:
        description: identifier of checklist item value
        type: string
      value:
        type: string

  MinimalLocation:
    description: A location, usually measured via some sensor - GPS, wifi, cell network etc
    required:
      - lat
      - lng
    properties:
      lat:
        type: number
        format: double
      lng:
        type: number
        format: double
      accuracy:
        type: number
        format: double
        description: For a measured location, the accuracy of the measurement, defined as the radius of circle of 68% confidence, in meters.
      timestamp:
        type: integer
        format: int64
        description: timestamp of when this location fix was obtained, in millis since epoch
      distance:
        type: integer
        format: int32
        description: Distance that user has travelled so far in reaching this location, within current trip
      speed:
        type: number
        format: float
        description: Measured speed at the location, in meters per second

  VisitId:
    description: An id for a visit
    required:
      - clientId
      - taskId
      - visitId
    properties:
      clientId:
        type: string
      taskId:
        type: string
      visitId:
        type: string

  CrossDockOrderData:
    description: Read-only field for parent order data
    properties:
      status:
        $ref: '#/definitions/CrossDockOrderStatus'
      totalLegs:
        type: integer
        format: int32

  CrossDockOrderStatus:
    allOf:
    - $ref: '#/definitions/MinimalStatusUpdate'
    - type: object
      properties:
        status:
          $ref: '#/definitions/CrossDockOrderStatusEnum'

  CrossDockOrderStatusEnum:
    type: string
    enum:
      - RECEIVED
      - STARTED
      - COMPLETED
      - CANCELLED
      - ERROR

  TaskChecklistRequest:
    description: Request for checklists of tasks
    required:
      - status
    properties:
      status:
        $ref: '#/definitions/TaskStatusEnum'
      taskIds:
        type: array
        items:
          $ref: '#/definitions/TaskId'
      tourIds:
        type: array
        items:
          $ref: '#/definitions/TourId'

  BulkTaskStatusUpdateRequest:
    description: Request for bulk task update
    required:
      - status
    properties:
      status:
        $ref: '#/definitions/TaskStatusEnum'
      taskIds:
        type: array
        items:
          $ref: '#/definitions/TaskId'
      tourIds:
        type: array
        items:
          $ref: '#/definitions/TourId'
      checklistValues:
        description: A map containing selected values for each checklist item.
        type: object
        additionalProperties:
          type: string

  MinimalPayments:
    required:
      - payments
    properties:
      pendingAmount:
        description: Remaining amount that has to be paid
        $ref: '#/definitions/Amount'
      payments:
        description: All payments associated with this. Can be in any status - successful, failed, pending etc.
        type: array
        items:
          $ref: '#/definitions/MinimalPayment'

  MinimalPayment:
    required:
      - actualAmount
      - status
      - additionalInfo
    properties:
      actualAmount:
        $ref: '#/definitions/Amount'
        description: Amount that was actually charged.
      status:
        $ref: '#/definitions/PaymentStatus'
      additionalInfo:
        description: Additional information that needs to be shared for the payment
        type: object
        additionalProperties:
          type: string
      instrument:
        $ref: '#/definitions/PaymentInstrument'

  PaymentStatus:
    description: Status of the payment
    type: string
    enum:
      - PENDING
      - SUCCESS
      - FAILED
      - CANCELLED

  PaymentInstrument:
    description: A method of payment
    required:
      - instrumentType
      - instrumentName
    properties:
      instrumentType:
        $ref: '#/definitions/PaymentInstrumentType'
      instrumentName:
        description: A human friendly name for the payment instrument
        type: string
      providerInstrumentId:
        $ref: '#/definitions/ProviderInstrumentId'
        description: Might not be applicable for all instrument types.

  ProviderInstrumentId:
    description: Id of the payment instrument as identified by a provider
    required:
      - providerId
      - instrumentId
    properties:
      providerId:
        description: Id of payment instrument provider. For eg, razor-pay for RazorPay instruments. This should be one of the supported values.
        type: string
      instrumentId:
        description: Id of the payment instrument as identified by the provider.
        type: string

  PaymentInstrumentType:
    description: Denotes the type of payment instrument
    type: string
    enum:
      - CASH
      - COUPON
      - ECOD
      - ONLINE

  PaymentCollectionStatus:
    description: Status of payment collection
    type: string
    enum:
      - PRE_PAID
      - PENDING
      - PARTIALLY_PAID
      - FULLY_PAID
      - UNPAID

  BoxesInfo:
    description: Details about the boxes
    properties:
      attributes:
        $ref: '#/definitions/ItemAttributes'

  TeamId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/TeamId'

  PlanId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/PlanId'

  TourId:
    $ref: 'https://swagger.locus-api.com/tour.yaml#/definitions/TourId'

  ShiftId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/ShiftId'

  Skills:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/Skills'

  Actor:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/Actor'

  LocationId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/LocationId'

  MapRouteId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/MapRouteId'

  LatLng:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/LatLng'

  StructuredAddress:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/StructuredAddress'

  CustomerId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/CustomerId'

  AddressId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/AddressId'

  TimeSlot:
    $ref: 'https://swagger.locus-api.com/slots.yaml#/definitions/TimeSlot'

  Amount:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/Amount'

  Resource:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/Resource'

  ResourceDefinition:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/ResourceDefinition'

  ResourceExchangeType:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/ResourceExchangeType'

  VehicleId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/VehicleId'

  VehicleModelId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/VehicleModelId'

  TransporterId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/TransporterId'

  RiderId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/RiderId'

  PaginationInfo:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/PaginationInfo'

  LineItemPart:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/LineItemPart'

  Weight:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/Weight'

  WeightUnit:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/WeightUnit'

  PrimaryFleetEnum:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/PrimaryFleetEnum'

  GeocodingMetadata:
    $ref: 'https://swagger.locus-api.com/geocoding.yaml#/definitions/GeocodingMetadata'

  CrossDockType:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/CrossDockType'

  HomebaseId:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/HomebaseId'

  ItemVolume:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/ItemVolume'

  ItemVolumeUnit:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/ItemVolumeUnit'

  UnitsOfTransaction:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/UnitsOfTransaction'

  ItemAttributesUnit:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/ItemAttributesUnit'

  ItemAttributes:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/ItemAttributes'

  BaseItemAttributes:
    $ref: 'https://swagger.locus-api.com/common-entities.yaml#/definitions/BaseItemAttributes'

  TransactionDetail:
    $ref: 'https://swagger.locus-api.com/oms.yaml#/definitions/TransactionDetail'

  AssetInfo:
    $ref: 'https://swagger.locus-api.com/oms.yaml#/definitions/AssetInfo'
