Class: SpotifyWebApi::CursorPagingPlayHistoryObject

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

Overview

CursorPagingPlayHistoryObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(href = SKIP, limit = SKIP, mnext = SKIP, cursors = SKIP, total = SKIP, items = SKIP) ⇒ CursorPagingPlayHistoryObject

Returns a new instance of CursorPagingPlayHistoryObject.



66
67
68
69
70
71
72
73
74
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 66

def initialize(href = SKIP, limit = SKIP, mnext = SKIP, cursors = SKIP,
               total = SKIP, items = SKIP)
  @href = href unless href == SKIP
  @limit = limit unless limit == SKIP
  @mnext = mnext unless mnext == SKIP
  @cursors = cursors unless cursors == SKIP
  @total = total unless total == SKIP
  @items = items unless items == SKIP
end

Instance Attribute Details

#cursorsCursorObject

The cursors used to find the next set of items.

Returns:



27
28
29
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 27

def cursors
  @cursors
end

#hrefString

A link to the Web API endpoint returning the full result of the request.

Returns:

  • (String)


14
15
16
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 14

def href
  @href
end

#itemsArray[PlayHistoryObject]

The total number of items available to return.

Returns:



35
36
37
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 35

def items
  @items
end

#limitInteger

The maximum number of items in the response (as set in the query or by default).

Returns:

  • (Integer)


19
20
21
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 19

def limit
  @limit
end

#mnextString

URL to the next page of items. ( ‘null` if none)

Returns:

  • (String)


23
24
25
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 23

def mnext
  @mnext
end

#totalInteger

The total number of items available to return.

Returns:

  • (Integer)


31
32
33
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 31

def total
  @total
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  href = hash.key?('href') ? hash['href'] : SKIP
  limit = hash.key?('limit') ? hash['limit'] : SKIP
  mnext = hash.key?('next') ? hash['next'] : SKIP
  cursors = CursorObject.from_hash(hash['cursors']) if hash['cursors']
  total = hash.key?('total') ? hash['total'] : SKIP
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (PlayHistoryObject.from_hash(structure) if structure)
    end
  end

  items = SKIP unless hash.key?('items')

  # Create object from extracted values.
  CursorPagingPlayHistoryObject.new(href,
                                    limit,
                                    mnext,
                                    cursors,
                                    total,
                                    items)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['href'] = 'href'
  @_hash['limit'] = 'limit'
  @_hash['mnext'] = 'next'
  @_hash['cursors'] = 'cursors'
  @_hash['total'] = 'total'
  @_hash['items'] = 'items'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
59
# File 'lib/spotify_web_api/models/cursor_paging_play_history_object.rb', line 50

def self.optionals
  %w[
    href
    limit
    mnext
    cursors
    total
    items
  ]
end