1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.user.social.models.facebook
21 
22 import io.circe.Decoder
23 import org.make.api.user.social.models
24 
25 final case class UserInfo(id: String, email: Option[String], firstName: Option[String]) {
26   def pictureUrl: String = s"https://graph.facebook.com/v12.0/$id/picture?width=512&height=512"
27 
28   def toUserInfo(): models.UserInfo = {
29     models.UserInfo(
30       email = email,
31       firstName = firstName,
32       facebookId = Some(id),
33       picture = Option(pictureUrl),
34       dateOfBirth = None
35     )
36   }
37 }
38 
39 object UserInfo {
40   implicit val decoder: Decoder[UserInfo] = Decoder.forProduct3("id", "email", "first_name")(UserInfo.apply)
41 }
Line Stmt Id Pos Tree Symbol Tests Code
29 23733 1097 - 1097 Select org.make.api.user.social.models.UserInfo.apply$default$5 org.make.api.user.social.models.UserInfo.apply$default$5
29 27097 1097 - 1097 Select org.make.api.user.social.models.UserInfo.apply$default$3 org.make.api.user.social.models.UserInfo.apply$default$3
29 27183 1097 - 1097 Select org.make.api.user.social.models.UserInfo.apply$default$8 org.make.api.user.social.models.UserInfo.apply$default$8
29 25804 1097 - 1097 Select org.make.api.user.social.models.UserInfo.apply$default$4 org.make.api.user.social.models.UserInfo.apply$default$4
29 25238 1090 - 1252 Apply org.make.api.user.social.models.UserInfo.apply org.make.api.user.social.models.UserInfo.apply(x$1, x$2, x$6, x$7, x$8, x$3, x$4, x$9, x$5)
30 23431 1121 - 1126 Select org.make.api.user.social.models.facebook.UserInfo.email UserInfo.this.email
31 27242 1146 - 1155 Select org.make.api.user.social.models.facebook.UserInfo.firstName UserInfo.this.firstName
32 24994 1181 - 1183 Select org.make.api.user.social.models.facebook.UserInfo.id UserInfo.this.id
32 23917 1176 - 1184 Apply scala.Some.apply scala.Some.apply[String](UserInfo.this.id)
33 25316 1202 - 1220 Apply scala.Option.apply scala.Option.apply[String](UserInfo.this.pictureUrl)
33 27642 1209 - 1219 Select org.make.api.user.social.models.facebook.UserInfo.pictureUrl UserInfo.this.pictureUrl
34 23118 1242 - 1246 Select scala.None scala.None
40 25922 1370 - 1370 Select io.circe.Decoder.decodeString circe.this.Decoder.decodeString
40 23745 1370 - 1370 ApplyToImplicitArgs io.circe.Decoder.decodeOption circe.this.Decoder.decodeOption[String](circe.this.Decoder.decodeString)
40 25324 1357 - 1369 Literal <nosymbol> "first_name"
40 22976 1322 - 1386 ApplyToImplicitArgs io.circe.ProductDecoders.forProduct3 io.circe.Decoder.forProduct3[org.make.api.user.social.models.facebook.UserInfo, String, Option[String], Option[String]]("id", "email", "first_name")(((id: String, email: Option[String], firstName: Option[String]) => UserInfo.apply(id, email, firstName)))(circe.this.Decoder.decodeString, circe.this.Decoder.decodeOption[String](circe.this.Decoder.decodeString), circe.this.Decoder.decodeOption[String](circe.this.Decoder.decodeString))
40 25174 1370 - 1370 ApplyToImplicitArgs io.circe.Decoder.decodeOption circe.this.Decoder.decodeOption[String](circe.this.Decoder.decodeString)
40 24046 1342 - 1346 Literal <nosymbol> "id"
40 23050 1371 - 1385 Apply org.make.api.user.social.models.facebook.UserInfo.apply UserInfo.apply(id, email, firstName)
40 27189 1370 - 1370 Select io.circe.Decoder.decodeString circe.this.Decoder.decodeString
40 27655 1348 - 1355 Literal <nosymbol> "email"
40 27104 1370 - 1370 Select io.circe.Decoder.decodeString circe.this.Decoder.decodeString