Class: SpotifyWebApi::TrackRestrictionObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/spotify_web_api/models/track_restriction_object.rb

Overview

TrackRestrictionObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(reason = SKIP) ⇒ TrackRestrictionObject

Returns a new instance of TrackRestrictionObject.



43
44
45
# File 'lib/spotify_web_api/models/track_restriction_object.rb', line 43

def initialize(reason = SKIP)
  @reason = reason unless reason == SKIP
end

Instance Attribute Details

#reasonString

The reason for the restriction. Supported values:

  • ‘market` - The content item is not available in the given market.

  • ‘product` - The content item is not available for the user’s

subscription type.

  • ‘explicit` - The content item is explicit and the user’s account is set

to not play explicit content. Additional reasons may be added in the future. Note: If you use this field, make sure that your application safely handles unknown values.

Returns:

  • (String)


22
23
24
# File 'lib/spotify_web_api/models/track_restriction_object.rb', line 22

def reason
  @reason
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
# File 'lib/spotify_web_api/models/track_restriction_object.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reason = hash.key?('reason') ? hash['reason'] : SKIP

  # Create object from extracted values.
  TrackRestrictionObject.new(reason)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
# File 'lib/spotify_web_api/models/track_restriction_object.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reason'] = 'reason'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/spotify_web_api/models/track_restriction_object.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



32
33
34
35
36
# File 'lib/spotify_web_api/models/track_restriction_object.rb', line 32

def self.optionals
  %w[
    reason
  ]
end