SescAPI notebook
# Mix.install([
# {:ex_utils, "~> 0.1.7"},
# {:plug, "~> 1.0"},
# {:req, "~> 0.5.0"},
# {:kino, "~> 0.12.0"},
# {:sescapi, path: "/Users/vitorcalejuri/Projects/sescapi"}
# ])
import IEx.Helpers
import Kino
import Kino.Shorts
recompile()
Activity listing
First lets fetch all activities from Sesc using SescAPI.Activities
import SescAPI.Activities
# {%{"atividade" => activities}, _} = Code.eval_file("test/fixtures/activities.exs")
activities = SescAPI.Activities.filter(categoria: "musica-show", ppp: 1000)
#File.write("/Users/vitorcalejuri/Projects/sescapi/test/fixtures/musica-show.json",Jason.encode!(activities))
Enum.filter(activities, fn act -> String.match?(act.titulo, ~r/Hermeto/) end )
We must transform the data into a list of events, to be processed by the calendar component below.
defmodule CalendarEvents do
def event(activity) do
%{
id: activity.id,
title: activity.titulo,
desc: activity.complemento,
unit: hd(activity.unidade)[:name],
start: activity.dataPrimeiraSessao,
end: activity.dataUltimaSessao
}
end
end
events = Enum.map(activities, &CalendarEvents.event/1)
tree(events)
Calendar
import IEx.Helpers
recompile()
Assets.Calendar.new(events)
Misc
tree(activities)