Class: Sidemash::SDK::StreamSquareRestCollection
- Inherits:
-
Object
- Object
- Sidemash::SDK::StreamSquareRestCollection
- Defined in:
- lib/sidemash/sdk/rest_collection.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#pagination ⇒ Object
readonly
Returns the value of attribute pagination.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url, pagination, items) ⇒ StreamSquareRestCollection
constructor
A new instance of StreamSquareRestCollection.
- #to_hash ⇒ Object
- #to_json(*a) ⇒ Object
- #to_remote ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url, pagination, items) ⇒ StreamSquareRestCollection
Returns a new instance of StreamSquareRestCollection.
9 10 11 12 13 14 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 9 def initialize(url, pagination, items) @_type = 'StreamSquareRestCollection' @url = url @pagination = pagination @items = items end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 7 def items @items end |
#pagination ⇒ Object (readonly)
Returns the value of attribute pagination.
6 7 8 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 6 def pagination @pagination end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 5 def url @url end |
Class Method Details
._type ⇒ Object
16 17 18 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 16 def self._type 'StreamSquareRestCollection' end |
.from_hash(h) ⇒ Object
49 50 51 52 53 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 49 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
20 21 22 23 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 20 def self.from_json(js) h = JSON.parse(js) StreamSquareRestCollection.from_hash(h) end |
.from_remote(h) ⇒ Object
43 44 45 46 47 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 43 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_hash ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 34 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
55 56 57 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 55 def to_json(*a) to_hash.to_json(*a) end |
#to_remote ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 25 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_s ⇒ Object
59 60 61 62 63 |
# File 'lib/sidemash/sdk/rest_collection.rb', line 59 def to_s ('StreamSquareRestCollection(url=' + @url + ', pagination=' + @pagination.to_s + ', items=' + @items.to_s + ')') end |