mercado_livre_api 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da2e5a6e2092109d60552f33315b0587ea517826698694261992040894b4150d
4
- data.tar.gz: a4ed7d00baaca1ea57d779c85e84926f4f446998d703e67816cb32f72d35da48
3
+ metadata.gz: ae63147281b2f563edf461ba04aaa557e07b0c50a9b6f35844addee298afcd31
4
+ data.tar.gz: bf01b7f05744c232a88f1945f14528223d22482fdf27c70903b0895d6c9caa18
5
5
  SHA512:
6
- metadata.gz: d234e0a23fabc62515d879e73187c51a22c853c58a02eb695f7fce35fff0d2826d925b432dc0ab9e75ce9af45becf19e45cb98ffeb9eeec2750164d2296523cf
7
- data.tar.gz: 4f8a767ae05fdba58ae0ec79c904784f32512b541cb2d851ea713f8dabf61ec36f8fda70cf37478ed87247916cea6a1910ded88368bc4055b5038a2e16b9501d
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
@@ -153,10 +153,26 @@ module MercadoLivreApi
153
153
  get("/users/#{user_id}/items/search", params: params) { _1.results.is_a?(Array) }
154
154
  end
155
155
 
156
- def multiget(ids: [], attributes: nil)
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
+
157
171
  params = {ids: ids.join(",")}
158
- params[:attributes] = attributes.join(",") if attributes
159
- get("/items", params: params) { _1.is_a?(Array) }
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) }
160
176
  end
161
177
 
162
178
  def get_listing(item_id)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MercadoLivreApi
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercado_livre_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - marialuiza1324
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-10-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ac
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
- rubygems_version: 3.6.2
62
+ rubygems_version: 3.6.9
63
63
  specification_version: 4
64
64
  summary: Ruby client for the Mercado Livre — OAuth authentication and endpoints for
65
65
  orders, shipments, shipping labels and invoices.