progress on go rewrite: logger and config work now
This commit is contained in:
58
structs/config.go
Normal file
58
structs/config.go
Normal file
@ -0,0 +1,58 @@
|
||||
package structs
|
||||
|
||||
type SyncData struct {
|
||||
Followers []FanslyFollowResponse `json:"followers"` // List of followers
|
||||
Subscriptions []Subscription `json:"subscriptions"` // List of subscriptions
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Version int // The version of the config file
|
||||
IsFirstRun bool // Is this the first run of the application
|
||||
FanslyAccessToken string // The access token for the Fansly API
|
||||
AutoSyncEnabled bool // Is auto-sync enabled
|
||||
SyncToken string // The token used for syncing
|
||||
SyncInterval int // The interval for syncing in hours
|
||||
LastSyncTime string // The last time the sync was performed
|
||||
LastSyncData SyncData // The data from the last sync
|
||||
}
|
||||
|
||||
type OldConfig struct {
|
||||
Version int `json:"version"`
|
||||
IsFirstRun bool `json:"is_first_run"`
|
||||
FanslyToken string `json:"fansly_token"`
|
||||
AutoSyncEnabled bool `json:"auto_sync_enabled"`
|
||||
SyncToken string `json:"sync_token"`
|
||||
SyncInterval int `json:"sync_interval"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
Version: 3,
|
||||
IsFirstRun: true,
|
||||
FanslyAccessToken: "",
|
||||
AutoSyncEnabled: false,
|
||||
SyncToken: "",
|
||||
SyncInterval: 8,
|
||||
LastSyncTime: "",
|
||||
LastSyncData: SyncData{
|
||||
Followers: []FanslyFollowResponse{},
|
||||
Subscriptions: []Subscription{},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewConfigFromOld(oldConfig *OldConfig) *Config {
|
||||
return &Config{
|
||||
Version: 3,
|
||||
IsFirstRun: oldConfig.IsFirstRun,
|
||||
FanslyAccessToken: oldConfig.FanslyToken,
|
||||
AutoSyncEnabled: oldConfig.AutoSyncEnabled,
|
||||
SyncToken: oldConfig.SyncToken,
|
||||
SyncInterval: oldConfig.SyncInterval,
|
||||
LastSyncTime: "",
|
||||
LastSyncData: SyncData{
|
||||
Followers: []FanslyFollowResponse{},
|
||||
Subscriptions: []Subscription{},
|
||||
},
|
||||
}
|
||||
}
|
53
structs/fansly.go
Normal file
53
structs/fansly.go
Normal file
@ -0,0 +1,53 @@
|
||||
package structs
|
||||
|
||||
type FanslyBaseResponse[T any] struct {
|
||||
Success bool `json:"success"` // Indicates if the request was successful
|
||||
Response T `json:"response"` // The response data, type of T
|
||||
}
|
||||
|
||||
type FanslyFollowResponse struct {
|
||||
Followers []struct {
|
||||
FollowerID string `json:"followerId"` // The ID of the follower
|
||||
}
|
||||
}
|
||||
|
||||
type FanslySubscriptionResponse struct {
|
||||
Subscriptions []Subscription `json:"subscriptions"` // List of subscriptions
|
||||
Stats SubStats `json:"stats"` // Subscription statistics
|
||||
}
|
||||
|
||||
type SubStats struct {
|
||||
TotalActive int `json:"totalActive"`
|
||||
TotalExpired int `json:"totalExpired"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type Subscription struct {
|
||||
ID string `json:"id"`
|
||||
HistoryID string `json:"historyId"`
|
||||
SubscriberID string `json:"subscriberId"`
|
||||
SubscriptionTierID string `json:"subscriptionTierId"`
|
||||
SubscriptionTierName string `json:"subscriptionTierName"`
|
||||
SubscriptionTierColor string `json:"subscriptionTierColor"`
|
||||
PlanID string `json:"planId"`
|
||||
PromoID string `json:"promoId"`
|
||||
GiftCodeID any `json:"giftCodeId"`
|
||||
PaymentMethodID string `json:"paymentMethodId"`
|
||||
Status int `json:"status"`
|
||||
Price int `json:"price"`
|
||||
RenewPrice int `json:"renewPrice"`
|
||||
RenewCorrelationID string `json:"renewCorrelationId"`
|
||||
AutoRenew int `json:"autoRenew"`
|
||||
BillingCycle int `json:"billingCycle"`
|
||||
Duration int `json:"duration"`
|
||||
RenewDate int64 `json:"renewDate"`
|
||||
Version int `json:"version"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
EndsAt int64 `json:"endsAt"`
|
||||
PromoPrice any `json:"promoPrice"`
|
||||
PromoDuration any `json:"promoDuration"`
|
||||
PromoStatus any `json:"promoStatus"`
|
||||
PromoStartsAt any `json:"promoStartsAt"`
|
||||
PromoEndsAt any `json:"promoEndsAt"`
|
||||
}
|
Reference in New Issue
Block a user