diff --git a/docs/docs.go b/docs/docs.go index 9b904d0f..d4a7d820 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -5221,80 +5221,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.UpdateGeneralNotificationSettingPayloadRequest" - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/response.UserNotificationSettingResponse" - } - }, - "400": { - "description": "bad request" - }, - "401": { - "description": "unauthorized" - }, - "404": { - "description": "not found" - }, - "500": { - "description": "internal server error" - } - } - } - }, - "/profiles/{profile_id}/settings/notifications/activity/{group}/{key}": { - "put": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "update profile's activity notification settings", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Settings" - ], - "summary": "update profile's activity notification settings", - "operationId": "updateUserActivityNotificationSettings", - "parameters": [ - { - "type": "string", - "description": "profile ID", - "name": "profile_id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "notification group. available values: ` + "`" + `wallet` + "`" + `, ` + "`" + `app` + "`" + `, ` + "`" + `community` + "`" + `", - "name": "group", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "notification key", - "name": "key", - "in": "path", - "required": true - }, - { - "description": "payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.UpdateActivityNotificationSettingPayloadRequest" + "$ref": "#/definitions/request.UpdateNotificationSettingPayloadRequest" } } ], @@ -7601,6 +7528,44 @@ const docTemplate = `{ } } }, + "model.PayToken": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "chain": { + "$ref": "#/definitions/model.Chain" + }, + "chain_id": { + "type": "string" + }, + "coin_gecko_id": { + "type": "string" + }, + "decimal": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "native": { + "type": "boolean" + }, + "price": { + "type": "number" + }, + "symbol": { + "type": "string" + } + } + }, "model.PrivacyCustomSetting": { "type": "object", "properties": { @@ -7938,7 +7903,7 @@ const docTemplate = `{ "type": "number" }, "token": { - "$ref": "#/definitions/model.Token" + "$ref": "#/definitions/model.PayToken" }, "token_id": { "type": "string" @@ -8048,7 +8013,7 @@ const docTemplate = `{ "type": "string" }, "default_token": { - "$ref": "#/definitions/model.Token" + "$ref": "#/definitions/model.PayToken" }, "default_token_id": { "type": "string" @@ -8056,7 +8021,7 @@ const docTemplate = `{ "prioritized_token": { "type": "array", "items": { - "$ref": "#/definitions/model.Token" + "$ref": "#/definitions/model.PayToken" } }, "prioritized_token_ids": { @@ -9297,17 +9262,6 @@ const docTemplate = `{ } } }, - "request.UpdateActivityNotificationSettingPayloadRequest": { - "type": "object", - "required": [ - "enable" - ], - "properties": { - "enable": { - "type": "boolean" - } - } - }, "request.UpdateDaoVoteRequest": { "type": "object", "required": [ @@ -9334,24 +9288,6 @@ const docTemplate = `{ } } }, - "request.UpdateGeneralNotificationSettingPayloadRequest": { - "type": "object", - "required": [ - "enable", - "platforms" - ], - "properties": { - "enable": { - "type": "boolean" - }, - "platforms": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, "request.UpdateGeneralSettingsPayloadRequest": { "type": "object", "required": [ @@ -9390,6 +9326,31 @@ const docTemplate = `{ } } }, + "request.UpdateNotificationSettingPayloadRequest": { + "type": "object", + "required": [ + "enable", + "flag", + "platforms" + ], + "properties": { + "enable": { + "type": "boolean" + }, + "flag": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + "platforms": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "request.UpdateQuestProgressRequest": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index a7dcdd96..e7d58e51 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -5213,80 +5213,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.UpdateGeneralNotificationSettingPayloadRequest" - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/response.UserNotificationSettingResponse" - } - }, - "400": { - "description": "bad request" - }, - "401": { - "description": "unauthorized" - }, - "404": { - "description": "not found" - }, - "500": { - "description": "internal server error" - } - } - } - }, - "/profiles/{profile_id}/settings/notifications/activity/{group}/{key}": { - "put": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "update profile's activity notification settings", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Settings" - ], - "summary": "update profile's activity notification settings", - "operationId": "updateUserActivityNotificationSettings", - "parameters": [ - { - "type": "string", - "description": "profile ID", - "name": "profile_id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "notification group. available values: `wallet`, `app`, `community`", - "name": "group", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "notification key", - "name": "key", - "in": "path", - "required": true - }, - { - "description": "payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.UpdateActivityNotificationSettingPayloadRequest" + "$ref": "#/definitions/request.UpdateNotificationSettingPayloadRequest" } } ], @@ -7593,6 +7520,44 @@ } } }, + "model.PayToken": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "chain": { + "$ref": "#/definitions/model.Chain" + }, + "chain_id": { + "type": "string" + }, + "coin_gecko_id": { + "type": "string" + }, + "decimal": { + "type": "integer" + }, + "icon": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "native": { + "type": "boolean" + }, + "price": { + "type": "number" + }, + "symbol": { + "type": "string" + } + } + }, "model.PrivacyCustomSetting": { "type": "object", "properties": { @@ -7930,7 +7895,7 @@ "type": "number" }, "token": { - "$ref": "#/definitions/model.Token" + "$ref": "#/definitions/model.PayToken" }, "token_id": { "type": "string" @@ -8040,7 +8005,7 @@ "type": "string" }, "default_token": { - "$ref": "#/definitions/model.Token" + "$ref": "#/definitions/model.PayToken" }, "default_token_id": { "type": "string" @@ -8048,7 +8013,7 @@ "prioritized_token": { "type": "array", "items": { - "$ref": "#/definitions/model.Token" + "$ref": "#/definitions/model.PayToken" } }, "prioritized_token_ids": { @@ -9289,17 +9254,6 @@ } } }, - "request.UpdateActivityNotificationSettingPayloadRequest": { - "type": "object", - "required": [ - "enable" - ], - "properties": { - "enable": { - "type": "boolean" - } - } - }, "request.UpdateDaoVoteRequest": { "type": "object", "required": [ @@ -9326,24 +9280,6 @@ } } }, - "request.UpdateGeneralNotificationSettingPayloadRequest": { - "type": "object", - "required": [ - "enable", - "platforms" - ], - "properties": { - "enable": { - "type": "boolean" - }, - "platforms": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, "request.UpdateGeneralSettingsPayloadRequest": { "type": "object", "required": [ @@ -9382,6 +9318,31 @@ } } }, + "request.UpdateNotificationSettingPayloadRequest": { + "type": "object", + "required": [ + "enable", + "flag", + "platforms" + ], + "properties": { + "enable": { + "type": "boolean" + }, + "flag": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + "platforms": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "request.UpdateQuestProgressRequest": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 41660912..195f33ff 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -654,6 +654,31 @@ definitions: updated_at: type: string type: object + model.PayToken: + properties: + address: + type: string + chain: + $ref: '#/definitions/model.Chain' + chain_id: + type: string + coin_gecko_id: + type: string + decimal: + type: integer + icon: + type: string + id: + type: string + name: + type: string + native: + type: boolean + price: + type: number + symbol: + type: string + type: object model.PrivacyCustomSetting: properties: platform: @@ -875,7 +900,7 @@ definitions: min: type: number token: - $ref: '#/definitions/model.Token' + $ref: '#/definitions/model.PayToken' token_id: type: string type: object @@ -947,12 +972,12 @@ definitions: default_receiver_platform: type: string default_token: - $ref: '#/definitions/model.Token' + $ref: '#/definitions/model.PayToken' default_token_id: type: string prioritized_token: items: - $ref: '#/definitions/model.Token' + $ref: '#/definitions/model.PayToken' type: array prioritized_token_ids: items: @@ -1776,13 +1801,6 @@ definitions: discord_user_id: type: string type: object - request.UpdateActivityNotificationSettingPayloadRequest: - properties: - enable: - type: boolean - required: - - enable - type: object request.UpdateDaoVoteRequest: properties: choice: @@ -1800,18 +1818,6 @@ definitions: increase_alert_at: type: integer type: object - request.UpdateGeneralNotificationSettingPayloadRequest: - properties: - enable: - type: boolean - platforms: - items: - type: string - type: array - required: - - enable - - platforms - type: object request.UpdateGeneralSettingsPayloadRequest: properties: payment: @@ -1837,6 +1843,23 @@ definitions: log_channel: type: string type: object + request.UpdateNotificationSettingPayloadRequest: + properties: + enable: + type: boolean + flag: + additionalProperties: + type: boolean + type: object + platforms: + items: + type: string + type: array + required: + - enable + - flag + - platforms + type: object request.UpdateQuestProgressRequest: properties: action: @@ -3022,14 +3045,14 @@ definitions: type: string usd: type: number + usd_1y_change: + type: number usd_7d_change: type: number usd_14d_change: type: number usd_1h_change: type: number - usd_1y_change: - type: number usd_24h_change: type: number usd_24h_vol: @@ -3650,30 +3673,30 @@ definitions: additionalProperties: type: number type: object - price_change_percentage_14d: + price_change_percentage_1h: type: number price_change_percentage_1h_in_currency: additionalProperties: type: number type: object + price_change_percentage_1y: + type: number price_change_percentage_1y_in_currency: additionalProperties: type: number type: object + price_change_percentage_7d: + type: number price_change_percentage_7d_in_currency: additionalProperties: type: number type: object + price_change_percentage_14d: + type: number price_change_percentage_14d_in_currency: additionalProperties: type: number type: object - price_change_percentage_1h: - type: number - price_change_percentage_1y: - type: number - price_change_percentage_7d: - type: number price_change_percentage_24h: type: number price_change_percentage_24h_in_currency: @@ -7841,7 +7864,7 @@ paths: name: payload required: true schema: - $ref: '#/definitions/request.UpdateGeneralNotificationSettingPayloadRequest' + $ref: '#/definitions/request.UpdateNotificationSettingPayloadRequest' produces: - application/json responses: @@ -7862,54 +7885,6 @@ paths: summary: update profile's notification settings tags: - Settings - /profiles/{profile_id}/settings/notifications/activity/{group}/{key}: - put: - consumes: - - application/json - description: update profile's activity notification settings - operationId: updateUserActivityNotificationSettings - parameters: - - description: profile ID - in: path - name: profile_id - required: true - type: string - - description: 'notification group. available values: `wallet`, `app`, `community`' - in: path - name: group - required: true - type: string - - description: notification key - in: path - name: key - required: true - type: string - - description: payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.UpdateActivityNotificationSettingPayloadRequest' - produces: - - application/json - responses: - "200": - description: successful operation - schema: - $ref: '#/definitions/response.UserNotificationSettingResponse' - "400": - description: bad request - "401": - description: unauthorized - "404": - description: not found - "500": - description: internal server error - security: - - BearerAuth: [] - summary: update profile's activity notification settings - tags: - - Settings /swap: post: consumes: diff --git a/pkg/entities/setting.go b/pkg/entities/setting.go index 0f6e8a5e..641630e6 100644 --- a/pkg/entities/setting.go +++ b/pkg/entities/setting.go @@ -114,10 +114,6 @@ func (e *Entity) GetUserNotificationSettings(uri request.UserSettingBaseUriReque return &userNotiSettings, nil } -func (e *Entity) UpdateUserNotificationSettings(uri request.UserSettingBaseUriRequest, payload request.UpdateGeneralNotificationSettingPayloadRequest) (*model.UserNotificationSetting, error) { - return &userNotiSettings, nil -} - -func (e *Entity) UpdateUserActivityNotificationSettings(uri request.UpdateActivityNotificationSettingUriRequest, payload request.UpdateActivityNotificationSettingPayloadRequest) (*model.UserNotificationSetting, error) { +func (e *Entity) UpdateUserNotificationSettings(uri request.UserSettingBaseUriRequest, payload request.UpdateNotificationSettingPayloadRequest) (*model.UserNotificationSetting, error) { return &userNotiSettings, nil } diff --git a/pkg/handler/setting/interface.go b/pkg/handler/setting/interface.go index 1caeabe7..7792d45e 100644 --- a/pkg/handler/setting/interface.go +++ b/pkg/handler/setting/interface.go @@ -10,5 +10,4 @@ type IHandler interface { // notification GetUserNotificationSettings(c *gin.Context) UpdateUserNotificationSettings(c *gin.Context) - UpdateUserActivityNotificationSettings(c *gin.Context) } diff --git a/pkg/handler/setting/notification.go b/pkg/handler/setting/notification.go index efe0a9fa..89ca7c71 100644 --- a/pkg/handler/setting/notification.go +++ b/pkg/handler/setting/notification.go @@ -58,7 +58,7 @@ func (h *handler) GetUserNotificationSettings(c *gin.Context) { // @Produce json // @Security BearerAuth // @Param profile_id path string true "profile ID" -// @Param payload body request.UpdateGeneralNotificationSettingPayloadRequest true "payload" +// @Param payload body request.UpdateNotificationSettingPayloadRequest true "payload" // @Success 200 {object} response.UserNotificationSettingResponse "successful operation" // @Failure 400 "bad request" // @Failure 401 "unauthorized" @@ -76,7 +76,7 @@ func (h *handler) UpdateUserNotificationSettings(c *gin.Context) { return } - var payload request.UpdateGeneralNotificationSettingPayloadRequest + var payload request.UpdateNotificationSettingPayloadRequest if err := c.BindJSON(&payload); err != nil { logger.WithError(err).Error("BindJSON() failed") c.JSON(http.StatusBadRequest, response.CreateResponse[any](nil, nil, err, nil)) @@ -92,50 +92,3 @@ func (h *handler) UpdateUserNotificationSettings(c *gin.Context) { c.JSON(http.StatusOK, response.CreateResponse[any](data, nil, nil, nil)) } - -// PUT /profiles/:profile_id/settings/notifications/activity/:group/:key -// UpdateUserActivityNotificationSettings update profile's activity notification settings -// @ID updateUserActivityNotificationSettings -// @Summary update profile's activity notification settings -// @Description update profile's activity notification settings -// @Tags Settings -// @Accept json -// @Produce json -// @Security BearerAuth -// @Param profile_id path string true "profile ID" -// @Param group path string true "notification group. available values: `wallet`, `app`, `community`" -// @Param key path string true "notification key" -// @Param payload body request.UpdateActivityNotificationSettingPayloadRequest true "payload" -// @Success 200 {object} response.UserNotificationSettingResponse "successful operation" -// @Failure 400 "bad request" -// @Failure 401 "unauthorized" -// @Failure 404 "not found" -// @Failure 500 "internal server error" -// @Router /profiles/{profile_id}/settings/notifications/activity/{group}/{key} [put] -func (h *handler) UpdateUserActivityNotificationSettings(c *gin.Context) { - logger.Debug("api call ", c.Request.RequestURI) - defer logger.Debug("api finish ", c.Request.RequestURI) - - var uri request.UpdateActivityNotificationSettingUriRequest - if err := c.BindUri(&uri); err != nil { - logger.WithError(err).Error("BindUri() failed") - c.JSON(http.StatusBadRequest, response.CreateResponse[any](nil, nil, err, nil)) - return - } - - var payload request.UpdateActivityNotificationSettingPayloadRequest - if err := c.BindJSON(&payload); err != nil { - logger.WithError(err).Error("BindJSON() failed") - c.JSON(http.StatusBadRequest, response.CreateResponse[any](nil, nil, err, nil)) - return - } - - data, err := h.entities.UpdateUserActivityNotificationSettings(uri, payload) - if err != nil { - logger.WithFields(logrus.Fields{"uri": uri, "payload": payload}).WithError(err).Error("entities.UpdateUserActivityNotificationSettings() failed") - c.JSON(http.StatusInternalServerError, response.CreateResponse[any](nil, nil, errors.New("failed to update user activity notification settings"), nil)) - return - } - - c.JSON(http.StatusOK, response.CreateResponse[any](data, nil, nil, nil)) -} diff --git a/pkg/request/setting.go b/pkg/request/setting.go index 8affde2c..d620565b 100644 --- a/pkg/request/setting.go +++ b/pkg/request/setting.go @@ -68,17 +68,8 @@ type PrivacySetting struct { Wallets *BasePrivacySetting `json:"wallets"` } -type UpdateGeneralNotificationSettingPayloadRequest struct { - Enable bool `json:"enable" binding:"required"` - Platforms []string `json:"platforms" binding:"required"` -} - -type UpdateActivityNotificationSettingUriRequest struct { - UserSettingBaseUriRequest - Group string `uri:"group" binding:"required"` - Key string `uri:"key" binding:"required"` -} - -type UpdateActivityNotificationSettingPayloadRequest struct { - Enable bool `json:"enable" binding:"required"` +type UpdateNotificationSettingPayloadRequest struct { + Enable bool `json:"enable" binding:"required"` + Platforms []string `json:"platforms" binding:"required"` + Flags map[string]bool `json:"flag" binding:"required"` } diff --git a/pkg/routes/v1.go b/pkg/routes/v1.go index e101192c..cc9f08cb 100644 --- a/pkg/routes/v1.go +++ b/pkg/routes/v1.go @@ -510,11 +510,6 @@ func NewRoutes(r *gin.Engine, h *handler.Handler, cfg config.Config) { { notification.GET("", h.Setting.GetUserNotificationSettings) notification.PUT("", h.Setting.UpdateUserNotificationSettings) - - activity := notification.Group("/activity") - { - activity.PUT("/:group/:key", h.Setting.UpdateUserActivityNotificationSettings) - } } } }