Class: EcwidApi::Product
Instance Method Summary collapse
- #combinations ⇒ Object
- #created ⇒ Object
-
#delete_gallery_images! ⇒ Object
Public: Deletes all of the gallery images for a Product.
- #updated ⇒ Object
-
#upload_gallery_images!(*filenames) ⇒ Object
Public: Uploads gallery images for a Product.
-
#upload_image!(filename) ⇒ Object
Public: Uploads a primary image for a Product.
Methods inherited from Entity
#==, #[], #assign_attributes, #assign_raw_attributes, define_accessor, #destroy!, ecwid_accessor, ecwid_reader, ecwid_writer, #initialize, #marshal_dump, #marshal_load, #save, #to_hash, #to_json, #update_attributes, #update_raw_attributes, #url
Constructor Details
This class inherits a constructor from EcwidApi::Entity
Instance Method Details
#combinations ⇒ Object
53 54 55 |
# File 'lib/ecwid_api/product.rb', line 53 def combinations @combinations ||= Api::ProductCombinations.new(self, client) end |
#created ⇒ Object
57 58 59 |
# File 'lib/ecwid_api/product.rb', line 57 def created @created ||= Time.parse(super) end |
#delete_gallery_images! ⇒ Object
Public: Deletes all of the gallery images for a Product
Raises ResponseError if the API returns an error
Returns a Faraday::Response object
49 50 51 |
# File 'lib/ecwid_api/product.rb', line 49 def delete_gallery_images! client.delete("#{url}/gallery") end |
#updated ⇒ Object
61 62 63 |
# File 'lib/ecwid_api/product.rb', line 61 def updated @updated ||= Time.parse(super) end |
#upload_gallery_images!(*filenames) ⇒ Object
Public: Uploads gallery images for a Product
*filenames - Strings that are either a local file name or URL
Raises ResponseError if the API returns an error
Returns an Array of Faraday::Response object
38 39 40 41 42 |
# File 'lib/ecwid_api/product.rb', line 38 def upload_gallery_images!(*filenames) filenames.map do |filename| client.post_image("#{url}/gallery", filename) end end |
#upload_image!(filename) ⇒ Object
Public: Uploads a primary image for a Product
filename - a String that is either a local file name or URL
Raises ResponseError if the API returns an error
Returns a Faraday::Response object
27 28 29 |
# File 'lib/ecwid_api/product.rb', line 27 def upload_image!(filename) client.post_image("#{url}/image", filename) end |