-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API to update the user notification settings
- Loading branch information
1 parent
89e3cc3
commit 05126f6
Showing
5 changed files
with
107 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,18 +57,21 @@ const SubscriptionName20KYearly = SubscriptionName("20k-yearly") | |
|
||
// User stores information about a user | ||
type User struct { | ||
ID UserID `json:"id" gorm:"primaryKey;type:string;" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"` | ||
Email string `json:"email" example:"[email protected]"` // gorm:"uniqueIndex" | ||
APIKey string `json:"api_key" example:"xyz"` // gorm:"uniqueIndex" | ||
Timezone string `json:"timezone" example:"Europe/Helsinki" gorm:"default:Africa/Accra"` | ||
ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"` | ||
SubscriptionName SubscriptionName `json:"subscription_name" example:"free"` | ||
SubscriptionID *string `json:"subscription_id" example:"8f9c71b8-b84e-4417-8408-a62274f65a08"` | ||
SubscriptionStatus *string `json:"subscription_status" example:"on_trial"` | ||
SubscriptionRenewsAt *time.Time `json:"subscription_renews_at" example:"2022-06-05T14:26:02.302718+03:00"` | ||
SubscriptionEndsAt *time.Time `json:"subscription_ends_at" example:"2022-06-05T14:26:02.302718+03: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"` | ||
ID UserID `json:"id" gorm:"primaryKey;type:string;" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"` | ||
Email string `json:"email" example:"[email protected]"` | ||
APIKey string `json:"api_key" example:"xyz"` | ||
Timezone string `json:"timezone" example:"Europe/Helsinki" gorm:"default:Africa/Accra"` | ||
ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"` | ||
SubscriptionName SubscriptionName `json:"subscription_name" example:"free"` | ||
SubscriptionID *string `json:"subscription_id" example:"8f9c71b8-b84e-4417-8408-a62274f65a08"` | ||
SubscriptionStatus *string `json:"subscription_status" example:"on_trial"` | ||
SubscriptionRenewsAt *time.Time `json:"subscription_renews_at" example:"2022-06-05T14:26:02.302718+03:00"` | ||
SubscriptionEndsAt *time.Time `json:"subscription_ends_at" example:"2022-06-05T14:26:02.302718+03:00"` | ||
NotificationMessageStatusEnabled bool `json:"notification_message_status_enabled" gorm:"default:true" example:"true"` | ||
NotificationWebhookEnabled bool `json:"notification_webhook_enabled" gorm:"default:true" example:"true"` | ||
NotificationHeartbeatEnabled bool `json:"notification_heartbeat_enabled" gorm:"default:true" example:"true"` | ||
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"` | ||
} | ||
|
||
// IsOnProPlan checks if a user is on the pro plan | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/NdoleStudio/httpsms/pkg/services" | ||
) | ||
|
||
// UserNotificationUpdate is the payload for updating a phone | ||
type UserNotificationUpdate struct { | ||
request | ||
MessageStatusEnabled bool `json:"message_status_enabled" example:"true"` | ||
WebhookEnabled bool `json:"webhook_enabled" example:"true"` | ||
HeartbeatEnabled bool `json:"heartbeat_enabled" example:"true"` | ||
} | ||
|
||
// ToUserNotificationUpdateParams converts UserNotificationUpdate to services.UserNotificationUpdateParams | ||
func (input *UserNotificationUpdate) ToUserNotificationUpdateParams() *services.UserNotificationUpdateParams { | ||
return &services.UserNotificationUpdateParams{ | ||
MessageStatusEnabled: input.MessageStatusEnabled, | ||
WebhookEnabled: input.WebhookEnabled, | ||
HeartbeatEnabled: input.HeartbeatEnabled, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters