Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HistoryResponse ¶
type HistoryResponse struct {
Weeks []HistoryResponseWeek `json:"weeks"`
}
type HistoryResponseWeek ¶
type HistoryResponseWeek struct { // Start is the starting time of the issuance week. Start time.Time `json:"start" example:"2022-04-11T05:00:00Z"` // End is the starting time of the issuance week after this one. End time.Time `json:"end" example:"2022-04-18T05:00:00Z"` // Points is the number of points the user earned this week. Points int `json:"points" example:"4000"` // Tokens is the number of tokens the user earned this week. Tokens *big.Int `json:"tokens" example:"4000" swaggertype:"number"` }
type RewardsController ¶
type RewardsController struct { DB func() *database.DBReaderWriter Logger *zerolog.Logger DataClient services.DeviceDataClient DefinitionsClient pb_defs.DeviceDefinitionServiceClient DevicesClient pb_devices.UserDeviceServiceClient AftermarketClient pb_devices.AftermarketDeviceServiceClient Settings *config.Settings }
func (*RewardsController) GetUserRewards ¶
func (r *RewardsController) GetUserRewards(c *fiber.Ctx) error
GetUserRewards godoc @Description A summary of the user's rewards. @Success 200 {object} controllers.UserResponse @Security BearerAuth @Router /user [get]
func (*RewardsController) GetUserRewardsHistory ¶
func (r *RewardsController) GetUserRewardsHistory(c *fiber.Ctx) error
GetUserRewardsHistory godoc @Description A summary of the user's rewards for past weeks. @Success 200 {object} controllers.HistoryResponse @Security BearerAuth @Router /user/history [get]
type UserResponse ¶
type UserResponse struct { // Points is the user's total number of points, across all devices and issuance weeks. Points int `json:"points" example:"5000"` // Tokens is the number of tokens the user has earned, across all devices and issuance // weeks. Tokens *big.Int `json:"tokens" example:"1105000000000000000000000" swaggertype:"number"` // Devices is a list of the user's devices, together with some information about their // connectivity. Devices []*UserResponseDevice `json:"devices"` // ThisWeek describes the current issuance week. ThisWeek UserResponseThisWeek `json:"thisWeek"` }
type UserResponseDevice ¶
type UserResponseDevice struct { // ID is the user device ID used across all services. ID string `json:"id" example:"27cv7gVTh9h4RJuTsmJHpBcr4I9"` // Points is the total number of points that the device has earned across all weeks. Points int `json:"points" example:"5000"` // Tokens is the total number of tokens that the device has earned across all weeks. Tokens *big.Int `json:"tokens,omitempty" example:"5000" swaggertype:"number"` // ConnectedThisWeek is true if we've seen activity from the device during the current issuance // week. ConnectedThisWeek bool `json:"connectedThisWeek" example:"true"` // IntegrationsThisWeek details the integrations we've seen active this week. IntegrationsThisWeek []UserResponseIntegration `json:"integrationsThisWeek"` // LastActive is the last time we saw activity from the vehicle. LastActive *time.Time `json:"lastActive,omitempty" example:"2022-04-12T09:23:01Z"` // ConnectionStreak is what we consider the streak of the device to be. This may not literally // be the number of consecutive connected weeks, because the user may disconnect for a week // without penalty, or have the connection streak reduced after three weeks of inactivity. ConnectionStreak int `json:"connectionStreak" example:"4"` // DisconnectionStreak is the number of consecutive issuance weeks that the device has been // disconnected. This number resets to 0 as soon as a device earns rewards for a certain week. DisconnectionStreak int `json:"disconnectionStreak,omitempty" example:"0"` // Level is the level 1-4 of the device. This is fully determined by ConnectionStreak. Level UserResponseLevel `json:"level"` }
type UserResponseIntegration ¶
type UserResponseIntegration struct { // ID is the integration ID. ID string `json:"id" example:"27egBSLazAT7njT2VBjcISPIpiU"` // Vendor is the name of the integration vendor. At present, this uniquely determines the // integration. Vendor string `json:"vendor" example:"SmartCar"` // Points is the number of points a user earns for being connected with this integration // for a week. Points int `json:"points" example:"1000"` }
type UserResponseLevel ¶
type UserResponseLevel struct { // Number is the level number 1-4 Number int `json:"number" example:"2"` // MinWeeks is the minimum streak of weeks needed to enter this level. MinWeeks int `json:"minWeeks" example:"4"` // MaxWeeks is the last streak week at this level. In the next week, we enter the next level. MaxWeeks *int `json:"maxWeeks,omitempty" example:"20"` // StreakPoints is the number of points you earn per week at this level. StreakPoints int `json:"streakPoints" example:"1000"` }
type UserResponseThisWeek ¶
Click to show internal directories.
Click to hide internal directories.