Class: SpotifyWebApi::ErrorObject

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

Overview

ErrorObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(status = nil, message = nil) ⇒ ErrorObject

Returns a new instance of ErrorObject.



41
42
43
44
# File 'lib/spotify_web_api/models/error_object.rb', line 41

def initialize(status = nil, message = nil)
  @status = status
  @message = message
end

Instance Attribute Details

#messageString

A short description of the cause of the error.

Returns:

  • (String)


21
22
23
# File 'lib/spotify_web_api/models/error_object.rb', line 21

def message
  @message
end

#statusInteger

The HTTP status code (also returned in the response header; see [Response Status Codes](/documentation/web-api/concepts/api-calls#response-status-codes) for more information).

Returns:

  • (Integer)


17
18
19
# File 'lib/spotify_web_api/models/error_object.rb', line 17

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  status = hash.key?('status') ? hash['status'] : nil
  message = hash.key?('message') ? hash['message'] : nil

  # Create object from extracted values.
  ErrorObject.new(status,
                  message)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



37
38
39
# File 'lib/spotify_web_api/models/error_object.rb', line 37

def self.nullables
  []
end

.optionalsObject

An array for optional fields



32
33
34
# File 'lib/spotify_web_api/models/error_object.rb', line 32

def self.optionals
  []
end