Class: Svpply::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/svpply/collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Collection

Returns a new instance of Collection.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/svpply/collection.rb', line 15

def initialize(hash)
  @id = hash["id"]
  @title = hash["title"]
  @masthead = hash["masthead"]
  @masthead_height = hash["masthead_height"]
  @masthead_width = hash["masthead_width"]
  @preview_type = hash["preview_type"]
  @preview_image = hash["preview_image"]
  @representative_item_id = hash["representative_item_id"]
  @representative_item_height = hash["representative_item_height"]
  @representative_item_width = hash["representative_item_width"]
  @products_count = hash["products_count"]
  @is_private = hash["is_private"]
  @is_wishlist = hash["is_wishlist"]
  @date_created = hash["date_created"]
  @date_updated = hash["date_updated"]
  @creator = hash["creator"]
  @creator["portrait"] = @creator["avatar"].gsub("avatars", "portraits")
  @svpply_url = "https://svpply.com/collections/#{@id}"
end

Instance Attribute Details

#creatorObject (readonly)

Returns the value of attribute creator.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def creator
  @creator
end

#date_createdObject (readonly)

Returns the value of attribute date_created.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def date_created
  @date_created
end

#date_updatedObject (readonly)

Returns the value of attribute date_updated.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def date_updated
  @date_updated
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def id
  @id
end

#is_privateObject (readonly)

Returns the value of attribute is_private.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def is_private
  @is_private
end

#is_wishlistObject (readonly)

Returns the value of attribute is_wishlist.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def is_wishlist
  @is_wishlist
end

#mastheadObject (readonly)

Returns the value of attribute masthead.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def masthead
  @masthead
end

#masthead_heightObject (readonly)

Returns the value of attribute masthead_height.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def masthead_height
  @masthead_height
end

#masthead_widthObject (readonly)

Returns the value of attribute masthead_width.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def masthead_width
  @masthead_width
end

#preview_imageObject (readonly)

Returns the value of attribute preview_image.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def preview_image
  @preview_image
end

#preview_typeObject (readonly)

Returns the value of attribute preview_type.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def preview_type
  @preview_type
end

#products_countObject (readonly)

Returns the value of attribute products_count.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def products_count
  @products_count
end

#representative_item_heightObject (readonly)

Returns the value of attribute representative_item_height.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def representative_item_height
  @representative_item_height
end

#representative_item_idObject (readonly)

Returns the value of attribute representative_item_id.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def representative_item_id
  @representative_item_id
end

#representative_item_widthObject (readonly)

Returns the value of attribute representative_item_width.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def representative_item_width
  @representative_item_width
end

#svpply_urlObject (readonly)

Returns the value of attribute svpply_url.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def svpply_url
  @svpply_url
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/svpply/collection.rb', line 3

def title
  @title
end

Class Method Details

.find(id) ⇒ Object



7
8
9
# File 'lib/svpply/collection.rb', line 7

def self.find(id)
  new(Client.get_response("/collections/#{id}.json")["collection"])
end

.products(id, attrs = nil) ⇒ Object



11
12
13
# File 'lib/svpply/collection.rb', line 11

def self.products(id, attrs=nil)
  ProductCollection.new(Client.get_response("/collections/#{id}/products.json", attrs)).products
end