class Spotify::SDK
Spotify::SDK
contains the complete Ruby DSL to interact with the Spotify
Platform.
Constants
- SDK_COMPONENTS
This is where we mount new
SDK
components to theSpotify::SDK
object. Simply add a key (this is your identifier) with the value being the object.Notes:
-
Make sure your
SDK
component is being loaded at the top of this page. -
You can name your identifier whatever you want:
-
This will be what people will use to call your code
-
For example: it would be the `connect` in `Spotify::SDK.new(@session).connect`
-
-
We'll call .new on your class, providing one parameter being the instance of this
SDK
(aka self). -
Make sure to a test for it in spec/lib/spotify/sdk_spec.rb (see how we did it for others)
-
Attributes
Public Class Methods
Initialize the Spotify
SDK
object.
@example
# Example 1: Load it in from an access token value. @sdk = Spotify::SDK.new("access_token_here") # Example 2: Load it in with values from your database. @sdk = Spotify::SDK.new({ access_token: "access_token_here", expires_in: 3_000_000, refresh_token: "refresh_token_here" }) # Example 4: Load it in from an OAuth2::AccessToken object. @sdk = Spotify::SDK.new(@auth.auth_code.get_token("auth code")) # Example 5: Load it from a query string or a fully qualified URL. @sdk = Spotify::SDK.new("https://localhost:8080/#token=...&expires_in=...") @sdk = Spotify::SDK.new("token=...&expires_in=...")
@param [String,Hash,OAuth2::AccessToken] session Any supported object containing an access token.
# File lib/spotify/sdk.rb, line 48 def initialize(session) raise "Invalid Spotify::Accounts::Session object" unless session.instance_of?(Spotify::Accounts::Session) @session = session mount_sdk_components end