Class: RingCentralSdk::REST::ConfigApp

Inherits:
Object
  • Object
show all
Defined in:
lib/ringcentral_sdk/rest/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_key = '', app_secret = '', server_url = RingCentralSdk::RC_SERVER_SANDBOX, opts = {}) ⇒ ConfigApp

Returns a new instance of ConfigApp.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ringcentral_sdk/rest/config.rb', line 52

def initialize(app_key='', app_secret='', server_url=RingCentralSdk::RC_SERVER_SANDBOX, opts={})
  @key = app_key
  @secret = app_secret
  @server_url = server_url
  if opts.key?(:redirect_url)
    @redirect_url = opts[:redirect_url]
  elsif opts.key?(:redirect_uri)
    @redirect_url = opts[:redirect_uri]
  else
    @redirect_url = ''
  end
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



47
48
49
# File 'lib/ringcentral_sdk/rest/config.rb', line 47

def key
  @key
end

#redirect_urlObject

Returns the value of attribute redirect_url.



50
51
52
# File 'lib/ringcentral_sdk/rest/config.rb', line 50

def redirect_url
  @redirect_url
end

#secretObject

Returns the value of attribute secret.



48
49
50
# File 'lib/ringcentral_sdk/rest/config.rb', line 48

def secret
  @secret
end

#server_urlObject

Returns the value of attribute server_url.



49
50
51
# File 'lib/ringcentral_sdk/rest/config.rb', line 49

def server_url
  @server_url
end

Instance Method Details

#load_envObject



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ringcentral_sdk/rest/config.rb', line 65

def load_env
  ['RC_APP_KEY', 'RC_APP_SECRET', 'RC_APP_SERVER_URL', 'RC_APP_REDIRECT_URL'].each do |var|
    if !ENV.key?(var)
      fail "environment variable '#{var}' not found"
    end
  end
  
  @key = ENV['RC_APP_KEY']
  @secret = ENV['RC_APP_SECRET']
  @server_url = ENV['RC_APP_SERVER_URL']
  @redirect_url = ENV['RC_APP_REDIRECT_URL']
end

#to_hashObject



78
79
80
81
82
83
84
85
# File 'lib/ringcentral_sdk/rest/config.rb', line 78

def to_hash
  {
    key: @key,
    secret: @secret,
    server_url: @server_url,
    redirect_url: @redirect_url
  }
end