Skip to content

Commit

Permalink
Use JSON::Serializable instead of deprecated JSON.mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł Świątkowski committed Sep 22, 2020
1 parent dc16e17 commit dff240a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 50 deletions.
20 changes: 10 additions & 10 deletions src/multi_auth/providers/facebook.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ class MultiAuth::Provider::Facebook < MultiAuth::Provider
end

private class FbUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth2::AccessToken?
property picture_url : String?

JSON.mapping(
id: String,
name: String,
last_name: String?,
first_name: String?,
email: String?,
location: String?,
about: String?,
website: String?
)
property id : String
property name : String
property last_name : String?
property first_name : String?
property email : String?
property location : String?
property about : String?
property website : String?
end

private def fetch_fb_user(code)
Expand Down
24 changes: 13 additions & 11 deletions src/multi_auth/providers/github.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ class MultiAuth::Provider::Github < MultiAuth::Provider
end

private class GhUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth2::AccessToken?

JSON.mapping(
id: {type: String, converter: String::RawConverter},
name: String,
email: String?,
login: String,
location: String?,
bio: String?,
avatar_url: String?,
blog: String?,
html_url: String?
)
@[JSON::Field(converter: String::RawConverter)]
property id : String

property name : String
property email : String?
property login : String
property location : String?
property bio : String?
property avatar_url : String?
property blog : String?
property html_url : String?
end

private def fetch_gh_user(code)
Expand Down
22 changes: 12 additions & 10 deletions src/multi_auth/providers/twitter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ class MultiAuth::Provider::Twitter < MultiAuth::Provider
end

private class TwUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth::AccessToken?

JSON.mapping(
id: {type: String, converter: String::RawConverter},
name: String,
screen_name: String,
location: String?,
description: String?,
url: String?,
profile_image_url: String?,
email: String?
)
@[JSON::Field(converter: String::RawConverter)]
property id : String

property name : String
property screen_name : String
property location : String?
property description : String?
property url : String?
property profile_image_url : String?
property email : String?
end

private def fetch_tw_user(oauth_token, oauth_verifier)
Expand Down
38 changes: 19 additions & 19 deletions src/multi_auth/providers/vk.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ class MultiAuth::Provider::Vk < MultiAuth::Provider
end

class VkTitle
JSON.mapping(
title: String
)
include JSON::Serializable
property title : String
end

class VkUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth2::AccessToken?
property email : String?
Expand All @@ -51,25 +52,24 @@ class MultiAuth::Provider::Vk < MultiAuth::Provider
"#{last_name} #{first_name}"
end

JSON.mapping(
id: {type: String, converter: String::RawConverter},
last_name: String?,
first_name: String?,
site: String?,
city: VkTitle?,
country: VkTitle?,
domain: String?,
about: String?,
photo_max_orig: String?,
mobile_phone: String?,
home_phone: String?
)
@[JSON::Field(converter: String::RawConverter)]
property id : String

property last_name : String?
property first_name : String?
property site : String?
property city : VkTitle?
property country : VkTitle?
property domain : String?
property about : String?
property photo_max_orig : String?
property mobile_phone : String?
property home_phone : String?
end

class VkResponse
JSON.mapping(
response: Array(VkUser),
)
include JSON::Serializable
property response : Array(VkUser)
end

private def fetch_vk_user(code)
Expand Down

0 comments on commit dff240a

Please sign in to comment.