Class: GoogleClient::Configuration
- Inherits:
-
Object
- Object
- GoogleClient::Configuration
- Defined in:
- lib/google_client/configuration.rb
Overview
Configuration class
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#app_version ⇒ Object
Returns the value of attribute app_version.
-
#auth_uri ⇒ Object
Returns the value of attribute auth_uri.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#javascript_origins ⇒ Object
Returns the value of attribute javascript_origins.
-
#redirect_uris ⇒ Object
Returns the value of attribute redirect_uris.
-
#token_uri ⇒ Object
Returns the value of attribute token_uri.
Instance Method Summary collapse
- #authorization ⇒ Object
- #client ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
42 43 44 45 46 47 |
# File 'lib/google_client/configuration.rb', line 42 def initialize @redirect_uris = [] @javascript_origins = [] @auth_uri = 'https://accounts.google.com/o/oauth2/auth' @token_uri = 'https://accounts.google.com/o/oauth2/token' end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def app_name @app_name end |
#app_version ⇒ Object
Returns the value of attribute app_version.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def app_version @app_version end |
#auth_uri ⇒ Object
Returns the value of attribute auth_uri.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def auth_uri @auth_uri end |
#client_id ⇒ Object
Returns the value of attribute client_id.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def client_secret @client_secret end |
#javascript_origins ⇒ Object
Returns the value of attribute javascript_origins.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def javascript_origins @javascript_origins end |
#redirect_uris ⇒ Object
Returns the value of attribute redirect_uris.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def redirect_uris @redirect_uris end |
#token_uri ⇒ Object
Returns the value of attribute token_uri.
33 34 35 |
# File 'lib/google_client/configuration.rb', line 33 def token_uri @token_uri end |
Instance Method Details
#authorization ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/google_client/configuration.rb', line 66 def errors = [] errors << 'app_name not set' unless @app_name.present? errors << 'app_version not set' unless @app_version.present? fail "Couldn't create the authorizationt:\n" << errors.to_sentence unless errors.blank? Google::APIClient::ClientSecrets.new(to_hash). end |
#client ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/google_client/configuration.rb', line 49 def client return @client if @client errors = [] # symbols = %i(app_name app_version) # symbols.each do |sym| # errors << errors_for(sym) # end errors << 'app_name not set' unless @app_name.present? errors << 'app_version not set' unless @app_version.present? fail "Couldn't create the client:\n" << errors.to_sentence unless errors.blank? @client = Google::APIClient.new(application_name: @app_name, application_version: @app_version) end |
#to_hash ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/google_client/configuration.rb', line 76 def to_hash { web: { client_id: @client_id, client_secret: @client_secret, redirect_uris: @redirect_uris, javascript_origins: @javascript_origins, auth_uri: @auth_uri, token_uri: @token_uri, } }.with_indifferent_access end |