Skip to content

Commit

Permalink
Allow updating and returning disabled field of event type
Browse files Browse the repository at this point in the history
  • Loading branch information
violog committed Jul 4, 2024
1 parent 20ebdc2 commit 2e26286
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/spec/components/schemas/EventStaticMeta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ required:
- frequency
- flag
- auto_claim
- disabled
properties:
name:
type: string
Expand Down Expand Up @@ -73,6 +74,9 @@ properties:
auto_claim:
type: boolean
description: Whether the event is automatically claimed on fulfillment, or requires manual claim
disabled:
type: boolean
description: Whether the event is disabled in the system. Disabled events can only be retrieved.
qr_code_value:
type: string
description: Base64-encoded QR code. Must match the code provided in event type.
Expand Down
5 changes: 4 additions & 1 deletion internal/data/evtypes/models/event_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func ResourceToModel(r resources.EventStaticMeta) EventType {
return u
}

// intended that disabled or no_auto_open fields are not accessible through API
// intended that no_auto_open field is not accessible through API due to being
// related only to back-end
return EventType{
Name: r.Name,
Description: r.Description,
Expand All @@ -44,6 +45,7 @@ func ResourceToModel(r resources.EventStaticMeta) EventType {
StartsAt: r.StartsAt,
ExpiresAt: r.ExpiresAt,
AutoClaim: r.AutoClaim,
Disabled: r.Disabled,
ActionURL: uConv(r.ActionUrl),
Logo: uConv(r.Logo),
QRCodeValue: r.QrCodeValue,
Expand Down Expand Up @@ -99,6 +101,7 @@ func (e EventType) ForUpdate() map[string]any {
"starts_at": e.StartsAt,
"expires_at": e.ExpiresAt,
"auto_claim": e.AutoClaim,
"disabled": e.Disabled,
"action_url": e.ActionURL,
"logo": e.Logo,
"qr_code_value": e.QRCodeValue,
Expand Down
2 changes: 2 additions & 0 deletions resources/model_event_static_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type EventStaticMeta struct {
// Whether the event is automatically claimed on fulfillment, or requires manual claim
AutoClaim bool `json:"auto_claim"`
Description string `json:"description"`
// Whether the event is disabled in the system. Disabled events can only be retrieved.
Disabled bool `json:"disabled"`
// General event expiration date (UTC RFC3339)
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// Event configuration flag: - active: Events can be opened, fulfilled, claimed - not_started: Event are not available yet, see `starts_at` - expired: Event is not available, as it has already expired, see `expires_at` - disabled: Event is disabled in the system If event is disabled, it doesn't matter if it's expired or not started: it has `disabled` flag.
Expand Down

0 comments on commit 2e26286

Please sign in to comment.