Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download api/pkg/entities/billing_usage.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/api/pkg/entities/billing_usage.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway@6917738ca6db1603dee9e07994b4e42d5e1ae9b2/api/pkg/entities/billing_usage.go
-
curl -L -o billing_usage.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/api/pkg/entities/billing_usage.go
1.27 kB
| package entities | |
| import ( | |
| "time" | |
| "github.com/google/uuid" | |
| ) | |
| // BillingUsage tracks the billing usage of an account | |
| type BillingUsage struct { | |
| ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"` | |
| UserID UserID `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"` | |
| SentMessages uint `json:"sent_messages" example:"321"` | |
| ReceivedMessages uint `json:"received_messages" example:"465"` | |
| TotalCost uint `json:"total_cost" example:"0"` | |
| StartTimestamp time.Time `json:"start_timestamp" example:"2022-01-01T00:00:00+00:00"` | |
| EndTimestamp time.Time `json:"end_timestamp" example:"2022-01-31T23:59:59+00:00"` | |
| CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"` | |
| UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"` | |
| } | |
| // TotalMessages returns the sum of sent and received messages | |
| func (usage *BillingUsage) TotalMessages() uint { | |
| return usage.SentMessages + usage.ReceivedMessages | |
| } | |
| // IsEntitled checks if a user can send `count` messages without exceeding `limit` | |
| func (usage *BillingUsage) IsEntitled(count, limit uint) bool { | |
| return (usage.TotalMessages() + count) <= limit | |
| } | |