class SpreadsheetToJson::Config

Public Class Methods

get_access_token(config_path) click to toggle source

Get the access_token of the auth

# File lib/spreadsheet_to_json/config.rb, line 12
def get_access_token(config_path)
  config = get_settings_from_yml(config_path)
  client = OAuth2::Client.new(
    config['auth']['client_id'],
    config['auth']['client_secret'],
    site: config['auth']['site'],
    token_url: config['auth']['token_url'],
    authorize_url: config['auth']['token_url']
  )
  auth_token = OAuth2::AccessToken.from_hash(
    client,
    {
      :refresh_token => config['auth']['refresh_token'],
      :expires_at => 3600
    }
  )
  auth_token.refresh!.token
end
get_spreadsheet_key(config_path) click to toggle source

Get the spreadsheet_key

# File lib/spreadsheet_to_json/config.rb, line 7
def get_spreadsheet_key(config_path)
  get_settings_from_yml(config_path)['spreadsheet_key']
end

Private Class Methods

get_settings_from_yml(path) click to toggle source

Get config file

# File lib/spreadsheet_to_json/config.rb, line 33
def get_settings_from_yml(path)
  File.open(path) { |file| YAML.load(file) }
end