Autofleet / locomotion

An open-source rider/passenger mobile app written in React Native and Node.js that can be customized and modified to support any ride-hailing
MIT License
32 stars 13 forks source link

Can't create ride offer #829

Closed otaviolbarbosa closed 1 month ago

otaviolbarbosa commented 2 months ago

Hi,

I'm trying to create a ride offer using api, but I'm always getting state as "offer-rejected" as you can see on image. Any ideas on how to fix it?

image

AlonAF800 commented 2 months ago

looking at the screen shot i see you sent a lat/lng near Israel

Screenshot 2024-07-10 at 12 20 02

https://www.google.com/maps/place/31%C2%B000'00.0%22N+34%C2%B000'00.0%22E/@30.8689605,32.632704,7.31z/data=!4m4!3m3!8m2!3d31!4d34?entry=ttu

in order for the offer to be created and accepted, you need to have an active driver in environment and the given radius.

otaviolbarbosa commented 2 months ago

Hi @AlonAF800, thanks for your answer. Even with lat/lng covered it's not working.

curl --location 'https://api.autofleet.io/api/v1/offers' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
  "rideType": "passenger",
  "pooling": "active",
  "stopPoints": [
    {
      "type": "pickup",
      "verificationMethods": [
        {
          "type": "photo"
        }
      ],
      "lat": 48.4026688,
      "lng": -89.2611372
    },
    {
      "type": "dropoff",
      "lat": 48.4180285,
      "lng": -89.2629133
    }
  ],
  "demandSourceId": "not-displayed",
  "numberOfPassengers": 1,
  "businessModelId": "not-displayed"
}'

This is the answer

{
    "id": "3b09f99c-128f-48be-9952-9ecda1a089be",
    "state": "offer-rejected",
    "rideType": "passenger",
    "externalId": null,
    "demandSourceId": "not-displayed",
    "stopPoints": [
        {
            "id": "38e85208-3654-41cf-8386-8ca2098f820f",
            "state": "pending",
            "beforeTime": null,
            "afterTime": null,
            "lat": "48.4026688",
            "lng": "-89.2611372",
            "description": null,
            "externalId": null,
            "contactPersonName": null,
            "contactPersonAvatar": null,
            "orderInParent": 0,
            "etaAtMatching": null,
            "type": "pickup",
            "notes": null,
            "webhookUrl": null,
            "packageId": null,
            "packageDescription": null,
            "numberOfItems": null,
            "verificationMethods": [
                {
                    "type": "photo"
                }
            ],
            "contactPersonPhone": null,
            "maskedContactPersonPhoneNumber": null,
            "maskedDriverPhoneNumber": null,
            "stopDurationSec": 0,
            "additionalStopDurationSec": 0,
            "cargoWeight": null,
            "cargoVolume": null,
            "customCargoUnits": {},
            "createdAt": "2024-07-10T14:47:44.190Z",
            "preferences": {}
        },
        {
            "id": "61722504-00ab-482f-bbd3-8f283e753120",
            "state": "pending",
            "beforeTime": null,
            "afterTime": null,
            "lat": "48.4180285",
            "lng": "-89.2629133",
            "description": null,
            "externalId": null,
            "contactPersonName": null,
            "contactPersonAvatar": null,
            "orderInParent": 1,
            "etaAtMatching": null,
            "type": "dropoff",
            "notes": null,
            "webhookUrl": null,
            "packageId": null,
            "packageDescription": null,
            "numberOfItems": null,
            "verificationMethods": null,
            "contactPersonPhone": null,
            "maskedContactPersonPhoneNumber": null,
            "maskedDriverPhoneNumber": null,
            "stopDurationSec": 0,
            "additionalStopDurationSec": 0,
            "cargoWeight": null,
            "cargoVolume": null,
            "customCargoUnits": {},
            "createdAt": "2024-07-10T14:47:44.190Z",
            "preferences": {}
        }
    ],
    "vehicleId": null,
    "driverId": null,
    "fleetId": null,
    "businessModelId": "not-shown",
    "rating": null,
    "priceCurrency": "CAD",
    "priceAmount": 15.14,
    "plannedDistance": 4000,
    "webhookUrl": null,
    "pooling": "active",
    "numberOfPassengers": 1,
    "createdAt": "2024-07-10T14:47:44.181Z",
    "scheduledTo": null,
    "predecessorId": null,
    "constraints": {
        "vehicleList": {
            "include": [],
            "exclude": [],
            "required": []
        },
        "vendorList": {
            "include": [],
            "exclude": [],
            "required": []
        },
        "vehicleClassList": {
            "include": [],
            "exclude": [],
            "required": []
        },
        "vehicleLabels": {
            "include": [],
            "exclude": [],
            "required": []
        },
        "driverList": {
            "include": [],
            "exclude": [],
            "required": []
        }
    },
    "successorId": null,
    "offer": null,
    "rejectionReason": null,
    "lastMatchAttempt": null,
    "lastMatchingCycleFirstAttempt": null,
    "audits": [],
    "cancelable": false,
    "unassignableByDriver": false,
    "labels": [],
    "matchingType": "automatic",
    "dispatchType": "automatic",
    "disableMatchingRetry": false,
    "priceCalculationId": "b52cd189-4f2f-4666-ae81-45ca4ad3da77",
    "payment": null,
    "serviceId": null,
    "estimationId": null,
    "clientId": null,
    "matchingRetryDurationSec": null,
    "cancellationReasonId": null,
    "rideTemplateId": null,
    "dispatchedAt": null,
    "vendorId": null,
    "origin": null,
    "customFields": {},
    "showInOpportunities": true,
    "planningJobId": null,
    "businessAccountId": null
}
OmerGery commented 2 months ago

Hey @otaviolbarbosa Please make a new request, and provide with the x-trace-id you got from the response headers This way i can debug the issue much faster

otaviolbarbosa commented 2 months ago

@OmerGery We still can't get data from this endpoint. This is the x-trace-id: kCMSyVv_fD

OmerGery commented 2 months ago

i will look into it @otaviolbarbosa thanks

OmerGery commented 2 months ago

@otaviolbarbosa

errors: [
0: "Demand Source <> not found or associated to the selected business model"
]

the reason is a mismatch between the demand source id and the business model id on the api body payload. the demand source id you used is of your production app the business model id you used is of your testing app It needs to be either both testing or both prod.