Method: PlaylyfeClient::Connection#initialize
- Defined in:
- lib/playlyfe_client/connection.rb
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/playlyfe_client/connection.rb', line 23 def initialize( = {}) if [:type].nil? err = PlaylyfeClient::ConnectionError.new("") err.name = 'init_failed' err. = "You must pass in a type whether 'client' for client credentials flow or 'code' for auth code flow" raise err end @version = [:version] ||= 'v2' @type = [:type] @id = [:client_id] @secret = [:client_secret] @store = [:store] @load = [:load] @redirect_uri = [:redirect_uri] if @store.nil? @store = lambda { |token| puts 'Storing Token' } end if @type == 'client' get_access_token() else if [:redirect_uri].nil? err = PlaylyfeClient::ConnectionError.new("") err.name = 'init_failed' err. = 'You must pass in a redirect_uri for the auth code flow' raise err end end end |