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
21 
22 import com.typesafe.config.Config
23 import org.make.api.ConfigComponent
24 
25 trait SocialProvidersConfiguration {
26   def google: GoogleConfiguration
27 }
28 
29 trait GoogleConfiguration {
30   def apiKey: String
31   def clientId: String
32   def scopes: String
33 }
34 
35 trait SocialProvidersConfigurationComponent {
36   def socialProvidersConfiguration: SocialProvidersConfiguration
37 }
38 
39 trait DefaultSocialProvidersConfigurationComponent extends SocialProvidersConfigurationComponent {
40   self: ConfigComponent =>
41 
42   override lazy val socialProvidersConfiguration: SocialProvidersConfiguration =
43     new DefaultSocialProvidersConfiguration(config.getConfig("make-api.social-providers"))
44 
45   class DefaultSocialProvidersConfiguration(socialConfig: Config) extends SocialProvidersConfiguration {
46     override val google = new DefaultGoogleConfiguration(socialConfig.getConfig("google"))
47   }
48 
49   class DefaultGoogleConfiguration(googleConfig: Config) extends GoogleConfiguration {
50     override val apiKey: String = googleConfig.getString("api-key")
51     override val clientId: String = googleConfig.getString("client-id")
52     override val scopes: String = googleConfig.getString("scopes")
53   }
54 }
Line Stmt Id Pos Tree Symbol Tests Code
46 47822 1596 - 1628 Apply com.typesafe.config.Config.getConfig DefaultSocialProvidersConfiguration.this.socialConfig.getConfig("google")
46 43657 1565 - 1629 Apply org.make.api.user.social.DefaultSocialProvidersConfigurationComponent.DefaultGoogleConfiguration.<init> new DefaultSocialProvidersConfigurationComponent.this.DefaultGoogleConfiguration(DefaultSocialProvidersConfiguration.this.socialConfig.getConfig("google"))
50 36863 1756 - 1789 Apply com.typesafe.config.Config.getString DefaultGoogleConfiguration.this.googleConfig.getString("api-key")
51 49161 1826 - 1861 Apply com.typesafe.config.Config.getString DefaultGoogleConfiguration.this.googleConfig.getString("client-id")
52 41051 1896 - 1928 Apply com.typesafe.config.Config.getString DefaultGoogleConfiguration.this.googleConfig.getString("scopes")