Class: AppleMusic::Config
- Inherits:
-
Object
- Object
- AppleMusic::Config
- Defined in:
- lib/apple_music/config.rb
Constant Summary collapse
- ALGORITHM =
'ES256'
- TOKEN_EXPIRATION_TIME =
1.day
60 * 60 * 24
- DEFAULT_STOREFRONT =
'us'
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#music_id ⇒ Object
Returns the value of attribute music_id.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#secret_key_path ⇒ Object
Returns the value of attribute secret_key_path.
-
#storefront ⇒ Object
Returns the value of attribute storefront.
-
#team_id ⇒ Object
Returns the value of attribute team_id.
-
#token_expiration_time ⇒ Object
Returns the value of attribute token_expiration_time.
Instance Method Summary collapse
- #authentication_token ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 22 23 24 |
# File 'lib/apple_music/config.rb', line 16 def initialize @secret_key_path = ENV['APPLE_MUSIC_SECRET_KEY_PATH'] @secret_key = ENV['APPLE_MUSIC_SECRET_KEY'] @team_id = ENV['APPLE_MUSIC_TEAM_ID'] @music_id = ENV['APPLE_MUSIC_MUSIC_ID'] @token_expiration_time = TOKEN_EXPIRATION_TIME @adapter = Faraday.default_adapter @storefront = ENV.fetch('APPLE_MUSIC_STOREFRONT') { DEFAULT_STOREFRONT } end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
13 14 15 |
# File 'lib/apple_music/config.rb', line 13 def adapter @adapter end |
#music_id ⇒ Object
Returns the value of attribute music_id.
13 14 15 |
# File 'lib/apple_music/config.rb', line 13 def music_id @music_id end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
13 14 15 |
# File 'lib/apple_music/config.rb', line 13 def secret_key @secret_key end |
#secret_key_path ⇒ Object
Returns the value of attribute secret_key_path.
13 14 15 |
# File 'lib/apple_music/config.rb', line 13 def secret_key_path @secret_key_path end |
#storefront ⇒ Object
Returns the value of attribute storefront.
13 14 15 |
# File 'lib/apple_music/config.rb', line 13 def storefront @storefront end |
#team_id ⇒ Object
Returns the value of attribute team_id.
13 14 15 |
# File 'lib/apple_music/config.rb', line 13 def team_id @team_id end |
#token_expiration_time ⇒ Object
Returns the value of attribute token_expiration_time.
13 14 15 |
# File 'lib/apple_music/config.rb', line 13 def token_expiration_time @token_expiration_time end |
Instance Method Details
#authentication_token ⇒ Object
26 27 28 29 |
# File 'lib/apple_music/config.rb', line 26 def authentication_token private_key = OpenSSL::PKey::EC.new(apple_music_secret_key) JWT.encode(authentication_payload, private_key, ALGORITHM, kid: music_id) end |