Class: Sidemash::Sdk::StreamSquareRestCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/sidemash/sdk/stream_square_rest_collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, pagination, items) ⇒ StreamSquareRestCollection

Returns a new instance of StreamSquareRestCollection.



26
27
28
29
30
31
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 26

def initialize(url, pagination, items)
  @_type = 'StreamSquareRestCollection'
  @url = url
  @pagination = pagination
  @items = items
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



24
25
26
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 24

def items
  @items
end

#paginationObject (readonly)

Returns the value of attribute pagination.



23
24
25
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 23

def pagination
  @pagination
end

#urlObject (readonly)

Returns the value of attribute url.



22
23
24
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 22

def url
  @url
end

Class Method Details

._typeObject



33
34
35
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 33

def self._type
  'StreamSquareRestCollection'
end

.from_hash(h) ⇒ Object



66
67
68
69
70
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 66

def self.from_hash(h)
  StreamSquareRestCollection.new(h['url'],
                                 Pagination.from_hash(h['pagination']),
                                 h['items'].map { |item_hash| StreamSquare.from_hash(item_hash) })
end

.from_json(js) ⇒ Object



37
38
39
40
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 37

def self.from_json(js)
  h = JSON.parse(js)
  StreamSquareRestCollection.from_hash(h)
end

.from_remote(h) ⇒ Object



60
61
62
63
64
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 60

def self.from_remote(h)
  StreamSquareRestCollection.new(h['url'],
                                 Pagination.from_remote(h['pagination']),
                                 h['items'].map { |item_hash| StreamSquare.from_remote(item_hash) })
end

Instance Method Details

#to_hashObject



51
52
53
54
55
56
57
58
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 51

def to_hash
  result = {}
  result[:_type] = @_type
  result[:url] = @url
  result[:pagination] = @pagination.to_hash
  result[:items] = @items.map { |el| el.to_hash }
  result
end

#to_json(*a) ⇒ Object



72
73
74
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 72

def to_json(*a)
  to_hash.to_json(*a)
end

#to_remoteObject



42
43
44
45
46
47
48
49
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 42

def to_remote
  result = {}
  result[:_type] = @_type
  result[:url] = @url
  result[:pagination] = @pagination.to_remote
  result[:items] = @items.map { |el| el.to_remote }
  result
end

#to_sObject



76
77
78
79
80
# File 'lib/sidemash/sdk/stream_square_rest_collection.rb', line 76

def to_s
  ('StreamSquareRestCollection(url=' + @url +
                              ', pagination=' + @pagination.to_s +
                              ', items=' + @items.to_s + ')')
end