mercado_livre_api 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/mercado_livre_api/client.rb +125 -0
- data/lib/mercado_livre_api/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae63147281b2f563edf461ba04aaa557e07b0c50a9b6f35844addee298afcd31
|
|
4
|
+
data.tar.gz: bf01b7f05744c232a88f1945f14528223d22482fdf27c70903b0895d6c9caa18
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 341668c8102f8f7c65f50b9acbaf2135a5888b39077314a4cabd5b3f3090218c4c26eef9cc572c67958068db162e2f7e613a7e0fa0d94113f81b4fdc2c58ac92
|
|
7
|
+
data.tar.gz: c4cda89691075cb5b0cd456d1d9cde8883c88e58e6eeaee7b42a5c67a9ef86f0eefec8e434591914841fbfb9d22e1bb2f09bffac231222c12f6315a1ff1fb557
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.3.0] - 2026-11-25
|
|
4
|
+
|
|
5
|
+
- `multiget` now uses the `/items/bulk` endpoint. **Breaking:** each entry is now
|
|
6
|
+
`{id, status_code, body}` — `code` was renamed to `status_code`. Failed entries
|
|
7
|
+
(e.g. 404) have no `body`; the message is in `error.message` instead of
|
|
8
|
+
`body.message`. Results follow the order of the requested ids.
|
|
9
|
+
- `multiget` makes a single request and raises `ArgumentError` for more than
|
|
10
|
+
20 ids (`MULTIGET_MAX_IDS`, the API limit): splitting into batches is up to
|
|
11
|
+
the caller. It returns `[]` for an empty `ids` list instead of hitting the API.
|
|
12
|
+
- `multiget` accepts `include_attributes: true`, which sends `include_attributes=all`
|
|
13
|
+
so each variation comes with its `attributes` (e.g. `SELLER_SKU`).
|
|
14
|
+
|
|
3
15
|
## [0.1.0] - 2026-08-17
|
|
4
16
|
|
|
5
17
|
- Initial release
|
|
@@ -145,5 +145,130 @@ module MercadoLivreApi
|
|
|
145
145
|
def get_pack(pack_id)
|
|
146
146
|
get("/packs/#{pack_id}") { _1.id }
|
|
147
147
|
end
|
|
148
|
+
|
|
149
|
+
def get_listings(scroll_id: nil, limit: 100)
|
|
150
|
+
params = {search_type: "scan", limit: limit}
|
|
151
|
+
params[:scroll_id] = scroll_id if scroll_id.present?
|
|
152
|
+
|
|
153
|
+
get("/users/#{user_id}/items/search", params: params) { _1.results.is_a?(Array) }
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
MULTIGET_MAX_IDS = 20
|
|
157
|
+
|
|
158
|
+
# Uma requisição por chamada: dividir mais de MULTIGET_MAX_IDS ids em lotes
|
|
159
|
+
# fica com quem chama (que controla quantas requisições faz).
|
|
160
|
+
#
|
|
161
|
+
# @param ids [Array<String>] até MULTIGET_MAX_IDS ids de anúncio
|
|
162
|
+
# @param include_attributes [Boolean] true envia include_attributes=all, que a
|
|
163
|
+
# API exige para trazer os atributos (ex: SELLER_SKU) dentro de cada variação
|
|
164
|
+
# @raise [ArgumentError] com mais de MULTIGET_MAX_IDS ids
|
|
165
|
+
def multiget(ids: [], attributes: nil, include_attributes: false)
|
|
166
|
+
return [] if ids.blank?
|
|
167
|
+
if ids.size > MULTIGET_MAX_IDS
|
|
168
|
+
raise ArgumentError, "multiget aceita até #{MULTIGET_MAX_IDS} ids por requisição (recebeu #{ids.size})"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
params = {ids: ids.join(",")}
|
|
172
|
+
params[:attributes] = (%w[id status_code error] + attributes.map { "body.#{_1}" }).join(",") if attributes.present?
|
|
173
|
+
params[:include_attributes] = "all" if include_attributes
|
|
174
|
+
|
|
175
|
+
get("/items/bulk", params: params) { _1.is_a?(Array) }
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def get_listing(item_id)
|
|
179
|
+
get("/items/#{item_id}?include_attributes=all") { _1.id }
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def get_listing_description(item_id)
|
|
183
|
+
get("/items/#{item_id}/description") { _1.plain_text }
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def get_listing_variations(item_id)
|
|
187
|
+
get("/items/#{item_id}/variations?include_attributes=all") { _1.is_a?(Array) }
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# @param dimensions [String] Dimensões do item (altura x largura x comprimento e peso). Exemplo: 60x364x63,661
|
|
191
|
+
def get_listing_shipping_cost(
|
|
192
|
+
item_id:,
|
|
193
|
+
dimensions: nil,
|
|
194
|
+
item_price: nil,
|
|
195
|
+
verbose: true,
|
|
196
|
+
mode: nil,
|
|
197
|
+
logistic_type: nil,
|
|
198
|
+
free_shipping: nil
|
|
199
|
+
)
|
|
200
|
+
params = {
|
|
201
|
+
item_id: item_id,
|
|
202
|
+
dimensions: dimensions,
|
|
203
|
+
item_price: item_price,
|
|
204
|
+
verbose: verbose,
|
|
205
|
+
mode: mode,
|
|
206
|
+
logistic_type: logistic_type,
|
|
207
|
+
free_shipping: free_shipping
|
|
208
|
+
}.compact
|
|
209
|
+
get("/users/#{user_id}/shipping_options/free", params: params)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def update_stock(item_id:, quantity:)
|
|
213
|
+
body = { available_quantity: quantity }
|
|
214
|
+
put("/items/#{item_id}", body: body)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def update_price(item_id:, price:)
|
|
218
|
+
body = { price: price }
|
|
219
|
+
put("/items/#{item_id}", body: body)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def update_variation_stock(item_id:, variation_id:, quantity:)
|
|
223
|
+
body = {
|
|
224
|
+
variations: [
|
|
225
|
+
id: variation_id,
|
|
226
|
+
available_quantity: quantity
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
put("/items/#{item_id}", body: body)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def update_variation_price(item_id:, variation_id:, price:)
|
|
233
|
+
body = {
|
|
234
|
+
variations: [
|
|
235
|
+
id: variation_id,
|
|
236
|
+
price: price
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
put("/items/#{item_id}", body: body)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def close_listing(item_id)
|
|
243
|
+
put("/items/#{item_id}", body: { status: "closed" })
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def relist(item_id:, price:, quantity:, listing_type:)
|
|
247
|
+
body = {
|
|
248
|
+
price: price,
|
|
249
|
+
quantity: quantity,
|
|
250
|
+
listing_type_id: listing_type
|
|
251
|
+
}.compact
|
|
252
|
+
post("/items/#{item_id}/relist", body: body)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def get_all_categories
|
|
256
|
+
get("/sites/MLB/categories/all", accept_encoding: "gzip")
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def get_category_rates(category_id:, price: 1000)
|
|
260
|
+
get("/sites/MLB/listing_prices?category_id=#{category_id}&price=#{price}") { _1.is_a?(Array) }
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
private
|
|
264
|
+
|
|
265
|
+
def user_id
|
|
266
|
+
@user_id || fetch_user_id
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def fetch_user_id
|
|
270
|
+
response = get("/users/me") { _1.id }
|
|
271
|
+
@user_id = response.id
|
|
272
|
+
end
|
|
148
273
|
end
|
|
149
274
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mercado_livre_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- marialuiza1324
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: ac
|
|
@@ -24,7 +23,6 @@ dependencies:
|
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
|
-
description:
|
|
28
26
|
email:
|
|
29
27
|
- marialuiza.nerypinto@yahoo.com.br
|
|
30
28
|
executables: []
|
|
@@ -47,7 +45,6 @@ metadata:
|
|
|
47
45
|
homepage_uri: https://github.com/todasessascoisas/mercado_livre_api
|
|
48
46
|
source_code_uri: https://github.com/todasessascoisas/mercado_livre_api
|
|
49
47
|
changelog_uri: https://github.com/todasessascoisas/mercado_livre_api
|
|
50
|
-
post_install_message:
|
|
51
48
|
rdoc_options: []
|
|
52
49
|
require_paths:
|
|
53
50
|
- lib
|
|
@@ -62,8 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
62
59
|
- !ruby/object:Gem::Version
|
|
63
60
|
version: '0'
|
|
64
61
|
requirements: []
|
|
65
|
-
rubygems_version: 3.
|
|
66
|
-
signing_key:
|
|
62
|
+
rubygems_version: 3.6.9
|
|
67
63
|
specification_version: 4
|
|
68
64
|
summary: Ruby client for the Mercado Livre — OAuth authentication and endpoints for
|
|
69
65
|
orders, shipments, shipping labels and invoices.
|