Class: EcwidApi::Product

Inherits:
Entity
  • Object
show all
Defined in:
lib/ecwid_api/product.rb

Instance Method Summary collapse

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

#combinationsObject



53
54
55
# File 'lib/ecwid_api/product.rb', line 53

def combinations
  @combinations ||= Api::ProductCombinations.new(self, client)
end

#createdObject



57
58
59
# File 'lib/ecwid_api/product.rb', line 57

def created
  @created ||= Time.parse(super)
end

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

#updatedObject



61
62
63
# File 'lib/ecwid_api/product.rb', line 61

def updated
  @updated ||= Time.parse(super)
end

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