-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
26 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Api::Event::Create < ApiAction | ||
post "/api/events" do | ||
serialized_event = EventCreateSerializer.from_json(params.body) | ||
event = SaveEvent.create!(serialized_event) | ||
json EventSerializer.new(event) | ||
end | ||
end | ||
post "/api/events" do | ||
serialized_event = EventCreateSerializer.from_json(params.body) | ||
event = SaveEvent.create!(serialized_event) | ||
json EventSerializer.new(event) | ||
end | ||
end |
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
class EventSerializer < BaseSerializer | ||
def initialize(@event : Event) | ||
end | ||
def initialize(@event : Event) | ||
end | ||
|
||
def render | ||
{ | ||
event_uuid: @event.event_uuid, | ||
name: @event.name, | ||
host_name: @event.host_name, | ||
} | ||
end | ||
def render | ||
{ | ||
event_uuid: @event.event_uuid, | ||
name: @event.name, | ||
host_name: @event.host_name, | ||
} | ||
end | ||
end | ||
|
||
class EventCreateSerializer | ||
include JSON::Serializable | ||
property name : String | ||
property host_name : String | ||
property slots : Array(SerializedSlot) | ||
end | ||
include JSON::Serializable | ||
property name : String | ||
property host_name : String | ||
property slots : Array(SerializedSlot) | ||
end |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class SerializedSlot | ||
include JSON::Serializable | ||
property slot_type : Slot::SlotType | ||
property slot_start : Time | ||
end | ||
include JSON::Serializable | ||
property slot_type : Slot::SlotType | ||
property slot_start : Time | ||
end |