0.2.1: Add support for contract type and team.
This commit is contained in:
parent
c085b71ede
commit
89b7ae32bc
4 changed files with 46 additions and 7 deletions
|
@ -15,10 +15,10 @@
|
||||||
### NOT SO IMPORTANT TODO
|
### NOT SO IMPORTANT TODO
|
||||||
|
|
||||||
- ~~STOP USING KEMAL FOR SIMPLE THINGS~~ Nevermind, kemal is pretty useful and it should stay
|
- ~~STOP USING KEMAL FOR SIMPLE THINGS~~ Nevermind, kemal is pretty useful and it should stay
|
||||||
- `programAgreement { type }` in the Next commit.
|
- ~~`programAgreement { type }` in the Next commit~~ Done.
|
||||||
- Guide on how to get the tokens to get it working
|
- Guide on how to get the tokens to get it working
|
||||||
- Kick API
|
- Kick API
|
||||||
|
|
||||||
### Suggestions
|
### Suggestions
|
||||||
|
|
||||||
~~3:45 RyanPotat: add team~~ Next commit.
|
~~3:45 RyanPotat: add team~~ Done.
|
||||||
|
|
|
@ -44,7 +44,7 @@ module TwAPI::Datahandlers::Twitch
|
||||||
|
|
||||||
def userLogin(env)
|
def userLogin(env)
|
||||||
if skipCache != "true"
|
if skipCache != "true"
|
||||||
if (json = Utils::Redis.retrieveFromCache("user-login_#{env.params.query["login"].try &.split(',')}"))
|
if (json = Utils::Redis.retrieveFromCache("user-login_#{env.params.query["login"].try &.split(',').to_s}"))
|
||||||
json = JSON.parse(json)
|
json = JSON.parse(json)
|
||||||
return json.to_json
|
return json.to_json
|
||||||
end
|
end
|
||||||
|
@ -89,6 +89,16 @@ module TwAPI::Datahandlers::Twitch
|
||||||
json.field "updatedAt", gql["user"]["updatedAt"]
|
json.field "updatedAt", gql["user"]["updatedAt"]
|
||||||
json.field "deletedAt", gql["user"]["deletedAt"]
|
json.field "deletedAt", gql["user"]["deletedAt"]
|
||||||
json.field "emotePrefix", gql["user"]["emoticonPrefix"]["name"]
|
json.field "emotePrefix", gql["user"]["emoticonPrefix"]["name"]
|
||||||
|
if gql["user"]["primaryTeam"] != nil
|
||||||
|
json.field "team", gql["user"]["primaryTeam"]["displayName"]
|
||||||
|
else
|
||||||
|
json.field "team", nil
|
||||||
|
end
|
||||||
|
if gql["user"]["primaryTeam"] != nil
|
||||||
|
json.field "contract", gql["user"]["programAgreement"]["type"]
|
||||||
|
else
|
||||||
|
json.field "contract", nil
|
||||||
|
end
|
||||||
json.field "roles", gql["user"]["roles"]
|
json.field "roles", gql["user"]["roles"]
|
||||||
json.field "badges", gql["user"]["displayBadges"]
|
json.field "badges", gql["user"]["displayBadges"]
|
||||||
json.field "chatterCount", gql["user"]["channel"]["chatters"]["count"]
|
json.field "chatterCount", gql["user"]["channel"]["chatters"]["count"]
|
||||||
|
@ -113,7 +123,7 @@ module TwAPI::Datahandlers::Twitch
|
||||||
|
|
||||||
def userId(env)
|
def userId(env)
|
||||||
if skipCache != "true"
|
if skipCache != "true"
|
||||||
if (json = Utils::Redis.retrieveFromCache("user-id_#{env.params.query["id"].try &.split(',')}"))
|
if (json = Utils::Redis.retrieveFromCache("user-id_#{env.params.query["id"].try &.split(',').to_s}"))
|
||||||
json = JSON.parse(json)
|
json = JSON.parse(json)
|
||||||
return json.to_json
|
return json.to_json
|
||||||
end
|
end
|
||||||
|
@ -128,7 +138,8 @@ module TwAPI::Datahandlers::Twitch
|
||||||
json_data = JSON.build do |json|
|
json_data = JSON.build do |json|
|
||||||
json.array do
|
json.array do
|
||||||
gql.each do |gql|
|
gql.each do |gql|
|
||||||
gql = gql["data"]
|
pp gql = gql["data"]
|
||||||
|
pp typeof(gql)
|
||||||
|
|
||||||
if (gql["user"] == nil)
|
if (gql["user"] == nil)
|
||||||
# v3 could add some feedback error message instead of an empty array.
|
# v3 could add some feedback error message instead of an empty array.
|
||||||
|
@ -159,6 +170,22 @@ module TwAPI::Datahandlers::Twitch
|
||||||
json.field "updatedAt", gql["user"]["updatedAt"]
|
json.field "updatedAt", gql["user"]["updatedAt"]
|
||||||
json.field "deletedAt", gql["user"]["deletedAt"]
|
json.field "deletedAt", gql["user"]["deletedAt"]
|
||||||
json.field "emotePrefix", gql["user"]["emoticonPrefix"]["name"]
|
json.field "emotePrefix", gql["user"]["emoticonPrefix"]["name"]
|
||||||
|
|
||||||
|
# failed attempts
|
||||||
|
# pp "1: #{gql["user"]["primaryTeam"]? || nil}"
|
||||||
|
# pp "2: #{gql["user"].try &.["primaryTeam"]?.try &.["displayName"]? || nil}"
|
||||||
|
# json.field "team", gql["user"]["primaryTeam"].try &.["displayName"]?
|
||||||
|
#
|
||||||
|
if gql["user"]["primaryTeam"] != nil
|
||||||
|
json.field "team", gql["user"]["primaryTeam"]["displayName"]
|
||||||
|
else
|
||||||
|
json.field "team", nil
|
||||||
|
end
|
||||||
|
if gql["user"]["primaryTeam"] != nil
|
||||||
|
json.field "contract", gql["user"]["programAgreement"]["type"]
|
||||||
|
else
|
||||||
|
json.field "contract", nil
|
||||||
|
end
|
||||||
json.field "roles", gql["user"]["roles"]
|
json.field "roles", gql["user"]["roles"]
|
||||||
json.field "badges", gql["user"]["displayBadges"]
|
json.field "badges", gql["user"]["displayBadges"]
|
||||||
json.field "chatterCount", gql["user"]["channel"]["chatters"]["count"]
|
json.field "chatterCount", gql["user"]["channel"]["chatters"]["count"]
|
||||||
|
|
|
@ -13,9 +13,17 @@ module TwAPI::Routes::Twitch
|
||||||
|
|
||||||
def user(env)
|
def user(env)
|
||||||
if env.params.query.has_key?("login")
|
if env.params.query.has_key?("login")
|
||||||
handleData(userLogin)
|
begin
|
||||||
|
handleData(userLogin)
|
||||||
|
rescue ex
|
||||||
|
puts ex.message
|
||||||
|
end
|
||||||
else
|
else
|
||||||
handleData(userId)
|
begin
|
||||||
|
handleData(userId)
|
||||||
|
rescue ex
|
||||||
|
puts ex.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ module TwAPI::GqlAPI
|
||||||
language
|
language
|
||||||
login
|
login
|
||||||
displayName
|
displayName
|
||||||
|
programAgreement { type }
|
||||||
|
primaryTeam { displayName name }
|
||||||
description
|
description
|
||||||
bannerImageURL
|
bannerImageURL
|
||||||
profileImageURL(width: 600)
|
profileImageURL(width: 600)
|
||||||
|
@ -158,6 +160,8 @@ module TwAPI::GqlAPI
|
||||||
language
|
language
|
||||||
login
|
login
|
||||||
displayName
|
displayName
|
||||||
|
programAgreement { type }
|
||||||
|
primaryTeam { displayName name }
|
||||||
description
|
description
|
||||||
bannerImageURL
|
bannerImageURL
|
||||||
profileImageURL(width: 600)
|
profileImageURL(width: 600)
|
||||||
|
|
Loading…
Reference in a new issue