class Cloth::Item
Attributes
data[R]
id[R]
user[R]
Public Class Methods
new(id, data)
click to toggle source
# File lib/cloth/item.rb, line 3 def initialize(id, data) @id = id @data = data @user = data["user_id"] if @data && data["user_id"] end
recommend(id, data = nil)
click to toggle source
# File lib/cloth/item.rb, line 31 def recommend(id, data = nil) Item.new(id, data).recommend end
recommendations(id, data = nil)
click to toggle source
# File lib/cloth/item.rb, line 39 def recommendations(id, data = nil) Item.new(id, data).recommendations end
unrecommend(id, data = nil)
click to toggle source
# File lib/cloth/item.rb, line 35 def unrecommend(id, data = nil) Item.new(id, data).unrecommend end
Public Instance Methods
recommend()
click to toggle source
# File lib/cloth/item.rb, line 13 def recommend Cloth.client.post("/api/items/recommend", { body: { item: { id: id, data: data } } }) end
recommendations()
click to toggle source
# File lib/cloth/item.rb, line 21 def recommendations resp = Cloth.client.get("/api/items/#{id}/recommendations") if resp['recommendations'] resp['recommendations'] else resp end end
unrecommend()
click to toggle source
# File lib/cloth/item.rb, line 17 def unrecommend Cloth.client.post("/api/items/unrecommend", { body: { item: { id: id, data: data } } }) end