Module: Mercadolibre::Core::Items
- Included in:
- Api
- Defined in:
- lib/mercadolibre/core/items.rb
Instance Method Summary collapse
- #create_item(attrs) ⇒ Object
- #delete_item_attributes(item_id, attr_list) ⇒ Object
- #get_item(item_id, attrs = {}) ⇒ Object
- #get_item_available_upgrades(item_id) ⇒ Object
- #get_item_description(item_id) ⇒ Object
- #get_item_identifiers(item_id) ⇒ Object
- #get_items(item_ids, attrs = {}) ⇒ Object
- #relist_item(item_id, attrs) ⇒ Object
- #update_item(item_id, attrs) ⇒ Object
- #update_item_attributes(item_id, attrs) ⇒ Object
- #update_item_description(item_id, text) ⇒ Object
- #update_item_identifiers(item_id, attrs) ⇒ Object
- #validate_item(attrs) ⇒ Object
Instance Method Details
#create_item(attrs) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/mercadolibre/core/items.rb', line 4 def create_item(attrs) payload = attrs.to_json headers = { content_type: :json } post_request("/items?access_token=#{@access_token}", payload, headers).body end |
#delete_item_attributes(item_id, attr_list) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/mercadolibre/core/items.rb', line 70 def delete_item_attributes(item_id, attr_list) payload = attr_list.map { |x| { id: x } }.to_json headers = { content_type: :json, accept: :json } put_request("/items/#{item_id}?access_token=#{@access_token}", payload, headers).status_code == 200 end |
#get_item(item_id, attrs = {}) ⇒ Object
12 13 14 |
# File 'lib/mercadolibre/core/items.rb', line 12 def get_item(item_id, attrs={}) get_request("/items/#{item_id}", attrs.merge({ access_token: @access_token })).body end |
#get_item_available_upgrades(item_id) ⇒ Object
38 39 40 |
# File 'lib/mercadolibre/core/items.rb', line 38 def get_item_available_upgrades(item_id) get_request("/items/#{item_id}/available_upgrades?access_token=@access_token").body end |
#get_item_description(item_id) ⇒ Object
50 51 52 |
# File 'lib/mercadolibre/core/items.rb', line 50 def get_item_description(item_id) get_request("/items/#{item_id}/description").body end |
#get_item_identifiers(item_id) ⇒ Object
78 79 80 |
# File 'lib/mercadolibre/core/items.rb', line 78 def get_item_identifiers(item_id) get_request("/items/#{item_id}/product_identifiers").body end |
#get_items(item_ids, attrs = {}) ⇒ Object
16 17 18 |
# File 'lib/mercadolibre/core/items.rb', line 16 def get_items(item_ids, attrs={}) get_request("/items", attrs.merge({ids: item_ids.uniq.join(','), access_token: @access_token})).body end |
#relist_item(item_id, attrs) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/mercadolibre/core/items.rb', line 42 def relist_item(item_id, attrs) payload = attrs.to_json headers = { content_type: :json, accept: :json } post_request("/items/#{item_id}/relist?access_token=#{@access_token}", payload, headers).body end |
#update_item(item_id, attrs) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/mercadolibre/core/items.rb', line 20 def update_item(item_id, attrs) payload = attrs.to_json headers = { content_type: :json, accept: :json } put_request("/items/#{item_id}?access_token=#{@access_token}", payload, headers).body end |
#update_item_attributes(item_id, attrs) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/mercadolibre/core/items.rb', line 62 def update_item_attributes(item_id, attrs) payload = attrs.to_json headers = { content_type: :json, accept: :json } put_request("/items/#{item_id}?access_token=#{@access_token}", payload, headers).status_code == 200 end |
#update_item_description(item_id, text) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/mercadolibre/core/items.rb', line 54 def update_item_description(item_id, text) payload = { text: text }.to_json headers = { content_type: :json, accept: :json } put_request("/items/#{item_id}/description?access_token=#{@access_token}", payload, headers).body end |
#update_item_identifiers(item_id, attrs) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/mercadolibre/core/items.rb', line 82 def update_item_identifiers(item_id, attrs) payload = attrs.to_json headers = { content_type: :json } put_request("/items/#{item_id}/product_identifiers?access_token=#{@access_token}", payload, headers).status_code == 200 end |
#validate_item(attrs) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/mercadolibre/core/items.rb', line 28 def validate_item(attrs) payload = attrs.to_json headers = { content_type: :json } result = post_request("/items/validate?access_token=#{@access_token}", payload, headers) (result.status_code.to_s == '204') end |