diff --git a/cmd/devices-api/api.go b/cmd/devices-api/api.go index 49600f1ad..b35cb280d 100644 --- a/cmd/devices-api/api.go +++ b/cmd/devices-api/api.go @@ -11,53 +11,45 @@ import ( "syscall" "time" - "github.com/DIMO-Network/shared/privileges" - - "github.com/DIMO-Network/devices-api/internal/services/fingerprint" - - "github.com/DIMO-Network/devices-api/internal/middleware" - - "github.com/DIMO-Network/devices-api/internal/rpc" - - "github.com/DIMO-Network/devices-api/internal/middleware/metrics" - grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" - grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" - grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - - "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/recovery" - - "github.com/DIMO-Network/shared/redis" - - "github.com/DIMO-Network/shared/db" - "github.com/ethereum/go-ethereum/common" - - "github.com/DIMO-Network/devices-api/internal/controllers/helpers" - "github.com/DIMO-Network/devices-api/internal/middleware/owner" - - "github.com/DIMO-Network/devices-api/internal/config" - "github.com/DIMO-Network/devices-api/internal/constants" - "github.com/DIMO-Network/devices-api/internal/controllers" - "github.com/DIMO-Network/devices-api/internal/services" - "github.com/DIMO-Network/devices-api/internal/services/autopi" - "github.com/DIMO-Network/devices-api/internal/services/issuer" - "github.com/DIMO-Network/devices-api/internal/services/macaron" - "github.com/DIMO-Network/devices-api/internal/services/registry" - pb "github.com/DIMO-Network/devices-api/pkg/grpc" "github.com/DIMO-Network/shared" pbuser "github.com/DIMO-Network/shared/api/users" + "github.com/DIMO-Network/shared/db" "github.com/DIMO-Network/shared/middleware/privilegetoken" + "github.com/DIMO-Network/shared/privileges" + "github.com/DIMO-Network/shared/redis" "github.com/DIMO-Network/zflogger" "github.com/Shopify/sarama" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/ethereum/go-ethereum/common" jwtware "github.com/gofiber/contrib/jwt" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cache" "github.com/gofiber/fiber/v2/middleware/cors" fiberrecover "github.com/gofiber/fiber/v2/middleware/recover" "github.com/gofiber/swagger" + grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" + grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/recovery" + grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/rs/zerolog" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + + "github.com/DIMO-Network/devices-api/internal/config" + "github.com/DIMO-Network/devices-api/internal/constants" + "github.com/DIMO-Network/devices-api/internal/controllers" + "github.com/DIMO-Network/devices-api/internal/controllers/helpers" + "github.com/DIMO-Network/devices-api/internal/middleware" + "github.com/DIMO-Network/devices-api/internal/middleware/metrics" + "github.com/DIMO-Network/devices-api/internal/middleware/owner" + "github.com/DIMO-Network/devices-api/internal/rpc" + "github.com/DIMO-Network/devices-api/internal/services" + "github.com/DIMO-Network/devices-api/internal/services/autopi" + "github.com/DIMO-Network/devices-api/internal/services/fingerprint" + "github.com/DIMO-Network/devices-api/internal/services/issuer" + "github.com/DIMO-Network/devices-api/internal/services/macaron" + "github.com/DIMO-Network/devices-api/internal/services/registry" + pb "github.com/DIMO-Network/devices-api/pkg/grpc" ) func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, eventService services.EventService, producer sarama.SyncProducer, s3ServiceClient *s3.Client, s3NFTServiceClient *s3.Client) { @@ -146,10 +138,11 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, documentsController := controllers.NewDocumentsController(settings, &logger, s3ServiceClient, pdb.DBS) countriesController := controllers.NewCountriesController() userIntegrationAuthController := controllers.NewUserIntegrationAuthController(settings, pdb.DBS, &logger, ddSvc, teslaFleetAPISvc, redisCache, cipher, usersClient) + userDeviceControllerV2 := controllers.NewUserDevicesControllerV2(settings, pdb.DBS, &logger, ddSvc) // commenting this out b/c the library includes the path in the metrics which saturates prometheus queries - need to fork / make our own - //prometheus := fiberprometheus.New("devices-api") - //app.Use(prometheus.Middleware) + // prometheus := fiberprometheus.New("devices-api") + // app.Use(prometheus.Middleware) app.Use(metrics.HTTPMetricsMiddleware) app.Use(fiberrecover.New(fiberrecover.Config{ @@ -157,11 +150,11 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, EnableStackTrace: true, StackTraceHandler: nil, })) - //cors + // cors app.Use(cors.New()) // request logging app.Use(zflogger.New(logger, nil)) - //cache + // cache cacheHandler := cache.New(cache.Config{ Next: func(c *fiber.Ctx) bool { return c.Query("refresh") == "true" @@ -198,6 +191,7 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, }) vPriv := app.Group("/v1/vehicle/:tokenID", privilegeAuth) + vPriv2 := app.Group("/v2/vehicles/:tokenID", privilegeAuth) privTokenWare := privilegetoken.New(privilegetoken.Config{Log: &logger}) @@ -330,6 +324,8 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, udOwner.Post("/aftermarket/commands/unpair", userDeviceController.UnpairAutoPi) udOwner.Post("/aftermarket/commands/cloud-repair", userDeviceController.CloudRepairAutoPi) + vPriv2.Get("/analytics/range", privTokenWare.OneOf(vehicleAddr, []privileges.Privilege{privileges.VehicleNonLocationData}), userDeviceControllerV2.GetRange) + logger.Info().Msg("Server started on port " + settings.Port) // Start Server from a different go routine go func() { diff --git a/docs/docs.go b/docs/docs.go index ddd0823a4..fa7503fcf 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,6 +1,4 @@ -// Package docs GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag at -// 2024-03-26 15:50:39.486471 -0600 MDT m=+2.385957543 +// Package docs Code generated by swaggo/swag at 2024-04-22 11:59:11.784573 -0400 EDT m=+2.083926209. DO NOT EDIT package docs import "github.com/swaggo/swag" @@ -75,7 +73,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiDeviceInfo" + "$ref": "#/definitions/internal_controllers.AutoPiDeviceInfo" } } } @@ -134,7 +132,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiClaimRequest" + "$ref": "#/definitions/internal_controllers.AutoPiClaimRequest" } } ], @@ -199,7 +197,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/services.AutoPiTask" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.AutoPiTask" } } } @@ -277,7 +275,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/constants.CountryInfo" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo" } } } @@ -305,7 +303,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/constants.CountryInfo" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo" } }, "400": { @@ -317,74 +315,6 @@ const docTemplate = `{ } } }, - "/dcn/{tokenID}": { - "get": { - "description": "retrieves the DCN NFT metadata for a given token ID address", - "produces": [ - "application/json" - ], - "tags": [ - "dcn" - ], - "parameters": [ - { - "type": "string", - "description": "DCN node id decimal representation", - "name": "tokenID", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/dcn/{tokenID}/image": { - "get": { - "description": "retrieves the DCN NFT metadata for a given token address", - "produces": [ - "image/svg+xml" - ], - "tags": [ - "dcn" - ], - "parameters": [ - { - "type": "string", - "description": "DCN node id decimal representation", - "name": "tokenID", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - } - } - } - }, "/documents": { "get": { "security": [ @@ -408,7 +338,7 @@ const docTemplate = `{ "schema": { "type": "array", "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse" + "$ref": "#/definitions/internal_controllers.DocumentResponse" } } } @@ -463,7 +393,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse" + "$ref": "#/definitions/internal_controllers.DocumentResponse" } } } @@ -499,7 +429,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse" + "$ref": "#/definitions/internal_controllers.DocumentResponse" } } } @@ -624,105 +554,16 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponseWrapper" + "$ref": "#/definitions/internal_controllers.CompleteOAuthExchangeRequest" } } - } - } - }, - "/integrations": { - "get": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "gets list of integrations we have defined", - "produces": [ - "application/json" - ], - "tags": [ - "integrations" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/grpc.Integration" - } - } - } - } - } - }, - "/manufacturer/{tokenId}": { - "get": { - "description": "Retrieves NFT metadata for a given manufacturer.", - "produces": [ - "application/json" - ], - "tags": [ - "nfts" - ], - "parameters": [ - { - "type": "integer", - "description": "token id", - "name": "tokenId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/synthetic/device/{tokenId}": { - "get": { - "description": "Retrieves NFT metadata for a given synthetic device.", - "produces": [ - "application/json" - ], - "tags": [ - "nfts" - ], - "parameters": [ - { - "type": "integer", - "description": "token id", - "name": "tokenId", - "in": "path", - "required": true - } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" + "$ref": "#/definitions/internal_controllers.CompleteOAuthExchangeResponseWrapper" } - }, - "404": { - "description": "Not Found" } } } @@ -754,7 +595,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDevice" + "$ref": "#/definitions/internal_controllers.RegisterUserDevice" } } ], @@ -762,7 +603,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceResponse" + "$ref": "#/definitions/internal_controllers.RegisterUserDeviceResponse" } } } @@ -854,7 +695,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest" + "$ref": "#/definitions/internal_controllers.AutoPiPairRequest" } } ], @@ -914,7 +755,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest" + "$ref": "#/definitions/internal_controllers.AutoPiPairRequest" } } ], @@ -942,7 +783,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterDeviceIntegrationRequest" + "$ref": "#/definitions/internal_controllers.RegisterDeviceIntegrationRequest" } } ], @@ -980,7 +821,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceSmartcar" + "$ref": "#/definitions/internal_controllers.RegisterUserDeviceSmartcar" } } ], @@ -988,13 +829,13 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" + "$ref": "#/definitions/internal_controllers.UserDeviceFull" } }, "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" + "$ref": "#/definitions/internal_controllers.UserDeviceFull" } }, "400": { @@ -1039,7 +880,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceVIN" + "$ref": "#/definitions/internal_controllers.RegisterUserDeviceVIN" } } ], @@ -1047,7 +888,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" + "$ref": "#/definitions/internal_controllers.UserDeviceFull" } }, "400": { @@ -1080,7 +921,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp" + "$ref": "#/definitions/internal_controllers.MyDevicesResp" } } } @@ -1104,7 +945,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp" + "$ref": "#/definitions/internal_controllers.MyDevicesResp" } } } @@ -1190,7 +1031,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MintRequest" + "$ref": "#/definitions/internal_controllers.MintRequest" } } ], @@ -1285,7 +1126,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateCountryCodeReq" + "$ref": "#/definitions/internal_controllers.UpdateCountryCodeReq" } } ], @@ -1326,7 +1167,7 @@ const docTemplate = `{ "404": { "description": "Vehicle not found", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } } } @@ -1369,7 +1210,7 @@ const docTemplate = `{ "404": { "description": "Vehicle not found", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } } } @@ -1396,13 +1237,13 @@ const docTemplate = `{ "404": { "description": "Vehicle not found", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } }, "429": { "description": "Last query already cleared", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } } } @@ -1423,7 +1264,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceIntegrationResponse" + "$ref": "#/definitions/internal_controllers.GetUserDeviceIntegrationResponse" } } } @@ -1555,7 +1396,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1594,7 +1435,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1633,7 +1474,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1749,7 +1590,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1795,7 +1636,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandRequestStatusResp" + "$ref": "#/definitions/internal_controllers.CommandRequestStatusResp" } } } @@ -1825,7 +1666,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateNameReq" + "$ref": "#/definitions/internal_controllers.UpdateNameReq" } }, { @@ -1900,7 +1741,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateVINReq" + "$ref": "#/definitions/internal_controllers.UpdateVINReq" } }, { @@ -1943,7 +1784,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTImageData" + "$ref": "#/definitions/internal_controllers.NFTImageData" } } ], @@ -1977,7 +1818,7 @@ const docTemplate = `{ "schema": { "type": "array", "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetGeofence" + "$ref": "#/definitions/internal_controllers.GetGeofence" } } } @@ -2009,7 +1850,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence" + "$ref": "#/definitions/internal_controllers.CreateGeofence" } } ], @@ -2017,7 +1858,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/helpers.CreateResponse" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.CreateResponse" } } } @@ -2057,7 +1898,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence" + "$ref": "#/definitions/internal_controllers.CreateGeofence" } } ], @@ -2154,6 +1995,39 @@ const docTemplate = `{ } } }, + "/v2/vehicles/{tokenId}/analytics/range": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "gets the estimated range for a particular user device", + "produces": [ + "application/json" + ], + "tags": [ + "user-devices" + ], + "parameters": [ + { + "type": "integer", + "description": "tokenId", + "name": "tokenId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/internal_controllers.DeviceRange" + } + } + } + } + }, "/vehicle/{tokenID}/commands/doors/lock": { "post": { "description": "Lock the device's doors.", @@ -2472,7 +2346,7 @@ const docTemplate = `{ "big.Int": { "type": "object" }, - "constants.CountryInfo": { + "github_com_DIMO-Network_devices-api_internal_constants.CountryInfo": { "type": "object", "properties": { "alpha_2": { @@ -2501,1020 +2375,269 @@ const docTemplate = `{ } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiClaimRequest": { + "github_com_DIMO-Network_devices-api_internal_controllers_helpers.CreateResponse": { "type": "object", "properties": { - "aftermarketDeviceSignature": { - "description": "AftermarketDeviceSignature is the signature from the aftermarket device.", + "id": { "type": "string" + } + } + }, + "github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes": { + "type": "object", + "properties": { + "code": { + "type": "integer" }, - "userSignature": { - "description": "UserSignature is the signature from the user, using their private key.", + "message": { "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiDeviceInfo": { + "github_com_DIMO-Network_devices-api_internal_services.AutoPiTask": { "type": "object", "properties": { - "beneficiaryAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", - "type": "array", - "items": { - "type": "integer" - } - }, - "claim": { - "description": "Claim contains the status of the on-chain claiming meta-transaction.", - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus" + "code": { + "type": "integer" }, - "deviceId": { + "description": { "type": "string" }, - "dockerReleases": { - "type": "array", - "items": { - "type": "integer" - } - }, - "ethereumAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", - "type": "array", - "items": { - "type": "integer" - } - }, - "hwRevision": { + "error": { "type": "string" }, - "isUpdated": { - "type": "boolean" - }, - "lastCommunication": { + "status": { "type": "string" }, - "manufacturer": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.ManufacturerInfo" - }, - "ownerAddress": { + "taskId": { "type": "string" }, - "pair": { - "description": "Pair contains the status of the on-chain pairing meta-transaction.", - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus" - }, - "releaseVersion": { + "updatedAt": { "type": "string" }, - "shouldUpdate": { - "type": "boolean" - }, - "template": { + "updates": { + "description": "Updates increments every time the job was updated.", "type": "integer" - }, - "tokenId": { - "$ref": "#/definitions/big.Int" - }, - "unitId": { + } + } + }, + "github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute": { + "type": "object", + "properties": { + "name": { "type": "string" }, - "unpair": { - "description": "Unpair contains the status of the on-chain unpairing meta-transaction.", - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus" + "value": { + "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility": { "type": "object", "properties": { - "aftermarketDeviceSignature": { - "description": "AftermarketDeviceSignature is the 65-byte, hex-encoded Ethereum signature of\nthe pairing payload by the device. Only needed if the vehicle owner and aftermarket\ndevice owner are not the same.", + "capabilities": { "type": "array", "items": { "type": "integer" } }, - "externalId": { + "country": { "type": "string" }, - "signature": { - "description": "AftermarketDeviceSignature is the 65-byte, hex-encoded Ethereum signature of\nthe pairing payload by the device. Only needed if the vehicle owner and aftermarket\ndevice owner are not the same.", - "type": "array", - "items": { - "type": "integer" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus": { - "type": "object", - "properties": { - "createdAt": { - "description": "CreatedAt is the timestamp of the creation of the meta-transaction.", - "type": "string", - "example": "2022-10-01T09:22:21.002Z" - }, - "hash": { - "description": "Hash is the hexidecimal transaction hash, available for any transaction at the Submitted stage or greater.", - "type": "string", - "example": "0x28b4662f1e1b15083261a4a5077664f4003d58cb528826b7aab7fad466c28e70" - }, - "status": { - "description": "Status is the state of the transaction performing this operation. There are only four options.", - "type": "string", - "enum": [ - "Unsubmitted", - "Submitted", - "Mined", - "Confirmed" - ], - "example": "Mined" - }, - "updatedAt": { - "description": "UpdatedAt is the last time we updated the status of the transaction.", - "type": "string", - "example": "2022-10-01T09:22:26.337Z" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.BurnRequest": { - "type": "object", - "required": [ - "signature" - ], - "properties": { - "signature": { - "description": "Signature is the hex encoding of the EIP-712 signature result.", - "type": "string" - }, - "tokenId": { - "$ref": "#/definitions/big.Int" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.BurnSyntheticDeviceRequest": { - "type": "object", - "properties": { - "signature": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CommandRequestStatusResp": { - "type": "object", - "properties": { - "command": { - "type": "string", - "example": "doors/unlock" - }, - "createdAt": { - "type": "string", - "example": "2022-08-09T19:38:39Z" - }, - "id": { - "type": "string", - "example": "2D8LqUHQtaMHH6LYPqznmJMBeZm" - }, - "status": { - "type": "string", - "enum": [ - "Pending", - "Complete", - "Failed" - ], - "example": "Complete" - }, - "updatedAt": { - "type": "string", - "example": "2022-08-09T19:39:22Z" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse": { - "type": "object", - "properties": { - "requestId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeRequest": { - "type": "object", - "properties": { - "authorizationCode": { - "type": "string" - }, - "redirectUri": { - "type": "string" - }, - "region": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponse": { - "type": "object", - "properties": { - "definition": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DeviceDefinition" - }, - "externalId": { - "type": "string" - }, - "vin": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponseWrapper": { - "type": "object", - "properties": { - "vehicles": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponse" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence": { - "type": "object", - "properties": { - "h3Indexes": { - "description": "required: false", - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "description": "required: true", - "type": "string" - }, - "type": { - "description": "one of following: \"PrivacyFence\", \"TriggerEntry\", \"TriggerExit\"\nrequired: true", - "type": "string" - }, - "userDeviceIds": { - "description": "Optionally link the geofence with a list of user device ID", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.DeviceDefinition": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "make": { - "type": "string" - }, - "model": { - "type": "string" - }, - "year": { - "type": "integer" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.DeviceSnapshot": { - "type": "object", - "properties": { - "ambientTemp": { - "type": "number" - }, - "batteryCapacity": { - "type": "integer" - }, - "batteryVoltage": { - "type": "number" - }, - "chargeLimit": { - "type": "number" - }, - "charging": { - "type": "boolean" - }, - "fuelPercentRemaining": { - "type": "number" - }, - "latitude": { - "type": "number" - }, - "longitude": { - "type": "number" - }, - "odometer": { - "type": "number" - }, - "oil": { - "type": "number" - }, - "range": { - "type": "number" - }, - "recordCreatedAt": { - "type": "string" - }, - "recordUpdatedAt": { - "type": "string" - }, - "soc": { - "type": "number" - }, - "tirePressure": { - "$ref": "#/definitions/smartcar.TirePressure" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "ext": { - "type": "string" - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "url": { - "type": "string" - }, - "userDeviceId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GeoFenceUserDevice": { - "type": "object", - "properties": { - "mmy": { - "type": "string" - }, - "name": { - "type": "string" - }, - "userDeviceId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetGeofence": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "h3Indexes": { - "type": "array", - "items": { - "type": "string" - } - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "userDevices": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GeoFenceUserDevice" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponse": { - "type": "object", - "properties": { - "queries": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponseItem" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponseItem": { - "type": "object", - "properties": { - "clearedAt": { - "description": "ClearedAt is the time at which the user cleared the codes from this query.\nMay be null.", - "type": "string", - "example": "2023-05-23T12:57:05Z" - }, - "errorCodes": { - "type": "array", - "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" - } - }, - "requestedAt": { - "type": "string", - "example": "2023-05-23T12:56:36Z" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceIntegrationResponse": { - "type": "object", - "properties": { - "createdAt": { - "description": "CreatedAt is the creation time of this integration for this device.", - "type": "string" - }, - "externalId": { - "description": "ExternalID is the identifier used by the third party for the device. It may be absent if we\nhaven't authorized yet.", - "type": "string" - }, - "status": { - "description": "Status is one of \"Pending\", \"PendingFirstData\", \"Active\", \"Failed\", \"DuplicateIntegration\".", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.ManufacturerInfo": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "tokenId": { - "$ref": "#/definitions/big.Int" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.MintRequest": { - "type": "object", - "required": [ - "imageData", - "signature" - ], - "properties": { - "imageData": { - "description": "ImageData contains the base64-encoded NFT PNG image.", - "type": "string" - }, - "imageDataTransparent": { - "description": "ImageDataTransparent contains the base64-encoded NFT PNG image\nwith a transparent background, for use in the app. For compatibility\nwith older versions it is not required.", - "type": "string" - }, - "signature": { - "description": "Signature is the hex encoding of the EIP-712 signature result.", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.MintSyntheticDeviceRequest": { - "type": "object", - "properties": { - "signature": { - "type": "string", - "example": "0xc565d38982e1a5004efb5ee390fba0a08bb5e72b3f3e91094c66bc395c324f785425d58d5c1a601372d9c16164e380c63e89f1e0ea95fdefdf7b2854c4f938e81b" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp": { - "type": "object", - "properties": { - "sharedDevices": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" - } - }, - "userDevices": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTAttribute": { - "type": "object", - "properties": { - "trait_type": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTData": { - "type": "object", - "properties": { - "ownerAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", - "type": "array", - "items": { - "type": "integer" - } - }, - "status": { - "description": "Status is the minting status of the NFT.", - "type": "string", - "enum": [ - "Unstarted", - "Submitted", - "Mined", - "Confirmed" - ], - "example": "Confirmed" - }, - "tokenId": { - "type": "number", - "example": 37 - }, - "tokenUri": { - "type": "string", - "example": "https://nft.dimo.zone/37" - }, - "txHash": { - "description": "TxHash is the hash of the minting transaction.", - "type": "string", - "example": "0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTImageData": { - "type": "object", - "required": [ - "imageData" - ], - "properties": { - "imageData": { - "description": "ImageData contains the base64-encoded NFT PNG image.", - "type": "string" - }, - "imageDataTransparent": { - "description": "ImageDataTransparent contains the base64-encoded NFT PNG image\nwith a transparent background, for use in the app. For compatibility\nwith older versions it is not required.", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTMetadataResp": { - "type": "object", - "properties": { - "attributes": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTAttribute" - } - }, - "description": { - "type": "string" - }, - "image": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.Offer": { - "type": "object", - "properties": { - "declineReason": { - "description": "The reason the offer was declined from the vendor", - "type": "string" - }, - "error": { - "description": "An error from the vendor (eg. when the VIN is invalid)", - "type": "string" - }, - "grade": { - "description": "The grade of the offer from the vendor (eg. \"RETAIL\")", - "type": "string" - }, - "price": { - "description": "The offer price from the vendor", - "type": "integer" - }, - "url": { - "description": "The offer URL from the vendor", - "type": "string" - }, - "vendor": { - "description": "The vendor of the offer (eg. \"carmax\", \"carvana\", etc.)", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.Privilege": { - "type": "object", - "properties": { - "expiry": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "updatedAt": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.PrivilegeUser": { - "type": "object", - "properties": { - "address": { - "type": "string" - }, - "privileges": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.Privilege" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.QueryDeviceErrorCodesReq": { - "type": "object", - "properties": { - "errorCodes": { - "type": "array", - "items": { - "type": "string" - }, - "example": [ - "P0106", - "P0279" - ] - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.QueryDeviceErrorCodesResponse": { - "type": "object", - "properties": { - "clearedAt": { - "type": "string" - }, - "errorCodes": { - "type": "array", - "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RangeSet": { - "type": "object", - "properties": { - "rangeBasis": { - "description": "The basis for the range calculation (eg. \"MPG\" or \"MPG Highway\")", - "type": "string" - }, - "rangeDistance": { - "description": "The estimated range distance", - "type": "integer" - }, - "rangeUnit": { - "description": "The unit used for the rangeDistance (eg. \"miles\" or \"kilometers\")", - "type": "string" - }, - "updated": { - "description": "The time the data was collected", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterDeviceIntegrationRequest": { - "type": "object", - "properties": { - "accessToken": { - "type": "string" - }, - "code": { - "description": "Code is an OAuth authorization code. Not used in all integrations.", - "type": "string" - }, - "expiresIn": { - "type": "integer" - }, - "externalId": { - "description": "ExternalID is the only field needed for AutoPi registrations. It is the UnitID.", + "id": { "type": "string" }, - "redirectURI": { - "description": "RedirectURI is the OAuth redirect URI used by the frontend. Not used in all integrations.", + "region": { "type": "string" }, - "refreshToken": { + "style": { "type": "string" }, - "version": { - "type": "integer" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDevice": { - "type": "object", - "properties": { - "countryCode": { + "type": { "type": "string" }, - "deviceDefinitionId": { + "vendor": { "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceResponse": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceDefinition": { "type": "object", "properties": { - "deviceDefinitionId": { - "type": "string" - }, - "integrationCapabilities": { + "compatibleIntegrations": { + "description": "CompatibleIntegrations has systems this vehicle can integrate with", "type": "array", "items": { - "$ref": "#/definitions/services.DeviceCompatibility" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility" } }, - "userDeviceId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceSmartcar": { - "type": "object", - "properties": { - "code": { - "description": "Code refers to the auth code provided by smartcar when user logs in", - "type": "string" + "deviceAttributes": { + "description": "DeviceAttributes is a list of attributes for the device type as defined in device_types.properties", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute" + } }, - "countryCode": { + "deviceDefinitionId": { "type": "string" }, - "redirectURI": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceVIN": { - "type": "object", - "properties": { - "canProtocol": { - "description": "CANProtocol is the protocol that was detected by edge-network from the autopi.", + "imageUrl": { "type": "string" }, - "countryCode": { - "type": "string" + "make": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceMake" }, - "vin": { + "metadata": {}, + "name": { "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.SyntheticDeviceStatus": { - "type": "object", - "properties": { - "address": { - "type": "string", - "example": "0xAED7EA8035eEc47E657B34eF5D020c7005487443" }, - "status": { - "type": "string", - "enum": [ - "Unstarted", - "Submitted", - "Mined", - "Confirmed" - ], - "example": "Confirmed" + "type": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceType" }, - "tokenId": { - "type": "number", - "example": 15 + "vehicleData": { + "description": "VehicleInfo will be empty if not a vehicle type", + "allOf": [ + { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceVehicleInfo" + } + ] }, - "txHash": { - "type": "string", - "example": "0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e" + "verified": { + "type": "boolean" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.UpdateCountryCodeReq": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceMake": { "type": "object", "properties": { - "countryCode": { + "id": { "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.UpdateNameReq": { - "type": "object", - "properties": { + }, + "logo_url": { + "type": "string" + }, "name": { "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.UpdateVINReq": { - "type": "object", - "required": [ - "vin" - ], - "properties": { - "signature": { - "description": "Signature is the hex-encoded result of the AutoPi signing the VIN. It must\nbe present to verify the VIN.", - "type": "string", - "example": "16b15f88bbd2e0a22d1d0084b8b7080f2003ea83eab1a00f80d8c18446c9c1b6224f17aa09eaf167717ca4f355bb6dc94356e037edf3adf6735a86fc3741f5231b" }, - "vin": { - "description": "VIN is a vehicle identification number. At the very least, it must be\n17 characters in length and contain only letters and numbers.", - "type": "string", - "example": "4Y1SL65848Z411439" + "oem_platform_name": { + "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceType": { "type": "object", "properties": { - "countryCode": { - "type": "string" - }, - "customImageUrl": { - "type": "string" - }, - "deviceDefinition": { - "$ref": "#/definitions/services.DeviceDefinition" - }, - "id": { - "type": "string" - }, - "integrations": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceIntegrationStatus" - } - }, - "metadata": { - "$ref": "#/definitions/services.UserDeviceMetadata" - }, - "name": { + "make": { "type": "string" }, - "nft": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTData" - }, - "optedInAt": { + "model": { "type": "string" }, - "privilegedUsers": { + "subModels": { "type": "array", "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.PrivilegeUser" + "type": "string" } }, - "vin": { + "type": { + "description": "Type is eg. Vehicle, E-bike, roomba", "type": "string" }, - "vinConfirmed": { - "type": "boolean" - }, - "vinCredential": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.VINCredentialData" + "year": { + "type": "integer" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceIntegrationStatus": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceVehicleInfo": { "type": "object", "properties": { - "createdAt": { + "base_msrp": { + "type": "integer" + }, + "driven_wheels": { "type": "string" }, - "externalId": { + "epa_class": { "type": "string" }, - "integrationId": { + "fuel_tank_capacity_gal": { "type": "string" }, - "integrationVendor": { + "fuel_type": { "type": "string" }, - "metadata": { + "mpg": { "type": "string" }, - "status": { + "mpg_city": { "type": "string" }, - "syntheticDevice": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.SyntheticDeviceStatus" + "mpg_highway": { + "type": "string" }, - "tokenId": { - "$ref": "#/definitions/big.Int" + "number_of_doors": { + "type": "string" }, - "updatedAt": { + "vehicle_type": { + "description": "VehicleType PASSENGER CAR, from NHTSA", "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.VINCredentialData": { + "github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse": { "type": "object", "properties": { - "expiresAt": { - "type": "string" - }, - "issuedAt": { - "type": "string" - }, - "valid": { - "type": "boolean" + "code": { + "type": "string", + "example": "P0148" }, - "vin": { - "type": "string" + "description": { + "type": "string", + "example": "Fuel delivery error" } } }, - "grpc.Integration": { + "github_com_DIMO-Network_devices-api_internal_services.PowertrainType": { + "type": "string", + "enum": [ + "ICE", + "HEV", + "PHEV", + "BEV", + "FCEV" + ], + "x-enum-varnames": [ + "ICE", + "HEV", + "PHEV", + "BEV", + "FCEV" + ] + }, + "github_com_DIMO-Network_devices-api_internal_services.UserDeviceMetadata": { "type": "object", "properties": { - "auto_pi_default_template_id": { - "type": "integer" - }, - "auto_pi_powertrain_template": { - "$ref": "#/definitions/grpc.Integration_AutoPiPowertrainTemplate" - }, - "id": { - "type": "string" - }, - "manufacturer_token_id": { - "type": "integer" - }, - "points": { - "type": "integer" - }, - "refresh_limit_secs": { - "type": "integer" - }, - "style": { + "canProtocol": { + "description": "CANProtocol is the protocol that was detected by edge-network from the autopi.", "type": "string" }, - "token_id": { - "description": "token_id can have a 0 value, which means it has not yet been minted and no token id has been assigned. This case should be checked for and handled.", - "type": "integer" + "elasticDefinitionSynced": { + "type": "boolean" }, - "type": { - "type": "string" + "elasticRegionSynced": { + "type": "boolean" }, - "vendor": { + "geoDecodedCountry": { "type": "string" - } - } - }, - "grpc.Integration_AutoPiPowertrainTemplate": { - "type": "object", - "properties": { - "BEV": { - "type": "integer" - }, - "HEV": { - "type": "integer" - }, - "ICE": { - "type": "integer" }, - "PHEV": { - "type": "integer" - } - } - }, - "helpers.CreateResponse": { - "type": "object", - "properties": { - "id": { + "geoDecodedStateProv": { "type": "string" - } - } - }, - "helpers.ErrorRes": { - "type": "object", - "properties": { - "code": { - "type": "integer" }, - "message": { + "postal_code": { "type": "string" + }, + "powertrainType": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.PowertrainType" } } }, @@ -3535,7 +2658,6 @@ const docTemplate = `{ "type": "object", "properties": { "beneficiaryAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", "type": "array", "items": { "type": "integer" @@ -3543,7 +2665,11 @@ const docTemplate = `{ }, "claim": { "description": "Claim contains the status of the on-chain claiming meta-transaction.", - "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + "allOf": [ + { + "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + } + ] }, "deviceId": { "type": "string" @@ -3555,7 +2681,6 @@ const docTemplate = `{ } }, "ethereumAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", "type": "array", "items": { "type": "integer" @@ -3578,7 +2703,11 @@ const docTemplate = `{ }, "pair": { "description": "Pair contains the status of the on-chain pairing meta-transaction.", - "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + "allOf": [ + { + "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + } + ] }, "releaseVersion": { "type": "string" @@ -3597,7 +2726,11 @@ const docTemplate = `{ }, "unpair": { "description": "Unpair contains the status of the on-chain unpairing meta-transaction.", - "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + "allOf": [ + { + "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + } + ] } } }, @@ -3797,6 +2930,18 @@ const docTemplate = `{ } } }, + "internal_controllers.DeviceRange": { + "type": "object", + "properties": { + "rangeSets": { + "description": "Contains a list of range sets, one for each range basis (may be empty)", + "type": "array", + "items": { + "$ref": "#/definitions/internal_controllers.RangeSet" + } + } + } + }, "internal_controllers.DeviceSnapshot": { "type": "object", "properties": { @@ -3863,7 +3008,7 @@ const docTemplate = `{ "type": "string" }, "type": { - "type": "string" + "$ref": "#/definitions/internal_controllers.DocumentTypeEnum" }, "url": { "type": "string" @@ -3873,6 +3018,27 @@ const docTemplate = `{ } } }, + "internal_controllers.DocumentTypeEnum": { + "type": "string", + "enum": [ + "DriversLicense", + "Other", + "VehicleTitle", + "VehicleRegistration", + "VehicleInsurance", + "VehicleMaintenance", + "VehicleCustomImage" + ], + "x-enum-varnames": [ + "DriversLicense", + "Other", + "VehicleTitle", + "VehicleRegistration", + "VehicleInsurance", + "VehicleMaintenance", + "VehicleCustomImage" + ] + }, "internal_controllers.GeoFenceUserDevice": { "type": "object", "properties": { @@ -3941,7 +3107,7 @@ const docTemplate = `{ "errorCodes": { "type": "array", "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse" } }, "requestedAt": { @@ -4108,35 +3274,6 @@ const docTemplate = `{ } } }, - "internal_controllers.Offer": { - "type": "object", - "properties": { - "declineReason": { - "description": "The reason the offer was declined from the vendor", - "type": "string" - }, - "error": { - "description": "An error from the vendor (eg. when the VIN is invalid)", - "type": "string" - }, - "grade": { - "description": "The grade of the offer from the vendor (eg. \"RETAIL\")", - "type": "string" - }, - "price": { - "description": "The offer price from the vendor", - "type": "integer" - }, - "url": { - "description": "The offer URL from the vendor", - "type": "string" - }, - "vendor": { - "description": "The vendor of the offer (eg. \"carmax\", \"carvana\", etc.)", - "type": "string" - } - } - }, "internal_controllers.Privilege": { "type": "object", "properties": { @@ -4189,7 +3326,7 @@ const docTemplate = `{ "errorCodes": { "type": "array", "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse" } } } @@ -4264,7 +3401,7 @@ const docTemplate = `{ "integrationCapabilities": { "type": "array", "items": { - "$ref": "#/definitions/services.DeviceCompatibility" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility" } }, "userDeviceId": { @@ -4373,7 +3510,7 @@ const docTemplate = `{ "type": "string" }, "deviceDefinition": { - "$ref": "#/definitions/services.DeviceDefinition" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceDefinition" }, "id": { "type": "string" @@ -4385,7 +3522,7 @@ const docTemplate = `{ } }, "metadata": { - "$ref": "#/definitions/services.UserDeviceMetadata" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.UserDeviceMetadata" }, "name": { "type": "string" @@ -4465,232 +3602,6 @@ const docTemplate = `{ "math.HexOrDecimal256": { "type": "object" }, - "services.AutoPiTask": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "error": { - "type": "string" - }, - "status": { - "type": "string" - }, - "taskId": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "updates": { - "description": "Updates increments every time the job was updated.", - "type": "integer" - } - } - }, - "services.DeviceAttribute": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "services.DeviceCompatibility": { - "type": "object", - "properties": { - "capabilities": { - "type": "array", - "items": { - "type": "integer" - } - }, - "country": { - "type": "string" - }, - "id": { - "type": "string" - }, - "region": { - "type": "string" - }, - "style": { - "type": "string" - }, - "type": { - "type": "string" - }, - "vendor": { - "type": "string" - } - } - }, - "services.DeviceDefinition": { - "type": "object", - "properties": { - "compatibleIntegrations": { - "description": "CompatibleIntegrations has systems this vehicle can integrate with", - "type": "array", - "items": { - "$ref": "#/definitions/services.DeviceCompatibility" - } - }, - "deviceAttributes": { - "description": "DeviceAttributes is a list of attributes for the device type as defined in device_types.properties", - "type": "array", - "items": { - "$ref": "#/definitions/services.DeviceAttribute" - } - }, - "deviceDefinitionId": { - "type": "string" - }, - "imageUrl": { - "type": "string" - }, - "make": { - "$ref": "#/definitions/services.DeviceMake" - }, - "metadata": {}, - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/services.DeviceType" - }, - "vehicleData": { - "description": "VehicleInfo will be empty if not a vehicle type", - "$ref": "#/definitions/services.DeviceVehicleInfo" - }, - "verified": { - "type": "boolean" - } - } - }, - "services.DeviceMake": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "logo_url": { - "type": "string" - }, - "name": { - "type": "string" - }, - "oem_platform_name": { - "type": "string" - } - } - }, - "services.DeviceType": { - "type": "object", - "properties": { - "make": { - "type": "string" - }, - "model": { - "type": "string" - }, - "subModels": { - "type": "array", - "items": { - "type": "string" - } - }, - "type": { - "description": "Type is eg. Vehicle, E-bike, roomba", - "type": "string" - }, - "year": { - "type": "integer" - } - } - }, - "services.DeviceVehicleInfo": { - "type": "object", - "properties": { - "base_msrp": { - "type": "integer" - }, - "driven_wheels": { - "type": "string" - }, - "epa_class": { - "type": "string" - }, - "fuel_tank_capacity_gal": { - "type": "string" - }, - "fuel_type": { - "type": "string" - }, - "mpg": { - "type": "string" - }, - "mpg_city": { - "type": "string" - }, - "mpg_highway": { - "type": "string" - }, - "number_of_doors": { - "type": "string" - }, - "vehicle_type": { - "description": "VehicleType PASSENGER CAR, from NHTSA", - "type": "string" - } - } - }, - "services.ErrorCodesResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "P0148" - }, - "description": { - "type": "string", - "example": "Fuel delivery error" - } - } - }, - "services.UserDeviceMetadata": { - "type": "object", - "properties": { - "canProtocol": { - "description": "CANProtocol is the protocol that was detected by edge-network from the autopi.", - "type": "string" - }, - "elasticDefinitionSynced": { - "type": "boolean" - }, - "elasticRegionSynced": { - "type": "boolean" - }, - "geoDecodedCountry": { - "type": "string" - }, - "geoDecodedStateProv": { - "type": "string" - }, - "postal_code": { - "type": "string" - }, - "powertrainType": { - "type": "string" - } - } - }, "smartcar.TirePressure": { "type": "object", "properties": { @@ -4717,9 +3628,20 @@ const docTemplate = `{ "type": "string" }, "unitSystem": { - "type": "string" + "$ref": "#/definitions/smartcar.UnitSystem" } } + }, + "smartcar.UnitSystem": { + "type": "string", + "enum": [ + "metric", + "imperial" + ], + "x-enum-varnames": [ + "Metric", + "Imperial" + ] } }, "securityDefinitions": { @@ -4741,6 +3663,8 @@ var SwaggerInfo = &swag.Spec{ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index b055d7110..b5a325e59 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -65,7 +65,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiDeviceInfo" + "$ref": "#/definitions/internal_controllers.AutoPiDeviceInfo" } } } @@ -124,7 +124,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiClaimRequest" + "$ref": "#/definitions/internal_controllers.AutoPiClaimRequest" } } ], @@ -189,7 +189,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/services.AutoPiTask" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.AutoPiTask" } } } @@ -267,7 +267,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/constants.CountryInfo" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo" } } } @@ -295,7 +295,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/constants.CountryInfo" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo" } }, "400": { @@ -307,74 +307,6 @@ } } }, - "/dcn/{tokenID}": { - "get": { - "description": "retrieves the DCN NFT metadata for a given token ID address", - "produces": [ - "application/json" - ], - "tags": [ - "dcn" - ], - "parameters": [ - { - "type": "string", - "description": "DCN node id decimal representation", - "name": "tokenID", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/dcn/{tokenID}/image": { - "get": { - "description": "retrieves the DCN NFT metadata for a given token address", - "produces": [ - "image/svg+xml" - ], - "tags": [ - "dcn" - ], - "parameters": [ - { - "type": "string", - "description": "DCN node id decimal representation", - "name": "tokenID", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" - } - }, - "400": { - "description": "Bad Request" - }, - "404": { - "description": "Not Found" - } - } - } - }, "/documents": { "get": { "security": [ @@ -398,7 +330,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse" + "$ref": "#/definitions/internal_controllers.DocumentResponse" } } } @@ -453,7 +385,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse" + "$ref": "#/definitions/internal_controllers.DocumentResponse" } } } @@ -489,7 +421,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse" + "$ref": "#/definitions/internal_controllers.DocumentResponse" } } } @@ -614,105 +546,16 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponseWrapper" + "$ref": "#/definitions/internal_controllers.CompleteOAuthExchangeRequest" } } - } - } - }, - "/integrations": { - "get": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "gets list of integrations we have defined", - "produces": [ - "application/json" - ], - "tags": [ - "integrations" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/grpc.Integration" - } - } - } - } - } - }, - "/manufacturer/{tokenId}": { - "get": { - "description": "Retrieves NFT metadata for a given manufacturer.", - "produces": [ - "application/json" - ], - "tags": [ - "nfts" - ], - "parameters": [ - { - "type": "integer", - "description": "token id", - "name": "tokenId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/synthetic/device/{tokenId}": { - "get": { - "description": "Retrieves NFT metadata for a given synthetic device.", - "produces": [ - "application/json" - ], - "tags": [ - "nfts" - ], - "parameters": [ - { - "type": "integer", - "description": "token id", - "name": "tokenId", - "in": "path", - "required": true - } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/internal_controllers.NFTMetadataResp" + "$ref": "#/definitions/internal_controllers.CompleteOAuthExchangeResponseWrapper" } - }, - "404": { - "description": "Not Found" } } } @@ -744,7 +587,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDevice" + "$ref": "#/definitions/internal_controllers.RegisterUserDevice" } } ], @@ -752,7 +595,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceResponse" + "$ref": "#/definitions/internal_controllers.RegisterUserDeviceResponse" } } } @@ -844,7 +687,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest" + "$ref": "#/definitions/internal_controllers.AutoPiPairRequest" } } ], @@ -904,7 +747,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest" + "$ref": "#/definitions/internal_controllers.AutoPiPairRequest" } } ], @@ -932,7 +775,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterDeviceIntegrationRequest" + "$ref": "#/definitions/internal_controllers.RegisterDeviceIntegrationRequest" } } ], @@ -970,7 +813,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceSmartcar" + "$ref": "#/definitions/internal_controllers.RegisterUserDeviceSmartcar" } } ], @@ -978,13 +821,13 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" + "$ref": "#/definitions/internal_controllers.UserDeviceFull" } }, "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" + "$ref": "#/definitions/internal_controllers.UserDeviceFull" } }, "400": { @@ -1029,7 +872,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceVIN" + "$ref": "#/definitions/internal_controllers.RegisterUserDeviceVIN" } } ], @@ -1037,7 +880,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" + "$ref": "#/definitions/internal_controllers.UserDeviceFull" } }, "400": { @@ -1070,7 +913,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp" + "$ref": "#/definitions/internal_controllers.MyDevicesResp" } } } @@ -1094,7 +937,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp" + "$ref": "#/definitions/internal_controllers.MyDevicesResp" } } } @@ -1180,7 +1023,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MintRequest" + "$ref": "#/definitions/internal_controllers.MintRequest" } } ], @@ -1275,7 +1118,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateCountryCodeReq" + "$ref": "#/definitions/internal_controllers.UpdateCountryCodeReq" } } ], @@ -1316,7 +1159,7 @@ "404": { "description": "Vehicle not found", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } } } @@ -1359,7 +1202,7 @@ "404": { "description": "Vehicle not found", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } } } @@ -1386,13 +1229,13 @@ "404": { "description": "Vehicle not found", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } }, "429": { "description": "Last query already cleared", "schema": { - "$ref": "#/definitions/helpers.ErrorRes" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes" } } } @@ -1413,7 +1256,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceIntegrationResponse" + "$ref": "#/definitions/internal_controllers.GetUserDeviceIntegrationResponse" } } } @@ -1545,7 +1388,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1584,7 +1427,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1623,7 +1466,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1739,7 +1582,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse" + "$ref": "#/definitions/internal_controllers.CommandResponse" } } } @@ -1785,7 +1628,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandRequestStatusResp" + "$ref": "#/definitions/internal_controllers.CommandRequestStatusResp" } } } @@ -1815,7 +1658,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateNameReq" + "$ref": "#/definitions/internal_controllers.UpdateNameReq" } }, { @@ -1890,7 +1733,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateVINReq" + "$ref": "#/definitions/internal_controllers.UpdateVINReq" } }, { @@ -1933,7 +1776,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTImageData" + "$ref": "#/definitions/internal_controllers.NFTImageData" } } ], @@ -1967,7 +1810,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetGeofence" + "$ref": "#/definitions/internal_controllers.GetGeofence" } } } @@ -1999,7 +1842,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence" + "$ref": "#/definitions/internal_controllers.CreateGeofence" } } ], @@ -2007,7 +1850,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/helpers.CreateResponse" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.CreateResponse" } } } @@ -2047,7 +1890,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence" + "$ref": "#/definitions/internal_controllers.CreateGeofence" } } ], @@ -2144,6 +1987,39 @@ } } }, + "/v2/vehicles/{tokenId}/analytics/range": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "gets the estimated range for a particular user device", + "produces": [ + "application/json" + ], + "tags": [ + "user-devices" + ], + "parameters": [ + { + "type": "integer", + "description": "tokenId", + "name": "tokenId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/internal_controllers.DeviceRange" + } + } + } + } + }, "/vehicle/{tokenID}/commands/doors/lock": { "post": { "description": "Lock the device's doors.", @@ -2462,7 +2338,7 @@ "big.Int": { "type": "object" }, - "constants.CountryInfo": { + "github_com_DIMO-Network_devices-api_internal_constants.CountryInfo": { "type": "object", "properties": { "alpha_2": { @@ -2491,1032 +2367,269 @@ } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiClaimRequest": { + "github_com_DIMO-Network_devices-api_internal_controllers_helpers.CreateResponse": { "type": "object", "properties": { - "aftermarketDeviceSignature": { - "description": "AftermarketDeviceSignature is the signature from the aftermarket device.", + "id": { "type": "string" + } + } + }, + "github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes": { + "type": "object", + "properties": { + "code": { + "type": "integer" }, - "userSignature": { - "description": "UserSignature is the signature from the user, using their private key.", + "message": { "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiDeviceInfo": { + "github_com_DIMO-Network_devices-api_internal_services.AutoPiTask": { "type": "object", "properties": { - "beneficiaryAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", - "type": "array", - "items": { - "type": "integer" - } - }, - "claim": { - "description": "Claim contains the status of the on-chain claiming meta-transaction.", - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus" + "code": { + "type": "integer" }, - "deviceId": { + "description": { "type": "string" }, - "dockerReleases": { - "type": "array", - "items": { - "type": "integer" - } - }, - "ethereumAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", - "type": "array", - "items": { - "type": "integer" - } - }, - "hwRevision": { + "error": { "type": "string" }, - "isUpdated": { - "type": "boolean" - }, - "lastCommunication": { + "status": { "type": "string" }, - "manufacturer": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.ManufacturerInfo" - }, - "ownerAddress": { + "taskId": { "type": "string" }, - "pair": { - "description": "Pair contains the status of the on-chain pairing meta-transaction.", - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus" - }, - "releaseVersion": { + "updatedAt": { "type": "string" }, - "shouldUpdate": { - "type": "boolean" - }, - "template": { + "updates": { + "description": "Updates increments every time the job was updated.", "type": "integer" - }, - "tokenId": { - "$ref": "#/definitions/big.Int" - }, - "unitId": { + } + } + }, + "github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute": { + "type": "object", + "properties": { + "name": { "type": "string" }, - "unpair": { - "description": "Unpair contains the status of the on-chain unpairing meta-transaction.", - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus" + "value": { + "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility": { "type": "object", "properties": { - "aftermarketDeviceSignature": { - "description": "AftermarketDeviceSignature is the 65-byte, hex-encoded Ethereum signature of\nthe pairing payload by the device. Only needed if the vehicle owner and aftermarket\ndevice owner are not the same.", + "capabilities": { "type": "array", "items": { "type": "integer" } }, - "externalId": { + "country": { "type": "string" }, - "signature": { - "description": "AftermarketDeviceSignature is the 65-byte, hex-encoded Ethereum signature of\nthe pairing payload by the device. Only needed if the vehicle owner and aftermarket\ndevice owner are not the same.", - "type": "array", - "items": { - "type": "integer" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus": { - "type": "object", - "properties": { - "createdAt": { - "description": "CreatedAt is the timestamp of the creation of the meta-transaction.", - "type": "string", - "example": "2022-10-01T09:22:21.002Z" - }, - "hash": { - "description": "Hash is the hexidecimal transaction hash, available for any transaction at the Submitted stage or greater.", - "type": "string", - "example": "0x28b4662f1e1b15083261a4a5077664f4003d58cb528826b7aab7fad466c28e70" - }, - "status": { - "description": "Status is the state of the transaction performing this operation. There are only four options.", - "type": "string", - "enum": [ - "Unsubmitted", - "Submitted", - "Mined", - "Confirmed" - ], - "example": "Mined" - }, - "updatedAt": { - "description": "UpdatedAt is the last time we updated the status of the transaction.", - "type": "string", - "example": "2022-10-01T09:22:26.337Z" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.BurnRequest": { - "type": "object", - "required": [ - "signature" - ], - "properties": { - "signature": { - "description": "Signature is the hex encoding of the EIP-712 signature result.", - "type": "string" - }, - "tokenId": { - "$ref": "#/definitions/big.Int" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.BurnSyntheticDeviceRequest": { - "type": "object", - "properties": { - "signature": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CommandRequestStatusResp": { - "type": "object", - "properties": { - "command": { - "type": "string", - "example": "doors/unlock" - }, - "createdAt": { - "type": "string", - "example": "2022-08-09T19:38:39Z" - }, - "id": { - "type": "string", - "example": "2D8LqUHQtaMHH6LYPqznmJMBeZm" - }, - "status": { - "type": "string", - "enum": [ - "Pending", - "Complete", - "Failed" - ], - "example": "Complete" - }, - "updatedAt": { - "type": "string", - "example": "2022-08-09T19:39:22Z" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse": { - "type": "object", - "properties": { - "requestId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeRequest": { - "type": "object", - "properties": { - "authorizationCode": { - "type": "string" - }, - "redirectUri": { - "type": "string" - }, - "region": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponse": { - "type": "object", - "properties": { - "definition": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DeviceDefinition" - }, - "externalId": { - "type": "string" - }, - "vin": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponseWrapper": { - "type": "object", - "properties": { - "vehicles": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponse" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence": { - "type": "object", - "properties": { - "h3Indexes": { - "description": "required: false", - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "description": "required: true", - "type": "string" - }, - "type": { - "description": "one of following: \"PrivacyFence\", \"TriggerEntry\", \"TriggerExit\"\nrequired: true", - "type": "string" - }, - "userDeviceIds": { - "description": "Optionally link the geofence with a list of user device ID", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.DeviceDefinition": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "make": { - "type": "string" - }, - "model": { - "type": "string" - }, - "year": { - "type": "integer" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.DeviceRange": { - "type": "object", - "properties": { - "rangeSets": { - "description": "Contains a list of range sets, one for each range basis (may be empty)", - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RangeSet" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.DeviceSnapshot": { - "type": "object", - "properties": { - "ambientTemp": { - "type": "number" - }, - "batteryCapacity": { - "type": "integer" - }, - "batteryVoltage": { - "type": "number" - }, - "chargeLimit": { - "type": "number" - }, - "charging": { - "type": "boolean" - }, - "fuelPercentRemaining": { - "type": "number" - }, - "latitude": { - "type": "number" - }, - "longitude": { - "type": "number" - }, - "odometer": { - "type": "number" - }, - "oil": { - "type": "number" - }, - "range": { - "type": "number" - }, - "recordCreatedAt": { - "type": "string" - }, - "recordUpdatedAt": { - "type": "string" - }, - "soc": { - "type": "number" - }, - "tirePressure": { - "$ref": "#/definitions/smartcar.TirePressure" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "ext": { - "type": "string" - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "url": { - "type": "string" - }, - "userDeviceId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GeoFenceUserDevice": { - "type": "object", - "properties": { - "mmy": { - "type": "string" - }, - "name": { - "type": "string" - }, - "userDeviceId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetGeofence": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "h3Indexes": { - "type": "array", - "items": { - "type": "string" - } - }, - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "userDevices": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GeoFenceUserDevice" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponse": { - "type": "object", - "properties": { - "queries": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponseItem" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponseItem": { - "type": "object", - "properties": { - "clearedAt": { - "description": "ClearedAt is the time at which the user cleared the codes from this query.\nMay be null.", - "type": "string", - "example": "2023-05-23T12:57:05Z" - }, - "errorCodes": { - "type": "array", - "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" - } - }, - "requestedAt": { - "type": "string", - "example": "2023-05-23T12:56:36Z" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceIntegrationResponse": { - "type": "object", - "properties": { - "createdAt": { - "description": "CreatedAt is the creation time of this integration for this device.", - "type": "string" - }, - "externalId": { - "description": "ExternalID is the identifier used by the third party for the device. It may be absent if we\nhaven't authorized yet.", - "type": "string" - }, - "status": { - "description": "Status is one of \"Pending\", \"PendingFirstData\", \"Active\", \"Failed\", \"DuplicateIntegration\".", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.ManufacturerInfo": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "tokenId": { - "$ref": "#/definitions/big.Int" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.MintRequest": { - "type": "object", - "required": [ - "imageData", - "signature" - ], - "properties": { - "imageData": { - "description": "ImageData contains the base64-encoded NFT PNG image.", - "type": "string" - }, - "imageDataTransparent": { - "description": "ImageDataTransparent contains the base64-encoded NFT PNG image\nwith a transparent background, for use in the app. For compatibility\nwith older versions it is not required.", - "type": "string" - }, - "signature": { - "description": "Signature is the hex encoding of the EIP-712 signature result.", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.MintSyntheticDeviceRequest": { - "type": "object", - "properties": { - "signature": { - "type": "string", - "example": "0xc565d38982e1a5004efb5ee390fba0a08bb5e72b3f3e91094c66bc395c324f785425d58d5c1a601372d9c16164e380c63e89f1e0ea95fdefdf7b2854c4f938e81b" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp": { - "type": "object", - "properties": { - "sharedDevices": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" - } - }, - "userDevices": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTAttribute": { - "type": "object", - "properties": { - "trait_type": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTData": { - "type": "object", - "properties": { - "ownerAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", - "type": "array", - "items": { - "type": "integer" - } - }, - "status": { - "description": "Status is the minting status of the NFT.", - "type": "string", - "enum": [ - "Unstarted", - "Submitted", - "Mined", - "Confirmed" - ], - "example": "Confirmed" - }, - "tokenId": { - "type": "number", - "example": 37 - }, - "tokenUri": { - "type": "string", - "example": "https://nft.dimo.zone/37" - }, - "txHash": { - "description": "TxHash is the hash of the minting transaction.", - "type": "string", - "example": "0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTImageData": { - "type": "object", - "required": [ - "imageData" - ], - "properties": { - "imageData": { - "description": "ImageData contains the base64-encoded NFT PNG image.", - "type": "string" - }, - "imageDataTransparent": { - "description": "ImageDataTransparent contains the base64-encoded NFT PNG image\nwith a transparent background, for use in the app. For compatibility\nwith older versions it is not required.", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.NFTMetadataResp": { - "type": "object", - "properties": { - "attributes": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTAttribute" - } - }, - "description": { - "type": "string" - }, - "image": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.Offer": { - "type": "object", - "properties": { - "declineReason": { - "description": "The reason the offer was declined from the vendor", - "type": "string" - }, - "error": { - "description": "An error from the vendor (eg. when the VIN is invalid)", - "type": "string" - }, - "grade": { - "description": "The grade of the offer from the vendor (eg. \"RETAIL\")", - "type": "string" - }, - "price": { - "description": "The offer price from the vendor", - "type": "integer" - }, - "url": { - "description": "The offer URL from the vendor", - "type": "string" - }, - "vendor": { - "description": "The vendor of the offer (eg. \"carmax\", \"carvana\", etc.)", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.Privilege": { - "type": "object", - "properties": { - "expiry": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "updatedAt": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.PrivilegeUser": { - "type": "object", - "properties": { - "address": { - "type": "string" - }, - "privileges": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.Privilege" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.QueryDeviceErrorCodesReq": { - "type": "object", - "properties": { - "errorCodes": { - "type": "array", - "items": { - "type": "string" - }, - "example": [ - "P0106", - "P0279" - ] - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.QueryDeviceErrorCodesResponse": { - "type": "object", - "properties": { - "clearedAt": { - "type": "string" - }, - "errorCodes": { - "type": "array", - "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" - } - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RangeSet": { - "type": "object", - "properties": { - "rangeBasis": { - "description": "The basis for the range calculation (eg. \"MPG\" or \"MPG Highway\")", - "type": "string" - }, - "rangeDistance": { - "description": "The estimated range distance", - "type": "integer" - }, - "rangeUnit": { - "description": "The unit used for the rangeDistance (eg. \"miles\" or \"kilometers\")", - "type": "string" - }, - "updated": { - "description": "The time the data was collected", - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterDeviceIntegrationRequest": { - "type": "object", - "properties": { - "accessToken": { - "type": "string" - }, - "code": { - "description": "Code is an OAuth authorization code. Not used in all integrations.", - "type": "string" - }, - "expiresIn": { - "type": "integer" - }, - "externalId": { - "description": "ExternalID is the only field needed for AutoPi registrations. It is the UnitID.", + "id": { "type": "string" }, - "redirectURI": { - "description": "RedirectURI is the OAuth redirect URI used by the frontend. Not used in all integrations.", + "region": { "type": "string" }, - "refreshToken": { + "style": { "type": "string" }, - "version": { - "type": "integer" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDevice": { - "type": "object", - "properties": { - "countryCode": { + "type": { "type": "string" }, - "deviceDefinitionId": { + "vendor": { "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceResponse": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceDefinition": { "type": "object", "properties": { - "deviceDefinitionId": { - "type": "string" - }, - "integrationCapabilities": { + "compatibleIntegrations": { + "description": "CompatibleIntegrations has systems this vehicle can integrate with", "type": "array", "items": { - "$ref": "#/definitions/services.DeviceCompatibility" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility" } }, - "userDeviceId": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceSmartcar": { - "type": "object", - "properties": { - "code": { - "description": "Code refers to the auth code provided by smartcar when user logs in", - "type": "string" + "deviceAttributes": { + "description": "DeviceAttributes is a list of attributes for the device type as defined in device_types.properties", + "type": "array", + "items": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute" + } }, - "countryCode": { + "deviceDefinitionId": { "type": "string" }, - "redirectURI": { - "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceVIN": { - "type": "object", - "properties": { - "canProtocol": { - "description": "CANProtocol is the protocol that was detected by edge-network from the autopi.", + "imageUrl": { "type": "string" }, - "countryCode": { - "type": "string" + "make": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceMake" }, - "vin": { + "metadata": {}, + "name": { "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.SyntheticDeviceStatus": { - "type": "object", - "properties": { - "address": { - "type": "string", - "example": "0xAED7EA8035eEc47E657B34eF5D020c7005487443" }, - "status": { - "type": "string", - "enum": [ - "Unstarted", - "Submitted", - "Mined", - "Confirmed" - ], - "example": "Confirmed" + "type": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceType" }, - "tokenId": { - "type": "number", - "example": 15 + "vehicleData": { + "description": "VehicleInfo will be empty if not a vehicle type", + "allOf": [ + { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceVehicleInfo" + } + ] }, - "txHash": { - "type": "string", - "example": "0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e" + "verified": { + "type": "boolean" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.UpdateCountryCodeReq": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceMake": { "type": "object", "properties": { - "countryCode": { + "id": { "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.UpdateNameReq": { - "type": "object", - "properties": { + }, + "logo_url": { + "type": "string" + }, "name": { "type": "string" - } - } - }, - "github.com_DIMO-Network_devices-api_internal_controllers.UpdateVINReq": { - "type": "object", - "required": [ - "vin" - ], - "properties": { - "signature": { - "description": "Signature is the hex-encoded result of the AutoPi signing the VIN. It must\nbe present to verify the VIN.", - "type": "string", - "example": "16b15f88bbd2e0a22d1d0084b8b7080f2003ea83eab1a00f80d8c18446c9c1b6224f17aa09eaf167717ca4f355bb6dc94356e037edf3adf6735a86fc3741f5231b" }, - "vin": { - "description": "VIN is a vehicle identification number. At the very least, it must be\n17 characters in length and contain only letters and numbers.", - "type": "string", - "example": "4Y1SL65848Z411439" + "oem_platform_name": { + "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceType": { "type": "object", "properties": { - "countryCode": { - "type": "string" - }, - "customImageUrl": { - "type": "string" - }, - "deviceDefinition": { - "$ref": "#/definitions/services.DeviceDefinition" - }, - "id": { - "type": "string" - }, - "integrations": { - "type": "array", - "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceIntegrationStatus" - } - }, - "metadata": { - "$ref": "#/definitions/services.UserDeviceMetadata" - }, - "name": { + "make": { "type": "string" }, - "nft": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTData" - }, - "optedInAt": { + "model": { "type": "string" }, - "privilegedUsers": { + "subModels": { "type": "array", "items": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.PrivilegeUser" + "type": "string" } }, - "vin": { + "type": { + "description": "Type is eg. Vehicle, E-bike, roomba", "type": "string" }, - "vinConfirmed": { - "type": "boolean" - }, - "vinCredential": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.VINCredentialData" + "year": { + "type": "integer" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceIntegrationStatus": { + "github_com_DIMO-Network_devices-api_internal_services.DeviceVehicleInfo": { "type": "object", "properties": { - "createdAt": { + "base_msrp": { + "type": "integer" + }, + "driven_wheels": { "type": "string" }, - "externalId": { + "epa_class": { "type": "string" }, - "integrationId": { + "fuel_tank_capacity_gal": { "type": "string" }, - "integrationVendor": { + "fuel_type": { "type": "string" }, - "metadata": { + "mpg": { "type": "string" }, - "status": { + "mpg_city": { "type": "string" }, - "syntheticDevice": { - "$ref": "#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.SyntheticDeviceStatus" + "mpg_highway": { + "type": "string" }, - "tokenId": { - "$ref": "#/definitions/big.Int" + "number_of_doors": { + "type": "string" }, - "updatedAt": { + "vehicle_type": { + "description": "VehicleType PASSENGER CAR, from NHTSA", "type": "string" } } }, - "github.com_DIMO-Network_devices-api_internal_controllers.VINCredentialData": { + "github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse": { "type": "object", "properties": { - "expiresAt": { - "type": "string" - }, - "issuedAt": { - "type": "string" - }, - "valid": { - "type": "boolean" + "code": { + "type": "string", + "example": "P0148" }, - "vin": { - "type": "string" + "description": { + "type": "string", + "example": "Fuel delivery error" } } }, - "grpc.Integration": { + "github_com_DIMO-Network_devices-api_internal_services.PowertrainType": { + "type": "string", + "enum": [ + "ICE", + "HEV", + "PHEV", + "BEV", + "FCEV" + ], + "x-enum-varnames": [ + "ICE", + "HEV", + "PHEV", + "BEV", + "FCEV" + ] + }, + "github_com_DIMO-Network_devices-api_internal_services.UserDeviceMetadata": { "type": "object", "properties": { - "auto_pi_default_template_id": { - "type": "integer" - }, - "auto_pi_powertrain_template": { - "$ref": "#/definitions/grpc.Integration_AutoPiPowertrainTemplate" - }, - "id": { - "type": "string" - }, - "manufacturer_token_id": { - "type": "integer" - }, - "points": { - "type": "integer" - }, - "refresh_limit_secs": { - "type": "integer" - }, - "style": { + "canProtocol": { + "description": "CANProtocol is the protocol that was detected by edge-network from the autopi.", "type": "string" }, - "token_id": { - "description": "token_id can have a 0 value, which means it has not yet been minted and no token id has been assigned. This case should be checked for and handled.", - "type": "integer" + "elasticDefinitionSynced": { + "type": "boolean" }, - "type": { - "type": "string" + "elasticRegionSynced": { + "type": "boolean" }, - "vendor": { + "geoDecodedCountry": { "type": "string" - } - } - }, - "grpc.Integration_AutoPiPowertrainTemplate": { - "type": "object", - "properties": { - "BEV": { - "type": "integer" - }, - "HEV": { - "type": "integer" - }, - "ICE": { - "type": "integer" }, - "PHEV": { - "type": "integer" - } - } - }, - "helpers.CreateResponse": { - "type": "object", - "properties": { - "id": { + "geoDecodedStateProv": { "type": "string" - } - } - }, - "helpers.ErrorRes": { - "type": "object", - "properties": { - "code": { - "type": "integer" }, - "message": { + "postal_code": { "type": "string" + }, + "powertrainType": { + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.PowertrainType" } } }, @@ -3537,7 +2650,6 @@ "type": "object", "properties": { "beneficiaryAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", "type": "array", "items": { "type": "integer" @@ -3545,7 +2657,11 @@ }, "claim": { "description": "Claim contains the status of the on-chain claiming meta-transaction.", - "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + "allOf": [ + { + "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + } + ] }, "deviceId": { "type": "string" @@ -3557,7 +2673,6 @@ } }, "ethereumAddress": { - "description": "OwnerAddress is the Ethereum address of the NFT owner.", "type": "array", "items": { "type": "integer" @@ -3580,7 +2695,11 @@ }, "pair": { "description": "Pair contains the status of the on-chain pairing meta-transaction.", - "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + "allOf": [ + { + "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + } + ] }, "releaseVersion": { "type": "string" @@ -3599,7 +2718,11 @@ }, "unpair": { "description": "Unpair contains the status of the on-chain unpairing meta-transaction.", - "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + "allOf": [ + { + "$ref": "#/definitions/internal_controllers.AutoPiTransactionStatus" + } + ] } } }, @@ -3877,7 +3000,7 @@ "type": "string" }, "type": { - "type": "string" + "$ref": "#/definitions/internal_controllers.DocumentTypeEnum" }, "url": { "type": "string" @@ -3887,6 +3010,27 @@ } } }, + "internal_controllers.DocumentTypeEnum": { + "type": "string", + "enum": [ + "DriversLicense", + "Other", + "VehicleTitle", + "VehicleRegistration", + "VehicleInsurance", + "VehicleMaintenance", + "VehicleCustomImage" + ], + "x-enum-varnames": [ + "DriversLicense", + "Other", + "VehicleTitle", + "VehicleRegistration", + "VehicleInsurance", + "VehicleMaintenance", + "VehicleCustomImage" + ] + }, "internal_controllers.GeoFenceUserDevice": { "type": "object", "properties": { @@ -3955,7 +3099,7 @@ "errorCodes": { "type": "array", "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse" } }, "requestedAt": { @@ -4122,35 +3266,6 @@ } } }, - "internal_controllers.Offer": { - "type": "object", - "properties": { - "declineReason": { - "description": "The reason the offer was declined from the vendor", - "type": "string" - }, - "error": { - "description": "An error from the vendor (eg. when the VIN is invalid)", - "type": "string" - }, - "grade": { - "description": "The grade of the offer from the vendor (eg. \"RETAIL\")", - "type": "string" - }, - "price": { - "description": "The offer price from the vendor", - "type": "integer" - }, - "url": { - "description": "The offer URL from the vendor", - "type": "string" - }, - "vendor": { - "description": "The vendor of the offer (eg. \"carmax\", \"carvana\", etc.)", - "type": "string" - } - } - }, "internal_controllers.Privilege": { "type": "object", "properties": { @@ -4203,7 +3318,7 @@ "errorCodes": { "type": "array", "items": { - "$ref": "#/definitions/services.ErrorCodesResponse" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse" } } } @@ -4278,7 +3393,7 @@ "integrationCapabilities": { "type": "array", "items": { - "$ref": "#/definitions/services.DeviceCompatibility" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility" } }, "userDeviceId": { @@ -4387,7 +3502,7 @@ "type": "string" }, "deviceDefinition": { - "$ref": "#/definitions/services.DeviceDefinition" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceDefinition" }, "id": { "type": "string" @@ -4399,7 +3514,7 @@ } }, "metadata": { - "$ref": "#/definitions/services.UserDeviceMetadata" + "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_services.UserDeviceMetadata" }, "name": { "type": "string" @@ -4479,232 +3594,6 @@ "math.HexOrDecimal256": { "type": "object" }, - "services.AutoPiTask": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "error": { - "type": "string" - }, - "status": { - "type": "string" - }, - "taskId": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "updates": { - "description": "Updates increments every time the job was updated.", - "type": "integer" - } - } - }, - "services.DeviceAttribute": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - }, - "services.DeviceCompatibility": { - "type": "object", - "properties": { - "capabilities": { - "type": "array", - "items": { - "type": "integer" - } - }, - "country": { - "type": "string" - }, - "id": { - "type": "string" - }, - "region": { - "type": "string" - }, - "style": { - "type": "string" - }, - "type": { - "type": "string" - }, - "vendor": { - "type": "string" - } - } - }, - "services.DeviceDefinition": { - "type": "object", - "properties": { - "compatibleIntegrations": { - "description": "CompatibleIntegrations has systems this vehicle can integrate with", - "type": "array", - "items": { - "$ref": "#/definitions/services.DeviceCompatibility" - } - }, - "deviceAttributes": { - "description": "DeviceAttributes is a list of attributes for the device type as defined in device_types.properties", - "type": "array", - "items": { - "$ref": "#/definitions/services.DeviceAttribute" - } - }, - "deviceDefinitionId": { - "type": "string" - }, - "imageUrl": { - "type": "string" - }, - "make": { - "$ref": "#/definitions/services.DeviceMake" - }, - "metadata": {}, - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/services.DeviceType" - }, - "vehicleData": { - "description": "VehicleInfo will be empty if not a vehicle type", - "$ref": "#/definitions/services.DeviceVehicleInfo" - }, - "verified": { - "type": "boolean" - } - } - }, - "services.DeviceMake": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "logo_url": { - "type": "string" - }, - "name": { - "type": "string" - }, - "oem_platform_name": { - "type": "string" - } - } - }, - "services.DeviceType": { - "type": "object", - "properties": { - "make": { - "type": "string" - }, - "model": { - "type": "string" - }, - "subModels": { - "type": "array", - "items": { - "type": "string" - } - }, - "type": { - "description": "Type is eg. Vehicle, E-bike, roomba", - "type": "string" - }, - "year": { - "type": "integer" - } - } - }, - "services.DeviceVehicleInfo": { - "type": "object", - "properties": { - "base_msrp": { - "type": "integer" - }, - "driven_wheels": { - "type": "string" - }, - "epa_class": { - "type": "string" - }, - "fuel_tank_capacity_gal": { - "type": "string" - }, - "fuel_type": { - "type": "string" - }, - "mpg": { - "type": "string" - }, - "mpg_city": { - "type": "string" - }, - "mpg_highway": { - "type": "string" - }, - "number_of_doors": { - "type": "string" - }, - "vehicle_type": { - "description": "VehicleType PASSENGER CAR, from NHTSA", - "type": "string" - } - } - }, - "services.ErrorCodesResponse": { - "type": "object", - "properties": { - "code": { - "type": "string", - "example": "P0148" - }, - "description": { - "type": "string", - "example": "Fuel delivery error" - } - } - }, - "services.UserDeviceMetadata": { - "type": "object", - "properties": { - "canProtocol": { - "description": "CANProtocol is the protocol that was detected by edge-network from the autopi.", - "type": "string" - }, - "elasticDefinitionSynced": { - "type": "boolean" - }, - "elasticRegionSynced": { - "type": "boolean" - }, - "geoDecodedCountry": { - "type": "string" - }, - "geoDecodedStateProv": { - "type": "string" - }, - "postal_code": { - "type": "string" - }, - "powertrainType": { - "type": "string" - } - } - }, "smartcar.TirePressure": { "type": "object", "properties": { @@ -4731,9 +3620,20 @@ "type": "string" }, "unitSystem": { - "type": "string" + "$ref": "#/definitions/smartcar.UnitSystem" } } + }, + "smartcar.UnitSystem": { + "type": "string", + "enum": [ + "metric", + "imperial" + ], + "x-enum-varnames": [ + "Metric", + "Imperial" + ] } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 20c4b22ac..e0cb70e8d 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -42,7 +42,7 @@ definitions: type: object big.Int: type: object - constants.CountryInfo: + github_com_DIMO-Network_devices-api_internal_constants.CountryInfo: properties: alpha_2: type: string @@ -61,727 +61,186 @@ definitions: sub_region_code: type: integer type: object - github.com_DIMO-Network_devices-api_internal_controllers.AutoPiClaimRequest: + github_com_DIMO-Network_devices-api_internal_controllers_helpers.CreateResponse: properties: - aftermarketDeviceSignature: - description: AftermarketDeviceSignature is the signature from the aftermarket - device. - type: string - userSignature: - description: UserSignature is the signature from the user, using their private - key. - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.AutoPiDeviceInfo: - properties: - beneficiaryAddress: - description: OwnerAddress is the Ethereum address of the NFT owner. - items: - type: integer - type: array - claim: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus' - description: Claim contains the status of the on-chain claiming meta-transaction. - deviceId: - type: string - dockerReleases: - items: - type: integer - type: array - ethereumAddress: - description: OwnerAddress is the Ethereum address of the NFT owner. - items: - type: integer - type: array - hwRevision: - type: string - isUpdated: - type: boolean - lastCommunication: - type: string - manufacturer: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.ManufacturerInfo' - ownerAddress: - type: string - pair: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus' - description: Pair contains the status of the on-chain pairing meta-transaction. - releaseVersion: - type: string - shouldUpdate: - type: boolean - template: - type: integer - tokenId: - $ref: '#/definitions/big.Int' - unitId: - type: string - unpair: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus' - description: Unpair contains the status of the on-chain unpairing meta-transaction. - type: object - github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest: - properties: - aftermarketDeviceSignature: - description: |- - AftermarketDeviceSignature is the 65-byte, hex-encoded Ethereum signature of - the pairing payload by the device. Only needed if the vehicle owner and aftermarket - device owner are not the same. - items: - type: integer - type: array - externalId: - type: string - signature: - description: |- - AftermarketDeviceSignature is the 65-byte, hex-encoded Ethereum signature of - the pairing payload by the device. Only needed if the vehicle owner and aftermarket - device owner are not the same. - items: - type: integer - type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.AutoPiTransactionStatus: - properties: - createdAt: - description: CreatedAt is the timestamp of the creation of the meta-transaction. - example: "2022-10-01T09:22:21.002Z" - type: string - hash: - description: Hash is the hexidecimal transaction hash, available for any transaction - at the Submitted stage or greater. - example: 0x28b4662f1e1b15083261a4a5077664f4003d58cb528826b7aab7fad466c28e70 - type: string - status: - description: Status is the state of the transaction performing this operation. - There are only four options. - enum: - - Unsubmitted - - Submitted - - Mined - - Confirmed - example: Mined - type: string - updatedAt: - description: UpdatedAt is the last time we updated the status of the transaction. - example: "2022-10-01T09:22:26.337Z" - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.BurnRequest: - properties: - signature: - description: Signature is the hex encoding of the EIP-712 signature result. - type: string - tokenId: - $ref: '#/definitions/big.Int' - required: - - signature - type: object - github.com_DIMO-Network_devices-api_internal_controllers.BurnSyntheticDeviceRequest: - properties: - signature: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.CommandRequestStatusResp: - properties: - command: - example: doors/unlock - type: string - createdAt: - example: "2022-08-09T19:38:39Z" - type: string - id: - example: 2D8LqUHQtaMHH6LYPqznmJMBeZm - type: string - status: - enum: - - Pending - - Complete - - Failed - example: Complete - type: string - updatedAt: - example: "2022-08-09T19:39:22Z" - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse: - properties: - requestId: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeRequest: - properties: - authorizationCode: - type: string - redirectUri: - type: string - region: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponse: - properties: - definition: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DeviceDefinition' - externalId: - type: string - vin: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponseWrapper: - properties: - vehicles: - items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponse' - type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence: - properties: - h3Indexes: - description: 'required: false' - items: - type: string - type: array - name: - description: 'required: true' - type: string - type: - description: |- - one of following: "PrivacyFence", "TriggerEntry", "TriggerExit" - required: true - type: string - userDeviceIds: - description: Optionally link the geofence with a list of user device ID - items: - type: string - type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.DeviceDefinition: - properties: - id: - type: string - make: - type: string - model: - type: string - year: - type: integer - type: object - github.com_DIMO-Network_devices-api_internal_controllers.DeviceSnapshot: - properties: - ambientTemp: - type: number - batteryCapacity: - type: integer - batteryVoltage: - type: number - chargeLimit: - type: number - charging: - type: boolean - fuelPercentRemaining: - type: number - latitude: - type: number - longitude: - type: number - odometer: - type: number - oil: - type: number - range: - type: number - recordCreatedAt: - type: string - recordUpdatedAt: - type: string - soc: - type: number - tirePressure: - $ref: '#/definitions/smartcar.TirePressure' - type: object - github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse: - properties: - createdAt: - type: string - ext: - type: string - id: - type: string - name: - type: string - type: - type: string - url: - type: string - userDeviceId: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.GeoFenceUserDevice: - properties: - mmy: - type: string - name: - type: string - userDeviceId: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.GetGeofence: - properties: - createdAt: - type: string - h3Indexes: - items: - type: string - type: array - id: - type: string - name: - type: string - type: - type: string - updatedAt: - type: string - userDevices: - items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GeoFenceUserDevice' - type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponse: - properties: - queries: - items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponseItem' - type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceErrorCodeQueriesResponseItem: - properties: - clearedAt: - description: |- - ClearedAt is the time at which the user cleared the codes from this query. - May be null. - example: "2023-05-23T12:57:05Z" - type: string - errorCodes: - items: - $ref: '#/definitions/services.ErrorCodesResponse' - type: array - requestedAt: - example: "2023-05-23T12:56:36Z" - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceIntegrationResponse: - properties: - createdAt: - description: CreatedAt is the creation time of this integration for this device. - type: string - externalId: - description: |- - ExternalID is the identifier used by the third party for the device. It may be absent if we - haven't authorized yet. - type: string - status: - description: Status is one of "Pending", "PendingFirstData", "Active", "Failed", - "DuplicateIntegration". - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.ManufacturerInfo: - properties: - name: - type: string - tokenId: - $ref: '#/definitions/big.Int' - type: object - github.com_DIMO-Network_devices-api_internal_controllers.MintRequest: - properties: - imageData: - description: ImageData contains the base64-encoded NFT PNG image. - type: string - imageDataTransparent: - description: |- - ImageDataTransparent contains the base64-encoded NFT PNG image - with a transparent background, for use in the app. For compatibility - with older versions it is not required. - type: string - signature: - description: Signature is the hex encoding of the EIP-712 signature result. + id: type: string - required: - - imageData - - signature type: object - github.com_DIMO-Network_devices-api_internal_controllers.MintSyntheticDeviceRequest: + github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes: properties: - signature: - example: 0xc565d38982e1a5004efb5ee390fba0a08bb5e72b3f3e91094c66bc395c324f785425d58d5c1a601372d9c16164e380c63e89f1e0ea95fdefdf7b2854c4f938e81b + code: + type: integer + message: type: string type: object - github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp: - properties: - sharedDevices: - items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull' - type: array - userDevices: - items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull' - type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.NFTAttribute: + github_com_DIMO-Network_devices-api_internal_services.AutoPiTask: properties: - trait_type: + code: + type: integer + description: type: string - value: + error: type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.NFTData: - properties: - ownerAddress: - description: OwnerAddress is the Ethereum address of the NFT owner. - items: - type: integer - type: array status: - description: Status is the minting status of the NFT. - enum: - - Unstarted - - Submitted - - Mined - - Confirmed - example: Confirmed type: string - tokenId: - example: 37 - type: number - tokenUri: - example: https://nft.dimo.zone/37 + taskId: type: string - txHash: - description: TxHash is the hash of the minting transaction. - example: 0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e + updatedAt: type: string + updates: + description: Updates increments every time the job was updated. + type: integer type: object - github.com_DIMO-Network_devices-api_internal_controllers.NFTImageData: + github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute: properties: - imageData: - description: ImageData contains the base64-encoded NFT PNG image. + name: type: string - imageDataTransparent: - description: |- - ImageDataTransparent contains the base64-encoded NFT PNG image - with a transparent background, for use in the app. For compatibility - with older versions it is not required. + value: type: string - required: - - imageData type: object - github.com_DIMO-Network_devices-api_internal_controllers.NFTMetadataResp: + github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility: properties: - attributes: + capabilities: items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTAttribute' + type: integer type: array - description: - type: string - image: - type: string - name: + country: type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.Offer: - properties: - declineReason: - description: The reason the offer was declined from the vendor + id: type: string - error: - description: An error from the vendor (eg. when the VIN is invalid) + region: type: string - grade: - description: The grade of the offer from the vendor (eg. "RETAIL") + style: type: string - price: - description: The offer price from the vendor - type: integer - url: - description: The offer URL from the vendor + type: type: string vendor: - description: The vendor of the offer (eg. "carmax", "carvana", etc.) - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.Privilege: - properties: - expiry: - type: string - id: - type: integer - updatedAt: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.PrivilegeUser: - properties: - address: type: string - privileges: - items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.Privilege' - type: array type: object - github.com_DIMO-Network_devices-api_internal_controllers.QueryDeviceErrorCodesReq: + github_com_DIMO-Network_devices-api_internal_services.DeviceDefinition: properties: - errorCodes: - example: - - P0106 - - P0279 + compatibleIntegrations: + description: CompatibleIntegrations has systems this vehicle can integrate + with items: - type: string + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility' type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.QueryDeviceErrorCodesResponse: - properties: - clearedAt: - type: string - errorCodes: + deviceAttributes: + description: DeviceAttributes is a list of attributes for the device type + as defined in device_types.properties items: - $ref: '#/definitions/services.ErrorCodesResponse' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceAttribute' type: array - type: object - github.com_DIMO-Network_devices-api_internal_controllers.RangeSet: - properties: - rangeBasis: - description: The basis for the range calculation (eg. "MPG" or "MPG Highway") - type: string - rangeDistance: - description: The estimated range distance - type: integer - rangeUnit: - description: The unit used for the rangeDistance (eg. "miles" or "kilometers") - type: string - updated: - description: The time the data was collected - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.RegisterDeviceIntegrationRequest: - properties: - accessToken: - type: string - code: - description: Code is an OAuth authorization code. Not used in all integrations. - type: string - expiresIn: - type: integer - externalId: - description: ExternalID is the only field needed for AutoPi registrations. - It is the UnitID. - type: string - redirectURI: - description: RedirectURI is the OAuth redirect URI used by the frontend. Not - used in all integrations. - type: string - refreshToken: - type: string - version: - type: integer - type: object - github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDevice: - properties: - countryCode: - type: string - deviceDefinitionId: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceResponse: - properties: deviceDefinitionId: type: string - integrationCapabilities: - items: - $ref: '#/definitions/services.DeviceCompatibility' - type: array - userDeviceId: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceSmartcar: - properties: - code: - description: Code refers to the auth code provided by smartcar when user logs - in - type: string - countryCode: - type: string - redirectURI: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceVIN: - properties: - canProtocol: - description: CANProtocol is the protocol that was detected by edge-network - from the autopi. - type: string - countryCode: - type: string - vin: - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.SyntheticDeviceStatus: - properties: - address: - example: 0xAED7EA8035eEc47E657B34eF5D020c7005487443 - type: string - status: - enum: - - Unstarted - - Submitted - - Mined - - Confirmed - example: Confirmed - type: string - tokenId: - example: 15 - type: number - txHash: - example: 0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e - type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.UpdateCountryCodeReq: - properties: - countryCode: + imageUrl: type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.UpdateNameReq: - properties: + make: + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceMake' + metadata: {} name: type: string + type: + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceType' + vehicleData: + allOf: + - $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceVehicleInfo' + description: VehicleInfo will be empty if not a vehicle type + verified: + type: boolean type: object - github.com_DIMO-Network_devices-api_internal_controllers.UpdateVINReq: - properties: - signature: - description: |- - Signature is the hex-encoded result of the AutoPi signing the VIN. It must - be present to verify the VIN. - example: 16b15f88bbd2e0a22d1d0084b8b7080f2003ea83eab1a00f80d8c18446c9c1b6224f17aa09eaf167717ca4f355bb6dc94356e037edf3adf6735a86fc3741f5231b - type: string - vin: - description: |- - VIN is a vehicle identification number. At the very least, it must be - 17 characters in length and contain only letters and numbers. - example: 4Y1SL65848Z411439 - type: string - required: - - vin - type: object - github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull: + github_com_DIMO-Network_devices-api_internal_services.DeviceMake: properties: - countryCode: - type: string - customImageUrl: - type: string - deviceDefinition: - $ref: '#/definitions/services.DeviceDefinition' id: type: string - integrations: - items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceIntegrationStatus' - type: array - metadata: - $ref: '#/definitions/services.UserDeviceMetadata' + logo_url: + type: string name: type: string - nft: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTData' - optedInAt: + oem_platform_name: type: string - privilegedUsers: + type: object + github_com_DIMO-Network_devices-api_internal_services.DeviceType: + properties: + make: + type: string + model: + type: string + subModels: items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.PrivilegeUser' + type: string type: array - vin: + type: + description: Type is eg. Vehicle, E-bike, roomba type: string - vinConfirmed: - type: boolean - vinCredential: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.VINCredentialData' + year: + type: integer type: object - github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceIntegrationStatus: + github_com_DIMO-Network_devices-api_internal_services.DeviceVehicleInfo: properties: - createdAt: - type: string - externalId: + base_msrp: + type: integer + driven_wheels: type: string - integrationId: + epa_class: type: string - integrationVendor: + fuel_tank_capacity_gal: type: string - metadata: + fuel_type: type: string - status: + mpg: type: string - syntheticDevice: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.SyntheticDeviceStatus' - tokenId: - $ref: '#/definitions/big.Int' - updatedAt: + mpg_city: type: string - type: object - github.com_DIMO-Network_devices-api_internal_controllers.VINCredentialData: - properties: - expiresAt: + mpg_highway: type: string - issuedAt: + number_of_doors: type: string - valid: - type: boolean - vin: + vehicle_type: + description: VehicleType PASSENGER CAR, from NHTSA type: string type: object - grpc.Integration: + github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse: properties: - auto_pi_default_template_id: - type: integer - auto_pi_powertrain_template: - $ref: '#/definitions/grpc.Integration_AutoPiPowertrainTemplate' - id: - type: string - manufacturer_token_id: - type: integer - points: - type: integer - refresh_limit_secs: - type: integer - style: - type: string - token_id: - description: token_id can have a 0 value, which means it has not yet been - minted and no token id has been assigned. This case should be checked for - and handled. - type: integer - type: + code: + example: P0148 type: string - vendor: + description: + example: Fuel delivery error type: string type: object - grpc.Integration_AutoPiPowertrainTemplate: - properties: - BEV: - type: integer - HEV: - type: integer - ICE: - type: integer - PHEV: - type: integer - type: object - helpers.CreateResponse: + github_com_DIMO-Network_devices-api_internal_services.PowertrainType: + enum: + - ICE + - HEV + - PHEV + - BEV + - FCEV + type: string + x-enum-varnames: + - ICE + - HEV + - PHEV + - BEV + - FCEV + github_com_DIMO-Network_devices-api_internal_services.UserDeviceMetadata: properties: - id: + canProtocol: + description: CANProtocol is the protocol that was detected by edge-network + from the autopi. type: string - type: object - helpers.ErrorRes: - properties: - code: - type: integer - message: + elasticDefinitionSynced: + type: boolean + elasticRegionSynced: + type: boolean + geoDecodedCountry: type: string + geoDecodedStateProv: + type: string + postal_code: + type: string + powertrainType: + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.PowertrainType' type: object internal_controllers.AutoPiClaimRequest: properties: @@ -797,12 +256,12 @@ definitions: internal_controllers.AutoPiDeviceInfo: properties: beneficiaryAddress: - description: OwnerAddress is the Ethereum address of the NFT owner. items: type: integer type: array claim: - $ref: '#/definitions/internal_controllers.AutoPiTransactionStatus' + allOf: + - $ref: '#/definitions/internal_controllers.AutoPiTransactionStatus' description: Claim contains the status of the on-chain claiming meta-transaction. deviceId: type: string @@ -811,7 +270,6 @@ definitions: type: integer type: array ethereumAddress: - description: OwnerAddress is the Ethereum address of the NFT owner. items: type: integer type: array @@ -826,7 +284,8 @@ definitions: ownerAddress: type: string pair: - $ref: '#/definitions/internal_controllers.AutoPiTransactionStatus' + allOf: + - $ref: '#/definitions/internal_controllers.AutoPiTransactionStatus' description: Pair contains the status of the on-chain pairing meta-transaction. releaseVersion: type: string @@ -839,7 +298,8 @@ definitions: unitId: type: string unpair: - $ref: '#/definitions/internal_controllers.AutoPiTransactionStatus' + allOf: + - $ref: '#/definitions/internal_controllers.AutoPiTransactionStatus' description: Unpair contains the status of the on-chain unpairing meta-transaction. type: object internal_controllers.AutoPiPairRequest: @@ -984,6 +444,15 @@ definitions: year: type: integer type: object + internal_controllers.DeviceRange: + properties: + rangeSets: + description: Contains a list of range sets, one for each range basis (may + be empty) + items: + $ref: '#/definitions/internal_controllers.RangeSet' + type: array + type: object internal_controllers.DeviceSnapshot: properties: ambientTemp: @@ -1028,12 +497,30 @@ definitions: name: type: string type: - type: string + $ref: '#/definitions/internal_controllers.DocumentTypeEnum' url: type: string userDeviceId: type: string type: object + internal_controllers.DocumentTypeEnum: + enum: + - DriversLicense + - Other + - VehicleTitle + - VehicleRegistration + - VehicleInsurance + - VehicleMaintenance + - VehicleCustomImage + type: string + x-enum-varnames: + - DriversLicense + - Other + - VehicleTitle + - VehicleRegistration + - VehicleInsurance + - VehicleMaintenance + - VehicleCustomImage internal_controllers.GeoFenceUserDevice: properties: mmy: @@ -1081,7 +568,7 @@ definitions: type: string errorCodes: items: - $ref: '#/definitions/services.ErrorCodesResponse' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse' type: array requestedAt: example: "2023-05-23T12:56:36Z" @@ -1205,27 +692,6 @@ definitions: name: type: string type: object - internal_controllers.Offer: - properties: - declineReason: - description: The reason the offer was declined from the vendor - type: string - error: - description: An error from the vendor (eg. when the VIN is invalid) - type: string - grade: - description: The grade of the offer from the vendor (eg. "RETAIL") - type: string - price: - description: The offer price from the vendor - type: integer - url: - description: The offer URL from the vendor - type: string - vendor: - description: The vendor of the offer (eg. "carmax", "carvana", etc.) - type: string - type: object internal_controllers.Privilege: properties: expiry: @@ -1260,7 +726,7 @@ definitions: type: string errorCodes: items: - $ref: '#/definitions/services.ErrorCodesResponse' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.ErrorCodesResponse' type: array type: object internal_controllers.RangeSet: @@ -1313,7 +779,7 @@ definitions: type: string integrationCapabilities: items: - $ref: '#/definitions/services.DeviceCompatibility' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceCompatibility' type: array userDeviceId: type: string @@ -1354,260 +820,106 @@ definitions: example: Confirmed type: string tokenId: - example: 15 - type: number - txHash: - example: 0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e - type: string - type: object - internal_controllers.UpdateCountryCodeReq: - properties: - countryCode: - type: string - type: object - internal_controllers.UpdateNameReq: - properties: - name: - type: string - type: object - internal_controllers.UpdateVINReq: - properties: - signature: - description: |- - Signature is the hex-encoded result of the AutoPi signing the VIN. It must - be present to verify the VIN. - example: 16b15f88bbd2e0a22d1d0084b8b7080f2003ea83eab1a00f80d8c18446c9c1b6224f17aa09eaf167717ca4f355bb6dc94356e037edf3adf6735a86fc3741f5231b - type: string - vin: - description: |- - VIN is a vehicle identification number. At the very least, it must be - 17 characters in length and contain only letters and numbers. - example: 4Y1SL65848Z411439 - type: string - required: - - vin - type: object - internal_controllers.UserDeviceFull: - properties: - countryCode: - type: string - customImageUrl: - type: string - deviceDefinition: - $ref: '#/definitions/services.DeviceDefinition' - id: - type: string - integrations: - items: - $ref: '#/definitions/internal_controllers.UserDeviceIntegrationStatus' - type: array - metadata: - $ref: '#/definitions/services.UserDeviceMetadata' - name: - type: string - nft: - $ref: '#/definitions/internal_controllers.NFTData' - optedInAt: - type: string - privilegedUsers: - items: - $ref: '#/definitions/internal_controllers.PrivilegeUser' - type: array - vin: - type: string - vinConfirmed: - type: boolean - vinCredential: - $ref: '#/definitions/internal_controllers.VINCredentialData' - type: object - internal_controllers.UserDeviceIntegrationStatus: - properties: - createdAt: - type: string - externalId: - type: string - integrationId: - type: string - integrationVendor: - type: string - metadata: - type: string - status: - type: string - syntheticDevice: - $ref: '#/definitions/internal_controllers.SyntheticDeviceStatus' - tokenId: - $ref: '#/definitions/big.Int' - updatedAt: - type: string - type: object - internal_controllers.VINCredentialData: - properties: - expiresAt: - type: string - issuedAt: - type: string - valid: - type: boolean - vin: - type: string - type: object - math.HexOrDecimal256: - type: object - services.AutoPiTask: - properties: - code: - type: integer - description: - type: string - error: - type: string - status: - type: string - taskId: - type: string - updatedAt: - type: string - updates: - description: Updates increments every time the job was updated. - type: integer - type: object - services.DeviceAttribute: - properties: - name: - type: string - value: - type: string - type: object - services.DeviceCompatibility: - properties: - capabilities: - items: - type: integer - type: array - country: - type: string - id: - type: string - region: - type: string - style: - type: string - type: - type: string - vendor: + example: 15 + type: number + txHash: + example: 0x30bce3da6985897224b29a0fe064fd2b426bb85a394cc09efe823b5c83326a8e type: string type: object - services.DeviceDefinition: + internal_controllers.UpdateCountryCodeReq: properties: - compatibleIntegrations: - description: CompatibleIntegrations has systems this vehicle can integrate - with - items: - $ref: '#/definitions/services.DeviceCompatibility' - type: array - deviceAttributes: - description: DeviceAttributes is a list of attributes for the device type - as defined in device_types.properties - items: - $ref: '#/definitions/services.DeviceAttribute' - type: array - deviceDefinitionId: - type: string - imageUrl: + countryCode: type: string - make: - $ref: '#/definitions/services.DeviceMake' - metadata: {} + type: object + internal_controllers.UpdateNameReq: + properties: name: type: string - type: - $ref: '#/definitions/services.DeviceType' - vehicleData: - $ref: '#/definitions/services.DeviceVehicleInfo' - description: VehicleInfo will be empty if not a vehicle type - verified: - type: boolean type: object - services.DeviceMake: + internal_controllers.UpdateVINReq: properties: - id: - type: string - logo_url: - type: string - name: + signature: + description: |- + Signature is the hex-encoded result of the AutoPi signing the VIN. It must + be present to verify the VIN. + example: 16b15f88bbd2e0a22d1d0084b8b7080f2003ea83eab1a00f80d8c18446c9c1b6224f17aa09eaf167717ca4f355bb6dc94356e037edf3adf6735a86fc3741f5231b type: string - oem_platform_name: + vin: + description: |- + VIN is a vehicle identification number. At the very least, it must be + 17 characters in length and contain only letters and numbers. + example: 4Y1SL65848Z411439 type: string + required: + - vin type: object - services.DeviceType: + internal_controllers.UserDeviceFull: properties: - make: + countryCode: type: string - model: + customImageUrl: type: string - subModels: + deviceDefinition: + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.DeviceDefinition' + id: + type: string + integrations: items: - type: string + $ref: '#/definitions/internal_controllers.UserDeviceIntegrationStatus' type: array - type: - description: Type is eg. Vehicle, E-bike, roomba + metadata: + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.UserDeviceMetadata' + name: type: string - year: - type: integer - type: object - services.DeviceVehicleInfo: - properties: - base_msrp: - type: integer - driven_wheels: + nft: + $ref: '#/definitions/internal_controllers.NFTData' + optedInAt: type: string - epa_class: + privilegedUsers: + items: + $ref: '#/definitions/internal_controllers.PrivilegeUser' + type: array + vin: type: string - fuel_tank_capacity_gal: + vinConfirmed: + type: boolean + vinCredential: + $ref: '#/definitions/internal_controllers.VINCredentialData' + type: object + internal_controllers.UserDeviceIntegrationStatus: + properties: + createdAt: type: string - fuel_type: + externalId: type: string - mpg: + integrationId: type: string - mpg_city: + integrationVendor: type: string - mpg_highway: + metadata: type: string - number_of_doors: + status: type: string - vehicle_type: - description: VehicleType PASSENGER CAR, from NHTSA + syntheticDevice: + $ref: '#/definitions/internal_controllers.SyntheticDeviceStatus' + tokenId: + $ref: '#/definitions/big.Int' + updatedAt: type: string type: object - services.ErrorCodesResponse: + internal_controllers.VINCredentialData: properties: - code: - example: P0148 - type: string - description: - example: Fuel delivery error + expiresAt: type: string - type: object - services.UserDeviceMetadata: - properties: - canProtocol: - description: CANProtocol is the protocol that was detected by edge-network - from the autopi. + issuedAt: type: string - elasticDefinitionSynced: - type: boolean - elasticRegionSynced: + valid: type: boolean - geoDecodedCountry: - type: string - geoDecodedStateProv: - type: string - postal_code: - type: string - powertrainType: + vin: type: string type: object + math.HexOrDecimal256: + type: object smartcar.TirePressure: properties: age: @@ -1626,8 +938,16 @@ definitions: requestId: type: string unitSystem: - type: string - type: object + $ref: '#/definitions/smartcar.UnitSystem' + type: object + smartcar.UnitSystem: + enum: + - metric + - imperial + type: string + x-enum-varnames: + - Metric + - Imperial info: contact: {} title: DIMO Devices API @@ -1708,7 +1028,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiDeviceInfo' + $ref: '#/definitions/internal_controllers.AutoPiDeviceInfo' security: - BearerAuth: [] tags: @@ -1746,7 +1066,7 @@ paths: name: claimRequest required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiClaimRequest' + $ref: '#/definitions/internal_controllers.AutoPiClaimRequest' produces: - application/json responses: @@ -1788,7 +1108,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/services.AutoPiTask' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_services.AutoPiTask' security: - BearerAuth: [] tags: @@ -1802,7 +1122,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/constants.CountryInfo' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo' tags: - countries /countries/{countryCode}: @@ -1820,57 +1140,13 @@ paths: "200": description: OK schema: - $ref: '#/definitions/constants.CountryInfo' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo' "400": description: invalid country code "404": description: country not found with that country code tags: - countries - /dcn/{tokenID}: - get: - description: retrieves the DCN NFT metadata for a given token ID address - parameters: - - description: DCN node id decimal representation - in: path - name: tokenID - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/internal_controllers.NFTMetadataResp' - "400": - description: Bad Request - "404": - description: Not Found - tags: - - dcn - /dcn/{tokenID}/image: - get: - description: retrieves the DCN NFT metadata for a given token address - parameters: - - description: DCN node id decimal representation - in: path - name: tokenID - required: true - type: string - produces: - - image/svg+xml - responses: - "200": - description: OK - schema: - $ref: '#/definitions/internal_controllers.NFTMetadataResp' - "400": - description: Bad Request - "404": - description: Not Found - tags: - - dcn /documents: get: consumes: @@ -1883,7 +1159,7 @@ paths: description: OK schema: items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse' + $ref: '#/definitions/internal_controllers.DocumentResponse' type: array security: - BearerAuth: [] @@ -1920,7 +1196,7 @@ paths: "201": description: Created schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse' + $ref: '#/definitions/internal_controllers.DocumentResponse' security: - BearerAuth: [] tags: @@ -1961,7 +1237,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DocumentResponse' + $ref: '#/definitions/internal_controllers.DocumentResponse' security: - BearerAuth: [] tags: @@ -2016,75 +1292,19 @@ paths: name: user_device required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeRequest' + $ref: '#/definitions/internal_controllers.CompleteOAuthExchangeRequest' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CompleteOAuthExchangeResponseWrapper' + $ref: '#/definitions/internal_controllers.CompleteOAuthExchangeResponseWrapper' security: - ApiKeyAuth: [] - BearerAuth: [] tags: - user-devices - /integrations: - get: - description: gets list of integrations we have defined - produces: - - application/json - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/grpc.Integration' - type: array - security: - - BearerAuth: [] - tags: - - integrations - /manufacturer/{tokenId}: - get: - description: Retrieves NFT metadata for a given manufacturer. - parameters: - - description: token id - in: path - name: tokenId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/internal_controllers.NFTMetadataResp' - "404": - description: Not Found - tags: - - nfts - /synthetic/device/{tokenId}: - get: - description: Retrieves NFT metadata for a given synthetic device. - parameters: - - description: token id - in: path - name: tokenId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/internal_controllers.NFTMetadataResp' - "404": - description: Not Found - tags: - - nfts /user/devices: post: consumes: @@ -2097,14 +1317,14 @@ paths: name: user_device required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDevice' + $ref: '#/definitions/internal_controllers.RegisterUserDevice' produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceResponse' + $ref: '#/definitions/internal_controllers.RegisterUserDeviceResponse' security: - ApiKeyAuth: [] - BearerAuth: [] @@ -2167,7 +1387,7 @@ paths: name: userSignature required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest' + $ref: '#/definitions/internal_controllers.AutoPiPairRequest' produces: - application/json responses: {} @@ -2206,7 +1426,7 @@ paths: name: userSignature required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.AutoPiPairRequest' + $ref: '#/definitions/internal_controllers.AutoPiPairRequest' produces: - application/json responses: {} @@ -2223,7 +1443,7 @@ paths: name: userDeviceIntegrationRegistration required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterDeviceIntegrationRequest' + $ref: '#/definitions/internal_controllers.RegisterDeviceIntegrationRequest' responses: "204": description: No Content @@ -2278,7 +1498,7 @@ paths: name: mintRequest required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MintRequest' + $ref: '#/definitions/internal_controllers.MintRequest' responses: "200": description: OK @@ -2333,7 +1553,7 @@ paths: name: name required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateCountryCodeReq' + $ref: '#/definitions/internal_controllers.UpdateCountryCodeReq' produces: - application/json responses: @@ -2359,7 +1579,7 @@ paths: "404": description: Vehicle not found schema: - $ref: '#/definitions/helpers.ErrorRes' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes' security: - BearerAuth: [] summary: List all error code queries made for this vehicle. @@ -2386,7 +1606,7 @@ paths: "404": description: Vehicle not found schema: - $ref: '#/definitions/helpers.ErrorRes' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes' security: - BearerAuth: [] summary: Obtain, store, and return descriptions for a list of error codes from @@ -2403,11 +1623,11 @@ paths: "404": description: Vehicle not found schema: - $ref: '#/definitions/helpers.ErrorRes' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes' "429": description: Last query already cleared schema: - $ref: '#/definitions/helpers.ErrorRes' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes' security: - BearerAuth: [] summary: Mark the most recent set of error codes as having been cleared. @@ -2429,7 +1649,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetUserDeviceIntegrationResponse' + $ref: '#/definitions/internal_controllers.GetUserDeviceIntegrationResponse' security: - BearerAuth: [] tags: @@ -2460,7 +1680,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandRequestStatusResp' + $ref: '#/definitions/internal_controllers.CommandRequestStatusResp' summary: Get the status of a submitted command. tags: - device @@ -2540,7 +1760,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse' + $ref: '#/definitions/internal_controllers.CommandResponse' summary: Lock the device's doors tags: - device @@ -2567,7 +1787,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse' + $ref: '#/definitions/internal_controllers.CommandResponse' summary: Unlock the device's doors tags: - device @@ -2595,7 +1815,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse' + $ref: '#/definitions/internal_controllers.CommandResponse' summary: Open the device's front trunk tags: - device @@ -2676,7 +1896,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CommandResponse' + $ref: '#/definitions/internal_controllers.CommandResponse' summary: Open the device's rear trunk tags: - device @@ -2693,7 +1913,7 @@ paths: name: name required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateNameReq' + $ref: '#/definitions/internal_controllers.UpdateNameReq' - description: user id in: path name: user_device_id @@ -2708,26 +1928,6 @@ paths: - BearerAuth: [] tags: - user-devices - /user/devices/{userDeviceID}/range: - get: - description: gets the estimated range for a particular user device - parameters: - - description: user device id - in: path - name: userDeviceID - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.DeviceRange' - security: - - BearerAuth: [] - tags: - - user-devices /user/devices/{userDeviceID}/status: get: description: |- @@ -2761,7 +1961,7 @@ paths: name: vin required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UpdateVINReq' + $ref: '#/definitions/internal_controllers.UpdateVINReq' - description: user id in: path name: userDeviceID @@ -2790,7 +1990,7 @@ paths: name: nftIamges required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.NFTImageData' + $ref: '#/definitions/internal_controllers.NFTImageData' responses: "204": description: No Content @@ -2811,18 +2011,18 @@ paths: name: user_device required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceSmartcar' + $ref: '#/definitions/internal_controllers.RegisterUserDeviceSmartcar' produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull' + $ref: '#/definitions/internal_controllers.UserDeviceFull' "201": description: Created schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull' + $ref: '#/definitions/internal_controllers.UserDeviceFull' "400": description: validation failure "409": @@ -2848,14 +2048,14 @@ paths: name: user_device required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.RegisterUserDeviceVIN' + $ref: '#/definitions/internal_controllers.RegisterUserDeviceVIN' produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.UserDeviceFull' + $ref: '#/definitions/internal_controllers.UserDeviceFull' "400": description: validation failure "424": @@ -2876,7 +2076,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp' + $ref: '#/definitions/internal_controllers.MyDevicesResp' security: - BearerAuth: [] tags: @@ -2890,7 +2090,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.MyDevicesResp' + $ref: '#/definitions/internal_controllers.MyDevicesResp' security: - BearerAuth: [] tags: @@ -2905,7 +2105,7 @@ paths: description: OK schema: items: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.GetGeofence' + $ref: '#/definitions/internal_controllers.GetGeofence' type: array security: - ApiKeyAuth: [] @@ -2923,14 +2123,14 @@ paths: name: geofence required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence' + $ref: '#/definitions/internal_controllers.CreateGeofence' produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/helpers.CreateResponse' + $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_controllers_helpers.CreateResponse' security: - ApiKeyAuth: [] - BearerAuth: [] @@ -2968,7 +2168,7 @@ paths: name: geofence required: true schema: - $ref: '#/definitions/github.com_DIMO-Network_devices-api_internal_controllers.CreateGeofence' + $ref: '#/definitions/internal_controllers.CreateGeofence' produces: - application/json responses: @@ -3014,6 +2214,26 @@ paths: description: OK security: - BearerAuth: [] + /v2/vehicles/{tokenId}/analytics/range: + get: + description: gets the estimated range for a particular user device + parameters: + - description: tokenId + in: path + name: tokenId + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/internal_controllers.DeviceRange' + security: + - BearerAuth: [] + tags: + - user-devices /vehicle/{tokenID}/commands/doors/lock: post: description: Lock the device's doors. diff --git a/internal/controllers/test_user_device_data.json b/internal/controllers/test_user_device_data.json new file mode 100644 index 000000000..eca61d55c --- /dev/null +++ b/internal/controllers/test_user_device_data.json @@ -0,0 +1,52 @@ +{ + "oil": { "value": 0.11299999803304672, "timestamp": "2022-06-18T04:06:40.200Z"}, + "vin": { "value": "1G6KN5R63KU145157", "timestamp": "2022-06-18T04:06:40.200Z"}, + "tires": { "value": { + "backLeft": 236, + "backRight": 268, + "frontLeft": 220, + "frontRight": 244 + }, "timestamp": "2022-06-18T04:06:40.200Z"}, + "errors": { "value": [ + { + "type": "battery", + "errorCode": 403, + "errorType": "PERMISSION", + "resolution": { + "type": "REAUTHENTICATE" + }, + "description": "Your application has insufficient permissions to access the requested resource. Please prompt the user to re-authenticate using Smartcar Connect." + }, + { + "type": "battery/capacity", + "errorCode": 403, + "errorType": "PERMISSION", + "resolution": { + "type": "REAUTHENTICATE" + }, + "description": "Your application has insufficient permissions to access the requested resource. Please prompt the user to re-authenticate using Smartcar Connect." + }, + { + "type": "charge", + "errorCode": 403, + "errorType": "PERMISSION", + "resolution": { + "type": "REAUTHENTICATE" + }, + "description": "Your application has insufficient permissions to access the requested resource. Please prompt the user to re-authenticate using Smartcar Connect." + }, + { + "type": "location", + "errorCode": 502, + "errorType": "UPSTREAM", + "resolution": { + "type": "RETRY_LATER" + }, + "description": "Smartcar received an error from an upstream source. Please retry your request at a later time." + } + ], "timestamp": "2022-06-18T04:06:40.200Z"}, + "odometer": { "value": 55759.33984375, "timestamp": "2022-06-18T04:06:40.200Z"}, + "timestamp": { "value": "2022-06-18T04:06:40.200Z", "timestamp": "2022-06-18T04:06:40.200Z"}, + "vehicleId": "c99099f3-a8c4-4534-8bc3-56a1a24b98c8", + "fuelPercentRemaining": { "value": 0.71, "timestamp": "2022-06-18T04:06:40.200Z"} +} diff --git a/internal/controllers/user_devices_controller_v2.go b/internal/controllers/user_devices_controller_v2.go new file mode 100644 index 000000000..d0d712b88 --- /dev/null +++ b/internal/controllers/user_devices_controller_v2.go @@ -0,0 +1,160 @@ +package controllers + +import ( + "database/sql" + "fmt" + "math/big" + "sort" + "time" + + "github.com/DIMO-Network/shared" + "github.com/DIMO-Network/shared/db" + "github.com/ericlagergren/decimal" + "github.com/gofiber/fiber/v2" + "github.com/pkg/errors" + "github.com/rs/zerolog" + "github.com/tidwall/gjson" + "github.com/volatiletech/sqlboiler/v4/queries/qm" + "github.com/volatiletech/sqlboiler/v4/types" + + "github.com/DIMO-Network/devices-api/internal/config" + "github.com/DIMO-Network/devices-api/internal/controllers/helpers" + "github.com/DIMO-Network/devices-api/internal/services" + "github.com/DIMO-Network/devices-api/models" +) + +type UserDevicesControllerV2 struct { + Settings *config.Settings + DBS func() *db.ReaderWriter + log *zerolog.Logger + DeviceDefSvc services.DeviceDefinitionService +} + +func NewUserDevicesControllerV2(settings *config.Settings, dbs func() *db.ReaderWriter, logger *zerolog.Logger, deviceDefSvc services.DeviceDefinitionService) UserDevicesControllerV2 { + return UserDevicesControllerV2{ + Settings: settings, + DBS: dbs, + log: logger, + DeviceDefSvc: deviceDefSvc, + } +} + +type DeviceRange struct { + // Contains a list of range sets, one for each range basis (may be empty) + RangeSets []RangeSet `json:"rangeSets"` +} + +type RangeSet struct { + // The time the data was collected + Updated string `json:"updated"` + // The basis for the range calculation (eg. "MPG" or "MPG Highway") + RangeBasis string `json:"rangeBasis"` + // The estimated range distance + RangeDistance int `json:"rangeDistance"` + // The unit used for the rangeDistance (eg. "miles" or "kilometers") + RangeUnit string `json:"rangeUnit"` +} + +// GetRange godoc +// @Description gets the estimated range for a particular user device +// @Tags user-devices +// @Produce json +// @Success 200 {object} controllers.DeviceRange +// @Security BearerAuth +// @Param tokenId path int true "tokenId" +// @Router /v2/vehicles/{tokenId}/analytics/range [get] +func (udc *UserDevicesControllerV2) GetRange(c *fiber.Ctx) error { + tis := c.Params("tokenID") + ti, ok := new(big.Int).SetString(tis, 10) + if !ok { + return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("Couldn't parse token id %q.", tis)) + } + + tkID := types.NewNullDecimal(new(decimal.Big).SetBigMantScale(ti, 0)) + + nft, err := models.VehicleNFTS( + models.VehicleNFTWhere.TokenID.EQ(tkID), + ).One(c.Context(), udc.DBS().Reader) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return fiber.NewError(fiber.StatusNotFound, "No device with that token ID found.") + } + udc.log.Err(err).Str("TokenID", tkID.String()).Msg("could not get device") + return fiber.NewError(fiber.StatusInternalServerError, "error occurred getting device with token id") + } + + if !nft.UserDeviceID.Valid { + return fiber.NewError(fiber.StatusInternalServerError, "error occurred getting device with token id") + } + + userDevice, err := models.UserDevices( + models.UserDeviceWhere.ID.EQ(nft.UserDeviceID.String), + qm.Load(models.UserDeviceRels.UserDeviceData), + ).One(c.Context(), udc.DBS().Reader) + if err != nil { + return err + } + + dds, err := udc.DeviceDefSvc.GetDeviceDefinitionsByIDs(c.Context(), []string{userDevice.DeviceDefinitionID}) + if err != nil { + return shared.GrpcErrorToFiber(err, "deviceDefSvc error getting definition id: "+userDevice.DeviceDefinitionID) + } + + deviceRange := DeviceRange{ + RangeSets: []RangeSet{}, + } + udd := userDevice.R.UserDeviceData + if len(dds) > 0 && dds[0] != nil && len(udd) > 0 { + + rangeData := helpers.GetActualDeviceDefinitionMetadataValues(dds[0], userDevice.DeviceStyleID) + + sortByJSONFieldMostRecent(udd, "fuelPercentRemaining") + fuelPercentRemaining := gjson.GetBytes(udd[0].Signals.JSON, "fuelPercentRemaining.value") + dataUpdatedOn := gjson.GetBytes(udd[0].Signals.JSON, "fuelPercentRemaining.timestamp").Time() + if fuelPercentRemaining.Exists() && rangeData.FuelTankCapGal > 0 && rangeData.Mpg > 0 { + fuelTankAtGal := rangeData.FuelTankCapGal * fuelPercentRemaining.Float() + rangeSet := RangeSet{ + Updated: dataUpdatedOn.Format(time.RFC3339), + RangeBasis: "MPG", + RangeDistance: int(rangeData.Mpg * fuelTankAtGal), + RangeUnit: "miles", + } + deviceRange.RangeSets = append(deviceRange.RangeSets, rangeSet) + if rangeData.MpgHwy > 0 { + rangeSet.RangeBasis = "MPG Highway" + rangeSet.RangeDistance = int(rangeData.MpgHwy * fuelTankAtGal) + deviceRange.RangeSets = append(deviceRange.RangeSets, rangeSet) + } + } + sortByJSONFieldMostRecent(udd, "range") + reportedRange := gjson.GetBytes(udd[0].Signals.JSON, "range.value") + dataUpdatedOn = gjson.GetBytes(udd[0].Signals.JSON, "range.timestamp").Time() + if reportedRange.Exists() { + reportedRangeMiles := int(reportedRange.Float() / services.MilesToKmFactor) + rangeSet := RangeSet{ + Updated: dataUpdatedOn.Format(time.RFC3339), + RangeBasis: "Vehicle Reported", + RangeDistance: reportedRangeMiles, + RangeUnit: "miles", + } + deviceRange.RangeSets = append(deviceRange.RangeSets, rangeSet) + } + } + + return c.JSON(deviceRange) +} + +// sortByJSONFieldMostRecent Sort user device data so the latest that has the specified field is first +// only pass in field name, as this will append "timestamp" to look compare signals.field.timestamp +func sortByJSONFieldMostRecent(udd models.UserDeviceDatumSlice, field string) { + sort.Slice(udd, func(i, j int) bool { + fpri := gjson.GetBytes(udd[i].Signals.JSON, field+".timestamp") + fprj := gjson.GetBytes(udd[j].Signals.JSON, field+".timestamp") + if fpri.Exists() && !fprj.Exists() { + return true + } else if !fpri.Exists() && fprj.Exists() { + return false + } + return fpri.Time().After(fprj.Time()) + }) +} diff --git a/internal/controllers/user_devices_controller_v2_test.go b/internal/controllers/user_devices_controller_v2_test.go new file mode 100644 index 000000000..da2896030 --- /dev/null +++ b/internal/controllers/user_devices_controller_v2_test.go @@ -0,0 +1,175 @@ +package controllers + +import ( + "context" + _ "embed" + "fmt" + "io" + "net/http" + "testing" + + ddgrpc "github.com/DIMO-Network/device-definitions-api/pkg/grpc" + "github.com/DIMO-Network/shared/db" + "github.com/DIMO-Network/shared/middleware/privilegetoken" + "github.com/DIMO-Network/shared/privileges" + "github.com/ericlagergren/decimal" + "github.com/gofiber/fiber/v2" + "github.com/segmentio/ksuid" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + "github.com/testcontainers/testcontainers-go" + "github.com/tidwall/gjson" + "github.com/volatiletech/null/v8" + "github.com/volatiletech/sqlboiler/v4/boil" + "github.com/volatiletech/sqlboiler/v4/types" + "go.uber.org/mock/gomock" + + "github.com/DIMO-Network/devices-api/internal/config" + "github.com/DIMO-Network/devices-api/internal/constants" + mock_services "github.com/DIMO-Network/devices-api/internal/services/mocks" + "github.com/DIMO-Network/devices-api/internal/test" + "github.com/DIMO-Network/devices-api/models" +) + +type UserDevicesControllerV2Suite struct { + suite.Suite + pdb db.Store + controller *UserDevicesControllerV2 + container testcontainers.Container + ctx context.Context + mockCtrl *gomock.Controller + app *fiber.App + deviceDefSvc *mock_services.MockDeviceDefinitionService + deviceDefIntSvc *mock_services.MockDeviceDefinitionIntegrationService + testUserID string +} + +// ClaimsInjectorTestHandler injects fake claims into context +func ClaimsInjectorTestHandler(claims []privileges.Privilege) fiber.Handler { + return func(c *fiber.Ctx) error { + claims := privilegetoken.CustomClaims{ + PrivilegeIDs: claims, + } + c.Locals("tokenClaims", claims) + return c.Next() + } +} + +func (s *UserDevicesControllerV2Suite) SetupSuite() { + s.ctx = context.Background() + s.pdb, s.container = test.StartContainerDatabase(s.ctx, s.T(), migrationsDirRelPath) + logger := test.Logger() + mockCtrl := gomock.NewController(s.T()) + s.mockCtrl = mockCtrl + + s.deviceDefSvc = mock_services.NewMockDeviceDefinitionService(mockCtrl) + s.deviceDefIntSvc = mock_services.NewMockDeviceDefinitionIntegrationService(mockCtrl) + + c := NewUserDevicesControllerV2(&config.Settings{Port: "3000", Environment: "prod"}, s.pdb.DBS, logger, s.deviceDefSvc) + app := test.SetupAppFiber(*logger) + app.Use(ClaimsInjectorTestHandler([]privileges.Privilege{privileges.VehicleNonLocationData})) + app.Get("/v2/vehicles/:tokenId/analytics/range", test.AuthInjectorTestHandler(s.testUserID), c.GetRange) + s.controller = &c + s.app = app +} + +// TearDownTest after each test truncate tables +func (s *UserDevicesControllerV2Suite) TearDownTest() { + test.TruncateTables(s.pdb.DBS().Writer.DB, s.T()) +} + +// TearDownSuite cleanup at end by terminating container +func (s *UserDevicesControllerV2Suite) TearDownSuite() { + fmt.Printf("shutting down postgres at with session: %s \n", s.container.SessionID()) + if err := s.container.Terminate(s.ctx); err != nil { + s.T().Fatal(err) + } + s.mockCtrl.Finish() // might need to do mockctrl on every test, and refactor setup into one method +} + +// Test Runner +func TestUserDevicesControllerTestSuiteV2(t *testing.T) { + suite.Run(t, new(UserDevicesControllerV2Suite)) +} + +//go:embed test_user_device_data.json +var testUserDeviceData []byte + +func (s *UserDevicesControllerV2Suite) TestGetRange() { + autoPiUnitID := "1234" + autoPiDeviceID := "4321" + tokenID := 4 + ddID := ksuid.New().String() + integration := test.BuildIntegrationGRPC(constants.AutoPiVendor, 10, 0) + smartCarIntegration := test.BuildIntegrationGRPC(constants.SmartCarVendor, 10, 0) + _ = test.SetupCreateAftermarketDevice(s.T(), testUserID, nil, autoPiUnitID, &autoPiDeviceID, s.pdb) + _, addr, err := test.GenerateWallet() + s.NoError(err) + + gddir := []*ddgrpc.GetDeviceDefinitionItemResponse{ + { + DeviceAttributes: []*ddgrpc.DeviceTypeAttribute{ + {Name: "mpg", Value: "38.0"}, + {Name: "mpg_highway", Value: "40.0"}, + {Name: "fuel_tank_capacity_gal", Value: "14.5"}, + }, + Make: &ddgrpc.DeviceMake{ + Name: "Ford", + }, + Name: "F-150", + DeviceDefinitionId: ddID, + }, + } + ud := test.SetupCreateUserDevice(s.T(), s.testUserID, ddID, nil, "", s.pdb) + + mint := models.MetaTransactionRequest{ID: ksuid.New().String(), Status: models.MetaTransactionRequestStatusConfirmed} + s.Require().NoError(mint.Insert(s.ctx, s.pdb.DBS().Writer, boil.Infer())) + + vnft := models.VehicleNFT{ + UserDeviceID: null.StringFrom(ud.ID), + Vin: ud.VinIdentifier.String, + TokenID: types.NewNullDecimal(decimal.New(int64(tokenID), 0)), + OwnerAddress: null.BytesFrom(addr.Bytes()), + MintRequestID: mint.ID, + } + s.Require().NoError(vnft.Insert(s.ctx, s.pdb.DBS().Writer, boil.Infer())) + + test.SetupCreateUserDeviceAPIIntegration(s.T(), autoPiUnitID, autoPiDeviceID, ud.ID, integration.Id, s.pdb) + udd := models.UserDeviceDatum{ + UserDeviceID: ud.ID, + Signals: null.JSONFrom(testUserDeviceData), + IntegrationID: integration.Id, + } + err = udd.Insert(context.Background(), s.pdb.DBS().Writer, boil.Infer()) + require.NoError(s.T(), err) + udd2 := models.UserDeviceDatum{ + UserDeviceID: ud.ID, + Signals: null.JSONFrom([]byte(`{"range": {"value": 380.14,"timestamp":"2022-06-18T04:02:11.544Z" } }`)), + IntegrationID: smartCarIntegration.Id, + } + err = udd2.Insert(context.Background(), s.pdb.DBS().Writer, boil.Infer()) + require.NoError(s.T(), err) + s.deviceDefSvc.EXPECT().GetDeviceDefinitionsByIDs(gomock.Any(), []string{ddID}).Return(gddir, nil) + + request := test.BuildRequest(http.MethodGet, fmt.Sprintf("/v2/vehicles/%d/analytics/range", tokenID), "") + + response, err := s.app.Test(request) + require.NoError(s.T(), err) + body, _ := io.ReadAll(response.Body) + + s.Assert().Equal(fiber.StatusOK, response.StatusCode) + + s.Assert().Equal(3, int(gjson.GetBytes(body, "rangeSets.#").Int())) + s.Assert().Equal("2022-06-18T04:06:40Z", gjson.GetBytes(body, "rangeSets.0.updated").String()) + s.Assert().Equal("2022-06-18T04:06:40Z", gjson.GetBytes(body, "rangeSets.1.updated").String()) + s.Assert().Equal("2022-06-18T04:02:11Z", gjson.GetBytes(body, "rangeSets.2.updated").String()) + s.Assert().Equal("MPG", gjson.GetBytes(body, "rangeSets.0.rangeBasis").String()) + s.Assert().Equal("MPG Highway", gjson.GetBytes(body, "rangeSets.1.rangeBasis").String()) + s.Assert().Equal("Vehicle Reported", gjson.GetBytes(body, "rangeSets.2.rangeBasis").String()) + s.Assert().Equal(391, int(gjson.GetBytes(body, "rangeSets.0.rangeDistance").Int())) + s.Assert().Equal(411, int(gjson.GetBytes(body, "rangeSets.1.rangeDistance").Int())) + s.Assert().Equal(236, int(gjson.GetBytes(body, "rangeSets.2.rangeDistance").Int())) + s.Assert().Equal("miles", gjson.GetBytes(body, "rangeSets.0.rangeUnit").String()) + s.Assert().Equal("miles", gjson.GetBytes(body, "rangeSets.1.rangeUnit").String()) + s.Assert().Equal("miles", gjson.GetBytes(body, "rangeSets.2.rangeUnit").String()) +}