From 99b3d7287bd0ac36ee82129ad38bd88c5b5af625 Mon Sep 17 00:00:00 2001 From: Jonathan B Date: Wed, 14 Aug 2019 21:25:02 +0200 Subject: Initial release --- src/twitch/mappings/converters.cr | 3 +++ src/twitch/mappings/user.cr | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/twitch/mappings/converters.cr create mode 100644 src/twitch/mappings/user.cr (limited to 'src/twitch/mappings') diff --git a/src/twitch/mappings/converters.cr b/src/twitch/mappings/converters.cr new file mode 100644 index 0000000..d9b57e9 --- /dev/null +++ b/src/twitch/mappings/converters.cr @@ -0,0 +1,3 @@ +module Twitcr + TIME_FORMAT = Time::Format.new("%FT%TZ") +end diff --git a/src/twitch/mappings/user.cr b/src/twitch/mappings/user.cr new file mode 100644 index 0000000..6ddd08b --- /dev/null +++ b/src/twitch/mappings/user.cr @@ -0,0 +1,21 @@ +require "./converters" + +module Twitcr + struct UserList + JSON.mapping({data: Array(User)}) + end + + struct User + JSON.mapping({ + id: {type: UInt64, converter: ID::Converter}, + login: String, + display_name: String, + }) + end +end + +module ID::Converter + def self.from_json(value : JSON::PullParser) : UInt64 + UInt64.new(value.read_string) + end +end -- cgit v1.2.3