summaryrefslogtreecommitdiff
path: root/src/twitch/mappings/user.cr
blob: 6ddd08bc17b7a2b0f404f87a18593753b3a39abe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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