Class: MercadoLibre::Item
- Inherits:
-
Object
- Object
- MercadoLibre::Item
- Defined in:
- lib/mercado_libre/item.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Item
constructor
A new instance of Item.
- #publishable_hash ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Item
Returns a new instance of Item.
19 20 21 22 23 24 |
# File 'lib/mercado_libre/item.rb', line 19 def initialize(params = {}) params = Hash[params.map { |k, v| [k.to_sym, v] }] #Symbolize keys self.class.attr_list.each do |k| send("#{k}=", params[k]) if params[k] end end |
Class Method Details
.attr_list ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/mercado_libre/item.rb', line 9 def self.attr_list other_fields = [:id, :start_time, :stop_time, :end_time, :permalink, :thumbnail, :secure_thumbnail, :descriptions, :accepts_mercadopago, :status, :date_created, :last_updated, :non_mercado_pago_payment_methods ] self.publishable_params + other_fields end |
.publishable_params ⇒ Object
3 4 5 6 7 |
# File 'lib/mercado_libre/item.rb', line 3 def self.publishable_params [:site_id, :title, :category_id, :price, :currency_id, :available_quantity, :buying_mode, :listing_type_id, :condition, :description, :video_id, :warranty, :pictures, :shipping] end |
Instance Method Details
#publishable_hash ⇒ Object
26 27 28 29 30 31 |
# File 'lib/mercado_libre/item.rb', line 26 def publishable_hash hash = {} self.class.publishable_params.each { |k| hash[k] = send(k) } hash end |