Module: Mercadolibre::Core::PickupStores

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

Instance Method Summary collapse

Instance Method Details

#create_item_pickup_store(item_id, store_id, attrs) ⇒ Object



33
34
35
36
37
38
# File 'lib/mercadolibre/core/pickup_stores.rb', line 33

def create_item_pickup_store(item_id, store_id, attrs)
  payload = attrs.to_json
  headers = { content_type: :json }

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

#create_item_variation_pickup_store(item_id, variation_id, store_id, attrs) ⇒ Object



57
58
59
60
61
62
# File 'lib/mercadolibre/core/pickup_stores.rb', line 57

def create_item_variation_pickup_store(item_id, variation_id, store_id, attrs)
  payload = attrs.to_json
  headers = { content_type: :json }

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

#create_pickup_store(user_id, attrs) ⇒ Object



4
5
6
7
8
9
# File 'lib/mercadolibre/core/pickup_stores.rb', line 4

def create_pickup_store(user_id, attrs)
  payload = attrs.to_json
  headers = { content_type: :json }

  post_request("/users/#{user_id}/stores?access_token=#{@access_token}", payload, headers).body
end

#delete_item_pickup_store(item_id, store_id) ⇒ Object



47
48
49
50
# File 'lib/mercadolibre/core/pickup_stores.rb', line 47

def delete_item_pickup_store(item_id, store_id)
  result = delete_request("/items/#{item_id}/stores/#{store_id}?access_token=#{@access_token}")
  result.status_code == 200
end

#delete_item_variation_pickup_store(item_id, variation_id, store_id) ⇒ Object



71
72
73
74
# File 'lib/mercadolibre/core/pickup_stores.rb', line 71

def delete_item_variation_pickup_store(item_id, variation_id, store_id)
  result = delete_request("/items/#{item_id}/variation/#{variation_id}/stores/#{store_id}?access_token=#{@access_token}")
  result.status_code == 200
end

#delete_pickup_store(user_id, store_id) ⇒ Object



18
19
20
21
# File 'lib/mercadolibre/core/pickup_stores.rb', line 18

def delete_pickup_store(user_id, store_id)
  result = delete_request("/users/#{user_id}/stores/#{store_id}?access_token=#{@access_token}")
  result.status_code == 200
end

#get_item_pickup_stores(item_id) ⇒ Object



52
53
54
55
# File 'lib/mercadolibre/core/pickup_stores.rb', line 52

def get_item_pickup_stores(item_id)
  filters = { access_token: @access_token }
  get_request("/items/#{item_id}/stores", filters).body
end

#get_pickup(pickup_id) ⇒ Object



76
77
78
79
# File 'lib/mercadolibre/core/pickup_stores.rb', line 76

def get_pickup(pickup_id)
  filters = { access_token: @access_token }
  get_request("/pickups/#{pickup_id}", filters).body
end

#get_pickup_store(store_id) ⇒ Object



28
29
30
31
# File 'lib/mercadolibre/core/pickup_stores.rb', line 28

def get_pickup_store(store_id)
  filters = { access_token: @access_token }
  get_request("/stores/#{store_id}", filters).body
end

#search_pickup_stores(user_id, filters = {}) ⇒ Object



23
24
25
26
# File 'lib/mercadolibre/core/pickup_stores.rb', line 23

def search_pickup_stores(user_id, filters={})
  filters.merge!({ access_token: @access_token })
  get_request("/users/#{user_id}/stores/search", filters).body
end

#update_item_pickup_store(item_id, store_id, attrs) ⇒ Object



40
41
42
43
44
45
# File 'lib/mercadolibre/core/pickup_stores.rb', line 40

def update_item_pickup_store(item_id, store_id, attrs)
  payload = attrs.to_json
  headers = { content_type: :json, accept: :json }

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

#update_item_variation_pickup_store(item_id, variation_id, store_id, attrs) ⇒ Object



64
65
66
67
68
69
# File 'lib/mercadolibre/core/pickup_stores.rb', line 64

def update_item_variation_pickup_store(item_id, variation_id, store_id, attrs)
  payload = attrs.to_json
  headers = { content_type: :json, accept: :json }

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

#update_pickup_store(user_id, store_id, attrs) ⇒ Object



11
12
13
14
15
16
# File 'lib/mercadolibre/core/pickup_stores.rb', line 11

def update_pickup_store(user_id, store_id, attrs)
  payload = attrs.to_json
  headers = { content_type: :json, accept: :json }

  put_request("/users/#{user_id}/stores/#{store_id}?access_token=#{@access_token}", payload, headers).body
end