66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
package walletapi
|
|
|
|
import walletv1 "hyapp.local/api/proto/wallet/v1"
|
|
|
|
type overviewVIPData struct {
|
|
Level int32 `json:"level"`
|
|
Name string `json:"name"`
|
|
Active bool `json:"active"`
|
|
StartedAtMS int64 `json:"started_at_ms"`
|
|
ExpiresAtMS int64 `json:"expires_at_ms"`
|
|
Unavailable bool `json:"unavailable,omitempty"`
|
|
}
|
|
|
|
type resourceData struct {
|
|
ResourceID int64 `json:"resource_id"`
|
|
ResourceCode string `json:"resource_code"`
|
|
ResourceType string `json:"resource_type"`
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
Grantable bool `json:"grantable"`
|
|
GrantStrategy string `json:"grant_strategy"`
|
|
WalletAssetType string `json:"wallet_asset_type,omitempty"`
|
|
WalletAssetAmount int64 `json:"wallet_asset_amount,omitempty"`
|
|
UsageScopes []string `json:"usage_scopes"`
|
|
AssetURL string `json:"asset_url"`
|
|
PreviewURL string `json:"preview_url"`
|
|
AnimationURL string `json:"animation_url"`
|
|
MetadataJSON string `json:"metadata_json"`
|
|
SortOrder int32 `json:"sort_order"`
|
|
CreatedAtMS int64 `json:"created_at_ms"`
|
|
UpdatedAtMS int64 `json:"updated_at_ms"`
|
|
}
|
|
|
|
func resourcePointerFromProto(item *walletv1.Resource) *resourceData {
|
|
if item == nil {
|
|
return nil
|
|
}
|
|
data := resourceFromProto(item)
|
|
return &data
|
|
}
|
|
|
|
func resourceFromProto(item *walletv1.Resource) resourceData {
|
|
if item == nil {
|
|
return resourceData{}
|
|
}
|
|
return resourceData{
|
|
ResourceID: item.GetResourceId(),
|
|
ResourceCode: item.GetResourceCode(),
|
|
ResourceType: item.GetResourceType(),
|
|
Name: item.GetName(),
|
|
Status: item.GetStatus(),
|
|
Grantable: item.GetGrantable(),
|
|
GrantStrategy: item.GetGrantStrategy(),
|
|
WalletAssetType: item.GetWalletAssetType(),
|
|
WalletAssetAmount: item.GetWalletAssetAmount(),
|
|
UsageScopes: item.GetUsageScopes(),
|
|
AssetURL: item.GetAssetUrl(),
|
|
PreviewURL: item.GetPreviewUrl(),
|
|
AnimationURL: item.GetAnimationUrl(),
|
|
MetadataJSON: item.GetMetadataJson(),
|
|
SortOrder: item.GetSortOrder(),
|
|
CreatedAtMS: item.GetCreatedAtMs(),
|
|
UpdatedAtMS: item.GetUpdatedAtMs(),
|
|
}
|
|
}
|