| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package entities |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "time" |
||
| 5 | |||
| 6 | "github.com/google/uuid" |
||
| 7 | ) |
||
| 8 | |||
| 9 | // Phone represents an android phone which has installed the http sms app |
||
| 10 | type Phone struct { |
||
| 11 | ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"` |
||
| 12 | UserID UserID `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"` |
||
| 13 | FcmToken *string `json:"fcm_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....."` |
||
| 14 | PhoneNumber string `json:"phone_number" example:"+18005550199"` |
||
| 15 | MessagesPerMinute uint `json:"messages_per_minute" example:"1"` |
||
| 16 | |||
| 17 | // MessageExpirationSeconds is the duration in seconds after sending a message when it is considered to be expired. |
||
| 18 | MessageExpirationSeconds uint `json:"message_expiration_seconds"` |
||
| 19 | |||
| 20 | CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"` |
||
| 21 | UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"` |
||
| 22 | } |
||
| 23 | |||
| 24 | // MessageExpirationDuration returns the message expiration as time.Duration |
||
| 25 | func (phone *Phone) MessageExpirationDuration() time.Duration { |
||
| 26 | return time.Duration(phone.MessageExpirationSeconds) * time.Second |
||
| 27 | } |
||
| 28 |