Skip to content

Instantly share code, notes, and snippets.

@z64
Last active July 3, 2018 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z64/cdde1e054f83046b2dc67f24daea2030 to your computer and use it in GitHub Desktop.
Save z64/cdde1e054f83046b2dc67f24daea2030 to your computer and use it in GitHub Desktop.
# ➜ mapper git:(master) ✗ curl \
# -H 'Authorization: Bot TOKEN' \
# https://discordapp.com/api/oauth2/applications/@me \
# | ./test OAuth2::Application application.cr
# % Total % Received % Xferd Average Speed Time Time Time Current
# Dload Upload Total Spent Left Speed
# 100 291 0 291 0 0 1625 0 --:--:-- --:--:-- --:--:-- 1625
# ➜ mapper git:(master) ✗ cat application.cr
struct OAuth2::Application
include JSON::Serializable
@[JSON::Field(key: "description")]
property description : String # => ""
@[JSON::Field(key: "name")]
property name : String # => "Hornet"
@[JSON::Field(key: "owner")]
property owner : T # => {"username":"z64","discriminator":"1337","id":"120571255635181568","avatar":"c1abc282b210ab76638d2bc1cf1687b4"}
@[JSON::Field(key: "bot_public")]
property bot_public : Bool # => true
@[JSON::Field(key: "bot_require_code_grant")]
property bot_require_code_grant : Bool # => false
@[JSON::Field(key: "id")]
property id : String # => "213450769276338177"
@[JSON::Field(key: "icon")]
property icon : String # => "ce23f72a13c945c38d0e890fd7b17335"
end
# ➜ mapper git:(master) ✗ curl \
# -H 'Authorization: Bot TOKEN' \
# https://discordapp.com/api/users/@me \
# | ./test User user.cr
# % Total % Received % Xferd Average Speed Time Time Time Current
# Dload Upload Total Spent Left Speed
# 100 219 0 219 0 0 1319 0 --:--:-- --:--:-- --:--:-- 1319
# ➜ mapper git:(master) ✗ cat user.cr
struct User
include JSON::Serializable
@[JSON::Field(key: "username")]
property username : String # => "Hornet"
@[JSON::Field(key: "verified")]
property verified : Bool # => true
@[JSON::Field(key: "locale")]
property locale : String # => "en-US"
@[JSON::Field(key: "mfa_enabled")]
property mfa_enabled : Bool # => true
@[JSON::Field(key: "bot")]
property bot : Bool # => true
@[JSON::Field(key: "id")]
property id : String # => "213450769276338177"
@[JSON::Field(key: "flags")]
property flags : Int64 # => 0
@[JSON::Field(key: "avatar")]
property avatar : String # => "208bcfc90f49915f25ec3808dcfa0f85"
@[JSON::Field(key: "discriminator")]
property discriminator : String # => "3729"
@[JSON::Field(key: "email")]
property email : Nil # => null
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment