Module: Mercadolibre::Core::Pictures

Included in:
Api
Defined in:
lib/mercadolibre/core/pictures.rb

Instance Method Summary collapse

Instance Method Details

#add_item_picture(picture_id, item_id) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/mercadolibre/core/pictures.rb', line 17

def add_item_picture(picture_id, item_id)
  payload = { id: picture_id }.to_json

  headers = { content_type: :json }

  post_request("/items/#{item_id}/pictures?access_token=#{@access_token}",
    payload, headers).body
end

#create_picture(path_to_file) ⇒ Object



4
5
6
7
# File 'lib/mercadolibre/core/pictures.rb', line 4

def create_picture(path_to_file)
  payload = { file: File.new(path_to_file, 'rb') }
  post_request("/pictures?access_token=#{@access_token}", payload).body
end

#delete_picture(picture_id) ⇒ Object



13
14
15
# File 'lib/mercadolibre/core/pictures.rb', line 13

def delete_picture(picture_id)
  delete_request("/pictures/#{picture_id}?access_token=#{@access_token}").body
end

#get_pictures(picture_id) ⇒ Object



9
10
11
# File 'lib/mercadolibre/core/pictures.rb', line 9

def get_pictures(picture_id)
  get_request("/pictures/#{picture_id}").body
end

#replace_item_pictures(item_id, images) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/mercadolibre/core/pictures.rb', line 26

def replace_item_pictures(item_id, images)
  payload = images.to_json

  headers = { content_type: :json }

  put_request("/items/#{item_id}?access_token=#{@access_token}", payload, headers).body
end