Skip to content

Commit 0a784ac

Browse files
committed
Fix swagger + Add scheduled sms docs
1 parent 86c22c3 commit 0a784ac

File tree

10 files changed

+55
-58
lines changed

10 files changed

+55
-58
lines changed

api/pkg/entities/event_listener_log.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

api/pkg/entities/message.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (s SIM) String() string {
8484
// Message represents a message sent between 2 phone numbers
8585
type Message struct {
8686
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
87-
RequestID *string `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4"`
87+
RequestID *string `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4" validate:"optional"`
8888
Owner string `json:"owner" example:"+18005550199"`
8989
UserID UserID `json:"user_id" gorm:"index:idx_messages__user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
9090
Contact string `json:"contact" example:"+18005550100"`
@@ -99,24 +99,24 @@ type Message struct {
9999
SIM SIM `json:"sim" example:"DEFAULT"`
100100

101101
// SendDuration is the number of nanoseconds from when the request was received until when the mobile phone send the message
102-
SendDuration *int64 `json:"send_time" example:"133414"`
102+
SendDuration *int64 `json:"send_time" example:"133414" validate:"optional"`
103103

104104
RequestReceivedAt time.Time `json:"request_received_at" example:"2022-06-05T14:26:01.520828+03:00"`
105105
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
106106
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`
107107
OrderTimestamp time.Time `json:"order_timestamp" example:"2022-06-05T14:26:09.527976+03:00"`
108-
LastAttemptedAt *time.Time `json:"last_attempted_at" example:"2022-06-05T14:26:09.527976+03:00"`
109-
NotificationScheduledAt *time.Time `json:"scheduled_at" example:"2022-06-05T14:26:09.527976+03:00"`
110-
SentAt *time.Time `json:"sent_at" example:"2022-06-05T14:26:09.527976+03:00"`
111-
ScheduledSendTime *time.Time `json:"scheduled_send_time" example:"2022-06-05T14:26:09.527976+03:00"`
112-
DeliveredAt *time.Time `json:"delivered_at" example:"2022-06-05T14:26:09.527976+03:00"`
113-
ExpiredAt *time.Time `json:"expired_at" example:"2022-06-05T14:26:09.527976+03:00"`
114-
FailedAt *time.Time `json:"failed_at" example:"2022-06-05T14:26:09.527976+03:00"`
115-
CanBePolled bool `json:"can_be_polled" example:"false"`
108+
LastAttemptedAt *time.Time `json:"last_attempted_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
109+
NotificationScheduledAt *time.Time `json:"scheduled_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
110+
SentAt *time.Time `json:"sent_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
111+
ScheduledSendTime *time.Time `json:"scheduled_send_time" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
112+
DeliveredAt *time.Time `json:"delivered_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
113+
ExpiredAt *time.Time `json:"expired_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
114+
FailedAt *time.Time `json:"failed_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
115+
CanBePolled bool `json:"can_be_polled" example:"false" swaggerignore:"true"`
116116
SendAttemptCount uint `json:"send_attempt_count" example:"0"`
117117
MaxSendAttempts uint `json:"max_send_attempts" example:"1"`
118-
ReceivedAt *time.Time `json:"received_at" example:"2022-06-05T14:26:09.527976+03:00"`
119-
FailureReason *string `json:"failure_reason" example:"UNKNOWN"`
118+
ReceivedAt *time.Time `json:"received_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
119+
FailureReason *string `json:"failure_reason" example:"UNKNOWN" validate:"optional"`
120120
}
121121

122122
// IsSending determines if a message is being sent

api/pkg/entities/phone.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
type Phone struct {
1111
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
1212
UserID UserID `json:"user_id" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
13-
FcmToken *string `json:"fcm_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....."`
13+
FcmToken *string `json:"fcm_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....." validate:"optional"`
1414
PhoneNumber string `json:"phone_number" example:"+18005550199"`
1515
MessagesPerMinute uint `json:"messages_per_minute" example:"1"`
1616
SIM SIM `json:"sim" gorm:"default:SIM1"`
@@ -20,7 +20,7 @@ type Phone struct {
2020
// MessageExpirationSeconds is the duration in seconds after sending a message when it is considered to be expired.
2121
MessageExpirationSeconds uint `json:"message_expiration_seconds"`
2222

23-
MissedCallAutoReply *string `json:"missed_call_auto_reply" example:"This phone cannot receive calls. Please send an SMS instead."`
23+
MissedCallAutoReply *string `json:"missed_call_auto_reply" example:"This phone cannot receive calls. Please send an SMS instead." validate:"optional"`
2424

2525
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
2626
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`

api/pkg/entities/user.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ type User struct {
7676
Email string `json:"email" example:"[email protected]"`
7777
APIKey string `json:"api_key" gorm:"uniqueIndex:idx_users_api_key;NOT NULL" example:"x-api-key"`
7878
Timezone string `json:"timezone" example:"Europe/Helsinki" gorm:"default:Africa/Accra"`
79-
ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
79+
ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb" validate:"optional"`
8080
SubscriptionName SubscriptionName `json:"subscription_name" example:"free"`
81-
SubscriptionID *string `json:"subscription_id" example:"8f9c71b8-b84e-4417-8408-a62274f65a08"`
82-
SubscriptionStatus *string `json:"subscription_status" example:"on_trial"`
83-
SubscriptionRenewsAt *time.Time `json:"subscription_renews_at" example:"2022-06-05T14:26:02.302718+03:00"`
84-
SubscriptionEndsAt *time.Time `json:"subscription_ends_at" example:"2022-06-05T14:26:02.302718+03:00"`
81+
SubscriptionID *string `json:"subscription_id" example:"8f9c71b8-b84e-4417-8408-a62274f65a08" swaggerignore:"true"`
82+
SubscriptionStatus *string `json:"subscription_status" example:"on_trial" validate:"optional"`
83+
SubscriptionRenewsAt *time.Time `json:"subscription_renews_at" example:"2022-06-05T14:26:02.302718+03:00" validate:"optional"`
84+
SubscriptionEndsAt *time.Time `json:"subscription_ends_at" example:"2022-06-05T14:26:02.302718+03:00" validate:"optional"`
8585
NotificationMessageStatusEnabled bool `json:"notification_message_status_enabled" gorm:"default:true" example:"true"`
8686
NotificationWebhookEnabled bool `json:"notification_webhook_enabled" gorm:"default:true" example:"true"`
8787
NotificationHeartbeatEnabled bool `json:"notification_heartbeat_enabled" gorm:"default:true" example:"true"`

api/pkg/handlers/lemonsqueezy_handler.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,7 @@ func (h *LemonsqueezyHandler) RegisterRoutes(app *fiber.App, middlewares ...fibe
4444
router.Post("/event", h.computeRoute(middlewares, h.Event)...)
4545
}
4646

47-
// Event consumes a lemonsqueezy event
48-
// @Summary Consume a lemonsqueezy event
49-
// @Description Publish a lemonsqueezy event to the registered listeners
50-
// @Tags Lemonsqueezy
51-
// @Accept json
52-
// @Produce json
53-
// @Success 204 {object} responses.NoContent
54-
// @Failure 400 {object} responses.BadRequest
55-
// @Failure 401 {object} responses.Unauthorized
56-
// @Failure 422 {object} responses.UnprocessableEntity
57-
// @Failure 500 {object} responses.InternalServerError
58-
// @Router /lemonsqueezy/event [post]
47+
// Event handles lemonsqueezy events
5948
func (h *LemonsqueezyHandler) Event(c *fiber.Ctx) error {
6049
ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger)
6150
defer span.End()

api/pkg/handlers/message_handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ func (h *MessageHandler) RegisterPhoneAPIKeyRoutes(router fiber.Router, middlewa
6666
}
6767

6868
// PostSend a new entities.Message
69-
// @Summary Send a new SMS message
70-
// @Description Add a new SMS message to be sent by the android phone
69+
// @Summary Send an SMS message
70+
// @Description Add a new SMS message to be sent by your Android phone
7171
// @Security ApiKeyAuth
7272
// @Tags Messages
7373
// @Accept json
7474
// @Produce json
75-
// @Param payload body requests.MessageSend true "PostSend message request payload"
75+
// @Param payload body requests.MessageSend true "Send message request payload"
7676
// @Success 200 {object} responses.MessageResponse
7777
// @Failure 400 {object} responses.BadRequest
7878
// @Failure 401 {object} responses.Unauthorized

api/pkg/requests/message_send_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type MessageSend struct {
2323
// RequestID is an optional parameter used to track a request from the client's perspective
2424
RequestID string `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4" validate:"optional"`
2525
// SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone and you can queue messages for up to 20 days (480 hours) in the future.
26-
SendAt *time.Time `json:"send_at" example:"2022-06-05T14:26:09.527976+03:00" validate:"optional"`
26+
SendAt *time.Time `json:"send_at" example:"2025-12-19T16:39:57-08:00" validate:"optional"`
2727
}
2828

2929
// Sanitize sets defaults to MessageReceive
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)