Sha256: b7b519adfebfb3d2b0ed1b77ff75a632db42a820730d08fc8d15132298c10a43
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
module SparkApi module Models class ListingCart < Base extend Finders include Concerns::Savable, Concerns::Destroyable self.element_name="listingcarts" def initialize(attributes={}) @contact_id = attributes.delete(:contact_id) if attributes[:contact_id] super(attributes) end def ListingIds=(listing_ids) attributes["ListingIds"] = Array(listing_ids) end def Name=(name) attributes["Name"] = name end def path if @contact_id "/contacts/#{@contact_id}/listingcarts" else super end end def add_listing(listing) ids = listing.respond_to?(:Id) ? listing.Id : listing results = connection.post("#{self.resource_uri}", {"ListingIds" => Array(ids)}) self.ListingCount = results.first["ListingCount"] end def remove_listing(listing) id = listing.respond_to?(:Id) ? listing.Id : listing.to_s results = connection.delete("#{self.class.path}/#{self.Id}/listings/#{id}") self.ListingCount = results.first["ListingCount"] end def self.for(listings,arguments={}) keys = Array(listings).map { |l| l.respond_to?(:Id) ? l.Id : l.to_s } collect(connection.get("/#{self.element_name}/for/#{keys.join(",")}", arguments)) end def self.my(arguments={}) collect(connection.get("/my/#{self.element_name}", arguments)) end def self.portal(arguments={}) collect(connection.get("/#{self.element_name}/portal", arguments)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spark_api-1.3.16 | lib/spark_api/models/listing_cart.rb |
spark_api-1.3.15 | lib/spark_api/models/listing_cart.rb |