Class: Sidemash::Sdk::StreamSquareRestCollection
- Inherits:
-
Object
- Object
- Sidemash::Sdk::StreamSquareRestCollection
- Defined in:
- lib/sidemash/sdk/stream_square_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.
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
#items ⇒ Object (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 |
#pagination ⇒ Object (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 |
#url ⇒ Object (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
._type ⇒ Object
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_hash ⇒ Object
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_remote ⇒ Object
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_s ⇒ Object
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 |