radarlabs / radar-sdk-js

Web JavaScript SDK for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
42 stars 11 forks source link

Revert trips changes #77

Closed bschoeneweis closed 1 year ago

bschoeneweis commented 1 year ago

Summary

QA

/track

curl 'https://api.radar.io/v1/track' \
  -H 'authority: api.radar.io' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'authorization: prj_test_pk_... \
  -H 'content-type: application/json' \
  -H 'origin: http://localhost:8080' \
  -H 'referer: http://localhost:8080/' \
  -H 'sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36' \
  -H 'x-radar-device-type: Web' \
  -H 'x-radar-sdk-version: 3.5.0-beta.1' \
  --data-raw '{"accuracy":17.225,"description":null,"deviceId":"46e5f782-f576-4e61-8419-5cf9673df955","deviceType":"Web","foreground":true,"installId":"46e5f782-f576-4e61-8419-5cf9673df955","latitude":...,"longitude":...,"metadata":null,"sdkVersion":"3.5.0-beta.1","stopped":true,"userId":null,"tripOptions":null}' \
  --compressed
{
    "meta": {
        "code": 200
    },
    "user": {
        "location": {
            "type": "Point",
            "coordinates": [...]
        },
        "live": false,
        "geofences": [],
        "beacons": [],
        "_id": "...",
        "createdAt": "2022-10-12T15:52:16.639Z",
        "updatedAt": "2022-10-12T15:52:16.632Z",
        "actualUpdatedAt": "2022-10-12T15:52:16.632Z",
        "deviceId": "46e5f782-f576-4e61-8419-5cf9673df955",
        "installId": "46e5f782-f576-4e61-8419-5cf9673df955",
        "foreground": true,
        "stopped": true,
        "deviceType": "Web",
        "locationAccuracy": 17.225,
        "sdkVersion": "3.5.0-beta.1",
        "ip": "...",
        "place": {...},
        "country": {
            "_id": "5cf694f66da6a800683f4d71",
            "type": "country",
            "name": "United States",
            "code": "US"
        },
        "state": {...},
        "dma": {...},
        "postalCode": {...}
    },
    "events": [],
    "nearbyGeofences": []
}

Start trip

curl 'https://api.radar.io/v1/trips/abcdef' \
  -X 'PATCH' \
  -H 'authority: api.radar.io' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'authorization: prj_test_pk_...' \
  -H 'content-type: application/json' \
  -H 'origin: http://localhost:8080' \
  -H 'referer: http://localhost:8080/' \
  -H 'sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36' \
  -H 'x-radar-device-type: Web' \
  -H 'x-radar-sdk-version: 3.5.0-beta.1' \
  --data-raw '{"externalId":"abcdef","status":"started","destinationGeofenceTag":"place-matching","destinationGeofenceExternalId":"four-seasons-miami","mode":"car","approachingThreshold":""}' \
  --compressed
{
    "meta": {
        "code": 200
    },
    "trip": {
        "_id": "...",
        "createdAt": "2022-10-12T15:53:00.087Z",
        "updatedAt": "2022-10-12T15:53:00.087Z",
        "live": false,
        "externalId": "abcdef",
        "mode": "car",
        "status": "started",
        "startedAt": "2022-10-12T15:53:00.087Z",
        "destinationGeofenceTag": "place-matching",
        "destinationGeofenceExternalId": "four-seasons-miami",
        "destinationLocation": {
            "type": "Point",
            "coordinates": [
                -80.19157056234305,
                25.758790649600396
            ]
        },
        "locations": []
    },
    "events": []
}

/track after trip is created

curl 'https://api.radar.io/v1/track' \
  -H 'authority: api.radar.io' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'authorization: prj_test_pk_...' \
  -H 'content-type: application/json' \
  -H 'origin: http://localhost:8080' \
  -H 'referer: http://localhost:8080/' \
  -H 'sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36' \
  -H 'x-radar-device-type: Web' \
  -H 'x-radar-sdk-version: 3.5.0-beta.1' \
  --data-raw '{"accuracy":17.464,"description":null,"deviceId":"46e5f782-f576-4e61-8419-5cf9673df955","deviceType":"Web","foreground":true,"installId":"46e5f782-f576-4e61-8419-5cf9673df955","latitude":..."longitude":...,"metadata":null,"sdkVersion":"3.5.0-beta.1","stopped":true,"userId":null,"tripOptions":{"externalId":"abcdef","mode":"car","destinationGeofenceTag":"place-matching","destinationGeofenceExternalId":"four-seasons-miami","approachingThreshold":""}}' \
  --compressed
{
    "meta": {
        "code": 200
    },
    "user": {
        "location": {
            "type": "Point",
            "coordinates": [...]
        },
        "live": false,
        "geofences": [],
        "beacons": [],
        "_id": "...",
        "createdAt": "2022-10-12T15:52:16.639Z",
        "updatedAt": "2022-10-12T15:53:15.323Z",
        "actualUpdatedAt": "2022-10-12T15:53:15.323Z",
        "deviceId": "46e5f782-f576-4e61-8419-5cf9673df955",
        "installId": "46e5f782-f576-4e61-8419-5cf9673df955",
        "foreground": true,
        "stopped": true,
        "deviceType": "Web",
        "locationAccuracy": 17.464,
        "sdkVersion": "3.5.0-beta.1",
        "ip": "...",
        "place": {...},
        "trip": {
            "_id": "...",
            "createdAt": "2022-10-12T15:53:00.087Z",
            "updatedAt": "2022-10-12T15:53:15.323Z",
            "live": false,
            "externalId": "abcdef",
            "mode": "car",
            "status": "started",
            "eta": {...},
            "startedAt": "2022-10-12T15:53:00.087Z",
            "destinationGeofenceTag": "place-matching",
            "destinationGeofenceExternalId": "four-seasons-miami",
            "destinationLocation": {
                "type": "Point",
                "coordinates": [
                    -80.19157056234305,
                    25.758790649600396
                ]
            },
            "locations": [
                {
                    "type": "Point",
                    "coordinates": [...],
                    "updatedAt": "2022-10-12T15:53:15.323Z",
                    "status": "started",
                    "eta": {...}
                }
            ]
        },
        "country": {
            "_id": "5cf694f66da6a800683f4d71",
            "type": "country",
            "name": "United States",
            "code": "US"
        },
        "state": {...},
        "dma": {...},
        "postalCode": {...}
    },
    "events": [
        {
            "createdAt": "2022-10-12T15:53:15.323Z",
            "live": false,
            "type": "user.started_trip",
            "location": {
                "type": "Point",
                "coordinates": [...]
            },
            "locationAccuracy": 17.464,
            "confidence": 3,
            "actualCreatedAt": "2022-10-12T15:53:15.323Z",
            "user": {
                "location": {
                    "type": "Point",
                    "coordinates": [...]
                },
                "_id": "...",
                "deviceId": "46e5f782-f576-4e61-8419-5cf9673df955",
                "installId": "46e5f782-f576-4e61-8419-5cf9673df955",
                "locationAccuracy": 17.464,
                "sdkVersion": "3.5.0-beta.1",
                "state": {...},
                "dma": {.},..
                "postalCode": {...}
            },
            "foreground": true,
            "trip": {
                "_id": "...",
                "createdAt": "2022-10-12T15:53:00.087Z",
                "updatedAt": "2022-10-12T15:53:15.323Z",
                "live": false,
                "externalId": "abcdef",
                "mode": "car",
                "status": "started",
                "eta": {...},
                "startedAt": "2022-10-12T15:53:00.087Z",
                "destinationGeofenceTag": "place-matching",
                "destinationGeofenceExternalId": "four-seasons-miami",
                "destinationLocation": {
                    "type": "Point",
                    "coordinates": [
                        -80.19157056234305,
                        25.758790649600396
                    ]
                },
                "locations": [
                    {
                        "type": "Point",
                        "coordinates": [...],
                        "updatedAt": "2022-10-12T15:53:15.323Z",
                        "status": "started",
                        "eta": {... }
                    }
                ]
            },
            "deviceType": "Web",
            "sdkVersion": "3.5.0-beta.1",
            "stopped": true,
            "_id": "...",
            "country": {
                "_id": "5cf694f66da6a800683f4d71",
                "type": "country",
                "name": "United States",
                "code": "US"
            },
            "state": {...},
            "postalCode": {...},
            "dma": {...}
        }
    ],
    "nearbyGeofences": []
}

Complete trip

curl 'https://api.radar.io/v1/trips/abcdef' \
  -X 'PATCH' \
  -H 'authority: api.radar.io' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'authorization: prj_test_pk_...' \
  -H 'content-type: application/json' \
  -H 'origin: http://localhost:8080' \
  -H 'referer: http://localhost:8080/' \
  -H 'sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36' \
  -H 'x-radar-device-type: Web' \
  -H 'x-radar-sdk-version: 3.5.0-beta.1' \
  --data-raw '{"externalId":"abcdef","status":"completed","destinationGeofenceTag":"place-matching","destinationGeofenceExternalId":"four-seasons-miami","mode":"car","approachingThreshold":""}' \
  --compressed
{
    "meta": {
        "code": 200
    },
    "trip": {
        "_id": "...",
        "createdAt": "2022-10-12T15:53:00.087Z",
        "updatedAt": "2022-10-12T15:53:19.673Z",
        "live": false,
        "externalId": "abcdef",
        "mode": "car",
        "status": "completed",
        "startedAt": "2022-10-12T15:53:00.087Z",
        "completedAt": "2022-10-12T15:53:19.673Z",
        "endedAt": "2022-10-12T15:53:19.673Z",
        "destinationGeofenceTag": "place-matching",
        "destinationGeofenceExternalId": "four-seasons-miami",
        "destinationLocation": {
            "type": "Point",
            "coordinates": [
                -80.19157056234305,
                25.758790649600396
            ]
        },
        "user": {
            "_id": "..."
        },
        "locations": [
            {
                "type": "Point",
                "coordinates": [...],
                "updatedAt": "2022-10-12T15:53:15.323Z",
                "status": "started",
                "eta": {...}
            }
        ]
    },
    "user": {
        "_id": "...",
        "deviceId": "46e5f782-f576-4e61-8419-5cf9673df955"
    },
    "events": [
        {
            "createdAt": "2022-10-12T15:53:19.697Z",
            "live": false,
            "type": "user.stopped_trip",
            "location": {
                "type": "Point",
                "coordinates": [...]
            },
            "locationAccuracy": 17.464,
            "confidence": 3,
            "actualCreatedAt": "2022-10-12T15:53:19.697Z",
            "user": {
                "_id": "...",
                "deviceId": "46e5f782-f576-4e61-8419-5cf9673df955"
            },
            "trip": {
                "_id": "...",
                "createdAt": "2022-10-12T15:53:00.087Z",
                "updatedAt": "2022-10-12T15:53:19.673Z",
                "live": false,
                "externalId": "abcdef",
                "mode": "car",
                "status": "completed",
                "startedAt": "2022-10-12T15:53:00.087Z",
                "completedAt": "2022-10-12T15:53:19.673Z",
                "endedAt": "2022-10-12T15:53:19.673Z",
                "destinationGeofenceTag": "place-matching",
                "destinationGeofenceExternalId": "four-seasons-miami",
                "destinationLocation": {
                    "type": "Point",
                    "coordinates": [
                        -80.19157056234305,
                        25.758790649600396
                    ]
                },
                "locations": [...]
            },
            "_id": "..."
        }
    ]
}