From 9f0d795ea7a23f37af1fe0d708b6a2a0f9158b6a Mon Sep 17 00:00:00 2001 From: zer0stars Date: Thu, 11 Sep 2025 11:26:03 +0200 Subject: [PATCH] removing countries endpoints --- cmd/devices-api/api.go | 4 - docs/docs.go | 82 -------------------- docs/swagger.json | 82 -------------------- docs/swagger.yaml | 53 ------------- internal/controllers/countries_controller.go | 48 ------------ 5 files changed, 269 deletions(-) delete mode 100644 internal/controllers/countries_controller.go diff --git a/cmd/devices-api/api.go b/cmd/devices-api/api.go index 0633b79d..efe5b954 100644 --- a/cmd/devices-api/api.go +++ b/cmd/devices-api/api.go @@ -144,7 +144,6 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, natsSvc, wallet, userDeviceSvc, teslaFleetAPISvc, ipfsSvc, chConn) webhooksController := controllers.NewWebhooksController(settings, pdb.DBS, &logger, autoPiSvc, ddIntSvc) documentsController := controllers.NewDocumentsController(settings, &logger, s3ServiceClient, pdb.DBS) - countriesController := controllers.NewCountriesController() userIntegrationAuthController := controllers.NewUserIntegrationAuthController(settings, pdb.DBS, &logger, ddSvc, teslaFleetAPISvc, &tmpcred.Store{ Redis: redisCache, Cipher: cipher, @@ -168,9 +167,6 @@ func startWebAPI(logger zerolog.Logger, settings *config.Settings, pdb db.Store, // Device Definitions nftController := controllers.NewNFTController(settings, pdb.DBS, &logger, s3NFTServiceClient, ddSvc, teslaTaskService, ddIntSvc, teslaOracle) - v1.Get("/countries", countriesController.GetSupportedCountries) - v1.Get("/countries/:countryCode", countriesController.GetCountry) - // webhooks, performs signature validation v1.Post(constants.AutoPiWebhookPath, webhooksController.ProcessCommand) diff --git a/docs/docs.go b/docs/docs.go index 3b82ffd9..4940dac3 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -15,59 +15,6 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/countries": { - "get": { - "description": "Returns all the supported countries", - "produces": [ - "application/json" - ], - "tags": [ - "countries" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo" - } - } - } - } - }, - "/countries/{countryCode}": { - "get": { - "description": "Returns a specific country by 3-letter ISO country code", - "produces": [ - "application/json" - ], - "tags": [ - "countries" - ], - "parameters": [ - { - "type": "string", - "description": "3-letter country code", - "name": "countryCode", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$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" - } - } - } - }, "/documents": { "get": { "security": [ @@ -1293,35 +1240,6 @@ const docTemplate = `{ "big.Int": { "type": "object" }, - "github_com_DIMO-Network_devices-api_internal_constants.CountryInfo": { - "type": "object", - "properties": { - "alpha_2": { - "type": "string" - }, - "alpha_3": { - "type": "string" - }, - "lora_region": { - "type": "string" - }, - "name": { - "type": "string" - }, - "region": { - "type": "string" - }, - "region_code": { - "type": "integer" - }, - "sub_region": { - "type": "string" - }, - "sub_region_code": { - "type": "integer" - } - } - }, "github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 4fb1087e..eb17dc3f 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7,59 +7,6 @@ }, "basePath": "/v1", "paths": { - "/countries": { - "get": { - "description": "Returns all the supported countries", - "produces": [ - "application/json" - ], - "tags": [ - "countries" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo" - } - } - } - } - }, - "/countries/{countryCode}": { - "get": { - "description": "Returns a specific country by 3-letter ISO country code", - "produces": [ - "application/json" - ], - "tags": [ - "countries" - ], - "parameters": [ - { - "type": "string", - "description": "3-letter country code", - "name": "countryCode", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$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" - } - } - } - }, "/documents": { "get": { "security": [ @@ -1285,35 +1232,6 @@ "big.Int": { "type": "object" }, - "github_com_DIMO-Network_devices-api_internal_constants.CountryInfo": { - "type": "object", - "properties": { - "alpha_2": { - "type": "string" - }, - "alpha_3": { - "type": "string" - }, - "lora_region": { - "type": "string" - }, - "name": { - "type": "string" - }, - "region": { - "type": "string" - }, - "region_code": { - "type": "integer" - }, - "sub_region": { - "type": "string" - }, - "sub_region_code": { - "type": "integer" - } - } - }, "github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 1a339b7d..85e161a8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -42,25 +42,6 @@ definitions: type: object big.Int: type: object - github_com_DIMO-Network_devices-api_internal_constants.CountryInfo: - properties: - alpha_2: - type: string - alpha_3: - type: string - lora_region: - type: string - name: - type: string - region: - type: string - region_code: - type: integer - sub_region: - type: string - sub_region_code: - type: integer - type: object github_com_DIMO-Network_devices-api_internal_controllers_helpers.ErrorRes: properties: code: @@ -712,40 +693,6 @@ info: title: DIMO Devices API version: "1.0" paths: - /countries: - get: - description: Returns all the supported countries - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/github_com_DIMO-Network_devices-api_internal_constants.CountryInfo' - tags: - - countries - /countries/{countryCode}: - get: - description: Returns a specific country by 3-letter ISO country code - parameters: - - description: 3-letter country code - in: path - name: countryCode - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $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 /documents: get: consumes: diff --git a/internal/controllers/countries_controller.go b/internal/controllers/countries_controller.go deleted file mode 100644 index ee401a9b..00000000 --- a/internal/controllers/countries_controller.go +++ /dev/null @@ -1,48 +0,0 @@ -package controllers - -import ( - "github.com/DIMO-Network/devices-api/internal/constants" - "github.com/gofiber/fiber/v2" -) - -type CountriesController struct { -} - -func NewCountriesController() CountriesController { - return CountriesController{} -} - -// GetSupportedCountries godoc -// @Description Returns all the supported countries -// @Tags countries -// @Produce json -// @Success 200 {object} constants.CountryInfo -// @Router /countries [get] -func (cc CountriesController) GetSupportedCountries(c *fiber.Ctx) error { - // read countries json and return it - c.Set("Content-Type", "application/json") - return c.SendString(constants.GetCountriesRaw()) -} - -// GetCountry godoc -// @Description Returns a specific country by 3-letter ISO country code -// @Tags countries -// @Produce json -// @Param countryCode path string true "3-letter country code" -// @Success 200 {object} constants.CountryInfo -// @Failure 404 "country not found with that country code" -// @Failure 400 "invalid country code" -// @Router /countries/{countryCode} [get] -func (cc CountriesController) GetCountry(c *fiber.Ctx) error { - countryCode := c.Params("countryCode") - if len(countryCode) != 3 { - return fiber.NewError(fiber.StatusBadRequest, "invalid country code: "+countryCode) - } - - country := constants.FindCountry(countryCode) - if country == nil { - return fiber.NewError(fiber.StatusNotFound, "country not found or not supported: "+countryCode) - } - - return c.JSON(country) -}