conexa 0.0.7 → 0.0.9

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: 8f797946a06e5b411bab47be327b805494a3baae97afb9faa629d0f5b45318a6
4
- data.tar.gz: a4433c392325e634d6ded5996a809dc124a2e1d75c3239af8050fbf8f3402c47
3
+ metadata.gz: b1dba13ee9b0dc841e758d5cb0b9c468a480ca564129666814c0e25892ea4cff
4
+ data.tar.gz: 732eebd11f3ec3b5ee727f030ac51493fbce0e6212fb510dfcf5ba476d6424c4
5
5
  SHA512:
6
- metadata.gz: 780a9f5f20b67d1b8a0917b41ff82e06536a79e9f23c29125c7627f2f84efd084e24d6d435d49603b7d3a1df65a5dd3880dea2c3168af653b71ae75800089fda
7
- data.tar.gz: 86bf266d620205ca7d52416775feec983f4d197ade8c241f4812d443b6776c850a12ac66ca3fb517a768f6caa60957843f5bebdb1653e17e590fc40c6338f482
6
+ metadata.gz: c45016bd74d1e830ae18915be67be0f5a5e5dfc87581a9fe6685775b83c0aa08a4b8a10389d1ae9c92bfbffbf1b1b076b244c736c74002688f6be84e4115f02e
7
+ data.tar.gz: ff7831e660833da76d85325532889590d27f60451747980427ce7e2d8f7f5e48ec02960d5fdad5bfb5ea7abadab9fdec19e6e30c5bb2adbc0be2e9527680ec3b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.0.9] - 2026-03-30
11
+
12
+ ### Added
13
+ - **New pagination model**: `limit`/`offset`/`hasNext` — more efficient, avoids calculating total records
14
+ - Pass `limit:` to any `.all` or `.find_by` to use the new pagination
15
+ - Old `page`/`size` pagination emits deprecation warning (deadline: 2026-08-01)
16
+ - **New resources:**
17
+ - `Conexa::ReceivingMethod` — Meios de Recebimento (`/receivingMethods`, `/receivingMethod/:id`)
18
+ - `Conexa::PaymentMethod` — Meios de Pagamento (`/paymentMethods`, `/paymentMethod/:id`)
19
+ - `Conexa::BillCategory` — Categorias de Despesa (`/billCategories`, `/billCategory/:id`)
20
+ - `Conexa::BillSubcategory` — Subcategorias de Despesa (`/billSubcategories`, `/billSubcategory/:id`)
21
+ - `Conexa::CostCenter` — Centros de Custo (`/costCenters`, `/costCenter/:id`)
22
+ - `Conexa::Account` — Contas Bancárias (`/accounts`, `/account/:id`)
23
+ - `Conexa::ServiceCategory` — Categorias de Serviço (`/serviceCategories`, `/serviceCategory/:id`)
24
+ - `Conexa::RoomBooking` — Reservas de Sala (`/room/bookings`, `/room/booking`) with cancel, checkout, checkin
25
+ - `Product` now supports full CRUD (POST `/product`, DELETE `/product/:id`) per API v2 update
26
+
27
+ ### Changed
28
+ - `Model#extract_page_size_or_params` rewritten to support dual pagination modes
29
+ - `Customer.persons`, `Customer.contracts`, `Customer.charges` migrated to `limit: 100`
30
+
31
+ ### Fixed
32
+ - `Supplier` list URL corrected from `/supplier` to `/suppliers`
33
+ - `Supplier` now has `primary_key_attribute :supplier_id`
34
+ - `Product` now has `primary_key_attribute :product_id`
35
+
36
+ ## [0.0.8] - 2026-02-19
37
+
38
+ ### Fixed
39
+ - `Auth.login` usava `Request.post` (inclui header Authorization) ao invés de `Request.auth`
40
+ - `Model#primary_key_name` retornava nomes incorretos para classes compostas (ex: `creditcard_id` ao invés de `credit_card_id`)
41
+ - `Model.destroy(id)` falhava para resources com `primary_key_attribute` definido
42
+ - `Model#destroy` retornava Hash interno ao invés de `self`
43
+ - `Person` tinha `find`, `all` e `find_by` desnecessariamente desabilitados (a API suporta todos os endpoints CRUD)
44
+
45
+ ### Added
46
+ - Testes de autenticação com cassettes VCR (13 specs)
47
+ - Testes de integração WebMock para Sale, RecurringSale, Plan, Product, Bill, Supplier, Company, CreditCard, Person e InvoicingMethod
48
+ - Total de testes: 407 specs
49
+
50
+ ### Changed
51
+ - `REFERENCE.md` reescrito com documentação completa de todos os endpoints baseada na collection Postman
52
+ - nokogiri atualizado para 1.19.1
53
+
10
54
  ## [0.0.7] - 2026-02-12
11
55
 
12
56
  ### Added
@@ -43,7 +87,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
43
87
  - Charge with settle and PIX methods
44
88
  - Pagination support
45
89
 
46
- [Unreleased]: https://github.com/guilhermegazzinelli/conexa-ruby/compare/v0.0.7...HEAD
90
+ [Unreleased]: https://github.com/guilhermegazzinelli/conexa-ruby/compare/v0.0.9...HEAD
91
+ [0.0.9]: https://github.com/guilhermegazzinelli/conexa-ruby/compare/v0.0.8...v0.0.9
92
+ [0.0.8]: https://github.com/guilhermegazzinelli/conexa-ruby/compare/v0.0.7...v0.0.8
47
93
  [0.0.7]: https://github.com/guilhermegazzinelli/conexa-ruby/compare/v0.0.6...v0.0.7
48
94
  [0.0.6]: https://github.com/guilhermegazzinelli/conexa-ruby/compare/v0.0.5...v0.0.6
49
95
  [0.0.5]: https://github.com/guilhermegazzinelli/conexa-ruby/releases/tag/v0.0.5
data/Gemfile CHANGED
@@ -11,8 +11,6 @@ gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
13
 
14
- gem "solargraph"
15
-
16
14
  gem "standard"
17
15
 
18
16
  gem "debug"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- conexa (0.0.6)
4
+ conexa (0.0.9)
5
5
  jwt
6
6
  multi_json
7
7
  rest-client
@@ -23,9 +23,7 @@ GEM
23
23
  addressable (2.8.7)
24
24
  public_suffix (>= 2.0.2, < 7.0)
25
25
  ast (2.4.2)
26
- backport (1.2.0)
27
26
  base64 (0.2.0)
28
- benchmark (0.3.0)
29
27
  bigdecimal (3.1.8)
30
28
  byebug (11.1.3)
31
29
  concurrent-ruby (1.3.4)
@@ -39,7 +37,6 @@ GEM
39
37
  diff-lcs (1.5.1)
40
38
  domain_name (0.6.20240107)
41
39
  drb (2.2.1)
42
- e2mmap (0.1.0)
43
40
  factory_bot (6.5.0)
44
41
  activesupport (>= 5.0.0)
45
42
  faker (3.5.1)
@@ -54,14 +51,9 @@ GEM
54
51
  irb (1.14.1)
55
52
  rdoc (>= 4.0.0)
56
53
  reline (>= 0.4.2)
57
- jaro_winkler (1.6.0)
58
54
  json (2.7.2)
59
55
  jwt (3.1.2)
60
56
  base64
61
- kramdown (2.4.0)
62
- rexml
63
- kramdown-parser-gfm (1.1.0)
64
- kramdown (~> 2.0)
65
57
  language_server-protocol (3.17.0.3)
66
58
  lint_roller (1.1.0)
67
59
  logger (1.6.1)
@@ -72,8 +64,6 @@ GEM
72
64
  minitest (5.25.1)
73
65
  multi_json (1.19.1)
74
66
  netrc (0.11.0)
75
- nokogiri (1.16.7-x86_64-linux)
76
- racc (~> 1.4)
77
67
  parallel (1.26.3)
78
68
  parser (3.3.5.0)
79
69
  ast (~> 2.4.1)
@@ -84,7 +74,6 @@ GEM
84
74
  racc (1.8.1)
85
75
  rainbow (3.1.1)
86
76
  rake (13.2.1)
87
- rbs (2.8.4)
88
77
  rdoc (6.7.0)
89
78
  psych (>= 4.0.0)
90
79
  regexp_parser (2.9.2)
@@ -95,8 +84,6 @@ GEM
95
84
  http-cookie (>= 1.0.2, < 2.0)
96
85
  mime-types (>= 1.16, < 4.0)
97
86
  netrc (~> 0.8)
98
- reverse_markdown (2.1.1)
99
- nokogiri
100
87
  rexml (3.3.8)
101
88
  rspec (3.13.0)
102
89
  rspec-core (~> 3.13.0)
@@ -128,22 +115,6 @@ GEM
128
115
  rubocop-ast (>= 1.31.1, < 2.0)
129
116
  ruby-progressbar (1.13.0)
130
117
  securerandom (0.3.1)
131
- solargraph (0.50.0)
132
- backport (~> 1.2)
133
- benchmark
134
- bundler (~> 2.0)
135
- diff-lcs (~> 1.4)
136
- e2mmap
137
- jaro_winkler (~> 1.5)
138
- kramdown (~> 2.3)
139
- kramdown-parser-gfm (~> 1.1)
140
- parser (~> 3.0)
141
- rbs (~> 2.0)
142
- reverse_markdown (~> 2.0)
143
- rubocop (~> 1.38)
144
- thor (~> 1.0)
145
- tilt (~> 2.0)
146
- yard (~> 0.9, >= 0.9.24)
147
118
  standard (1.41.1)
148
119
  language_server-protocol (~> 3.17.0.2)
149
120
  lint_roller (~> 1.0)
@@ -157,8 +128,6 @@ GEM
157
128
  lint_roller (~> 1.1)
158
129
  rubocop-performance (~> 1.22.0)
159
130
  stringio (3.1.1)
160
- thor (1.3.2)
161
- tilt (2.4.0)
162
131
  tzinfo (2.0.6)
163
132
  concurrent-ruby (~> 1.0)
164
133
  unicode-display_width (2.6.0)
@@ -168,10 +137,10 @@ GEM
168
137
  addressable (>= 2.8.0)
169
138
  crack (>= 0.3.2)
170
139
  hashdiff (>= 0.4.0, < 2.0.0)
171
- yard (0.9.37)
172
140
 
173
141
  PLATFORMS
174
- x86_64-linux
142
+ ruby
143
+ x86_64-linux-gnu
175
144
 
176
145
  DEPENDENCIES
177
146
  byebug
@@ -182,7 +151,6 @@ DEPENDENCIES
182
151
  rake (~> 13.0)
183
152
  rspec (~> 3.0)
184
153
  rubocop (~> 1.21)
185
- solargraph
186
154
  standard
187
155
  vcr
188
156
  webmock
data/README.md CHANGED
@@ -120,12 +120,11 @@ customer.legal_person['cnpj'] # => "99.557.155/0001-90"
120
120
  # Update customer
121
121
  Conexa::Customer.update(127, name: 'New Name', cell_number: '11888887777')
122
122
 
123
- # List customers with filters
123
+ # List customers with filters (new pagination)
124
124
  customers = Conexa::Customer.list(
125
125
  company_id: [3],
126
126
  is_active: true,
127
- page: 1,
128
- size: 20
127
+ limit: 20
129
128
  )
130
129
  ```
131
130
 
@@ -266,10 +265,75 @@ plan.price # => 99.90
266
265
 
267
266
  ```ruby
268
267
  # List products
269
- products = Conexa::Product.list(company_id: [3])
268
+ products = Conexa::Product.list(company_id: [3], limit: 50)
270
269
 
271
270
  # Retrieve product
272
271
  product = Conexa::Product.retrieve(101)
272
+
273
+ # Create product
274
+ product = Conexa::Product.create(name: 'Novo Produto', company_id: 3)
275
+
276
+ # Delete product
277
+ Conexa::Product.delete(101)
278
+ ```
279
+
280
+ ### Receiving Method
281
+
282
+ ```ruby
283
+ methods = Conexa::ReceivingMethod.list(limit: 50)
284
+ method = Conexa::ReceivingMethod.retrieve(11)
285
+ method.name # => "Cartão de Crédito"
286
+ ```
287
+
288
+ ### Payment Method
289
+
290
+ ```ruby
291
+ methods = Conexa::PaymentMethod.list(limit: 50)
292
+ method = Conexa::PaymentMethod.retrieve(2)
293
+ ```
294
+
295
+ ### Bill Category / Subcategory
296
+
297
+ ```ruby
298
+ categories = Conexa::BillCategory.list(limit: 50)
299
+ subcategories = Conexa::BillSubcategory.list(limit: 50)
300
+ ```
301
+
302
+ ### Cost Center
303
+
304
+ ```ruby
305
+ centers = Conexa::CostCenter.list(limit: 50)
306
+ center = Conexa::CostCenter.retrieve(11)
307
+ ```
308
+
309
+ ### Account
310
+
311
+ ```ruby
312
+ accounts = Conexa::Account.list(limit: 50)
313
+ account = Conexa::Account.retrieve(23)
314
+ ```
315
+
316
+ ### Service Category
317
+
318
+ ```ruby
319
+ categories = Conexa::ServiceCategory.list(limit: 50)
320
+ category = Conexa::ServiceCategory.retrieve(1)
321
+ ```
322
+
323
+ ### Room Booking
324
+
325
+ ```ruby
326
+ # List bookings
327
+ bookings = Conexa::RoomBooking.list(limit: 20)
328
+
329
+ # Create booking
330
+ booking = Conexa::RoomBooking.create(room_id: 5, customer_id: 127)
331
+
332
+ # Cancel booking
333
+ Conexa::RoomBooking.cancel(143063)
334
+
335
+ # Checkin
336
+ Conexa::RoomBooking.checkin(room_id: 5, customer_id: 127)
273
337
  ```
274
338
 
275
339
  ### Credit Card
@@ -306,25 +370,110 @@ company.document # => "12.345.678/0001-90"
306
370
 
307
371
  ## Pagination
308
372
 
309
- All list endpoints return paginated results:
373
+ ### New Pagination (recommended) `limit`/`offset`/`hasNext`
310
374
 
311
375
  ```ruby
312
- result = Conexa::Customer.list(page: 1, size: 20)
376
+ result = Conexa::Customer.list(limit: 50)
313
377
 
314
- result.data # Array of customers
378
+ result.data # Array of customers
379
+ result.pagination.limit # => 50
380
+ result.pagination.offset # => 0
381
+ result.pagination.has_next # => true/false
382
+
383
+ # Iterate through all pages
384
+ offset = 0
385
+ loop do
386
+ result = Conexa::Customer.list(limit: 50, offset: offset)
387
+ result.data.each { |customer| process(customer) }
388
+ break unless result.pagination.has_next
389
+ offset += 50
390
+ end
391
+ ```
392
+
393
+ ### Legacy Pagination (deprecated — will be removed 2026-08-01)
394
+
395
+ ```ruby
396
+ # Still works but emits a deprecation warning
397
+ result = Conexa::Customer.list(page: 1, size: 20)
315
398
  result.pagination.current_page # => 1
316
399
  result.pagination.total_pages # => 10
317
- result.pagination.total_items # => 195
318
- result.pagination.item_per_page # => 20
400
+ ```
401
+
402
+ ### Migration Guide: Legacy → New Pagination
403
+
404
+ The legacy `page`/`size` pagination is deprecated and will be removed on **2026-08-01**. Follow these steps to migrate:
405
+
406
+ #### 1. Replace `page`/`size` with `limit`/`offset`
407
+
408
+ ```ruby
409
+ # BEFORE (legacy — deprecated)
410
+ result = Conexa::Customer.list(page: 1, size: 50)
411
+ result = Conexa::Customer.list(page: 2, size: 50)
412
+
413
+ # AFTER (new)
414
+ result = Conexa::Customer.list(limit: 50) # offset defaults to 0
415
+ result = Conexa::Customer.list(limit: 50, offset: 50) # second page
416
+ ```
417
+
418
+ **Conversion formula:** `offset = (page - 1) * size`
319
419
 
320
- # Iterate through pages
420
+ #### 2. Update pagination metadata access
421
+
422
+ ```ruby
423
+ # BEFORE (legacy)
424
+ result.pagination # => { "page" => 1, "size" => 50, "total" => 150 }
425
+ total_pages = (result.pagination["total"].to_f / size).ceil
426
+
427
+ # AFTER (new)
428
+ result.pagination.limit # => 50
429
+ result.pagination.offset # => 0
430
+ result.pagination.has_next # => true/false
431
+ ```
432
+
433
+ #### 3. Update iteration loops
434
+
435
+ ```ruby
436
+ # BEFORE (legacy)
437
+ page = 1
321
438
  loop do
322
- result.data.each { |customer| process(customer) }
323
- break if result.pagination.current_page >= result.pagination.total_pages
324
- result = Conexa::Customer.list(page: result.pagination.current_page + 1)
439
+ result = Conexa::Customer.list(page: page, size: 100)
440
+ break if result.empty?
441
+ result.data.each { |c| process(c) }
442
+ page += 1
325
443
  end
444
+
445
+ # AFTER (new)
446
+ offset = 0
447
+ loop do
448
+ result = Conexa::Customer.list(limit: 100, offset: offset)
449
+ result.data.each { |c| process(c) }
450
+ break unless result.pagination.has_next
451
+ offset += 100
452
+ end
453
+ ```
454
+
455
+ #### 4. Remove positional arguments
456
+
457
+ ```ruby
458
+ # BEFORE (legacy positional args)
459
+ Conexa::Customer.all(2, 50) # page 2, size 50
460
+ Conexa::Customer.find_by({}, 1, 20) # page 1, size 20
461
+
462
+ # AFTER (new keyword args)
463
+ Conexa::Customer.all(limit: 50, offset: 50)
464
+ Conexa::Customer.find_by(limit: 20)
326
465
  ```
327
466
 
467
+ #### Quick reference
468
+
469
+ | Legacy | New |
470
+ |---|---|
471
+ | `page: 1, size: 50` | `limit: 50` (offset defaults to 0) |
472
+ | `page: N, size: S` | `limit: S, offset: (N-1)*S` |
473
+ | `pagination["total"]` | `pagination.has_next` |
474
+ | `pagination["page"]` | `pagination.offset` |
475
+ | Positional `(page, size)` | Keyword `limit:`, `offset:` |
476
+
328
477
  ## Error Handling
329
478
 
330
479
  ```ruby
@@ -360,7 +509,7 @@ end
360
509
 
361
510
  ## Rate Limiting
362
511
 
363
- The Conexa API has a limit of **100 requests per minute**. Response headers include:
512
+ The Conexa API has a limit of **100 requests per minute** (changing to **60 requests per minute** on 2026-04-27). Response headers include:
364
513
 
365
514
  - `X-Rate-Limit-Limit`: Maximum requests in 60s
366
515
  - `X-Rate-Limit-Remaining`: Remaining requests in 60s
data/README_pt-BR.md CHANGED
@@ -281,7 +281,7 @@ paginacao = pagina1.pagination
281
281
  # paginacao contém total de registros, total de páginas, etc.
282
282
  ```
283
283
 
284
- #### Iterando Por Todas as Páginas
284
+ #### Iterando Por Todas as Páginas (legado — depreciado)
285
285
 
286
286
  ```ruby
287
287
  pagina = 1
@@ -301,6 +301,101 @@ loop do
301
301
  end
302
302
  ```
303
303
 
304
+ ### Nova Paginação (recomendada) — `limit`/`offset`/`hasNext`
305
+
306
+ ```ruby
307
+ resultado = Conexa::Customer.all(limit: 50)
308
+
309
+ resultado.data # Array de clientes
310
+ resultado.pagination.limit # => 50
311
+ resultado.pagination.offset # => 0
312
+ resultado.pagination.has_next # => true/false
313
+
314
+ # Iterar por todas as páginas
315
+ offset = 0
316
+ loop do
317
+ resultado = Conexa::Customer.all(limit: 50, offset: offset)
318
+ resultado.data.each { |cliente| processa(cliente) }
319
+ break unless resultado.pagination.has_next
320
+ offset += 50
321
+ end
322
+ ```
323
+
324
+ ### Guia de Migração: Paginação Legada → Nova
325
+
326
+ A paginação legada `page`/`size` está depreciada e será removida em **01/08/2026**. Siga estes passos para migrar:
327
+
328
+ #### 1. Substitua `page`/`size` por `limit`/`offset`
329
+
330
+ ```ruby
331
+ # ANTES (legado — depreciado)
332
+ resultado = Conexa::Customer.all(page: 1, size: 50)
333
+ resultado = Conexa::Customer.all(page: 2, size: 50)
334
+
335
+ # DEPOIS (novo)
336
+ resultado = Conexa::Customer.all(limit: 50) # offset padrão 0
337
+ resultado = Conexa::Customer.all(limit: 50, offset: 50) # segunda página
338
+ ```
339
+
340
+ **Fórmula de conversão:** `offset = (page - 1) * size`
341
+
342
+ #### 2. Atualize o acesso aos metadados de paginação
343
+
344
+ ```ruby
345
+ # ANTES (legado)
346
+ resultado.pagination # => { "page" => 1, "size" => 50, "total" => 150 }
347
+ total_paginas = (resultado.pagination["total"].to_f / tamanho).ceil
348
+
349
+ # DEPOIS (novo)
350
+ resultado.pagination.limit # => 50
351
+ resultado.pagination.offset # => 0
352
+ resultado.pagination.has_next # => true/false
353
+ ```
354
+
355
+ #### 3. Atualize os loops de iteração
356
+
357
+ ```ruby
358
+ # ANTES (legado)
359
+ pagina = 1
360
+ loop do
361
+ resultado = Conexa::Customer.all(page: pagina, size: 100)
362
+ break if resultado.empty?
363
+ resultado.data.each { |c| processa(c) }
364
+ pagina += 1
365
+ end
366
+
367
+ # DEPOIS (novo)
368
+ offset = 0
369
+ loop do
370
+ resultado = Conexa::Customer.all(limit: 100, offset: offset)
371
+ resultado.data.each { |c| processa(c) }
372
+ break unless resultado.pagination.has_next
373
+ offset += 100
374
+ end
375
+ ```
376
+
377
+ #### 4. Remova argumentos posicionais
378
+
379
+ ```ruby
380
+ # ANTES (argumentos posicionais legados)
381
+ Conexa::Customer.all(2, 50) # página 2, tamanho 50
382
+ Conexa::Customer.find_by({}, 1, 20) # página 1, tamanho 20
383
+
384
+ # DEPOIS (argumentos nomeados)
385
+ Conexa::Customer.all(limit: 50, offset: 50)
386
+ Conexa::Customer.find_by(limit: 20)
387
+ ```
388
+
389
+ #### Referência rápida
390
+
391
+ | Legado | Novo |
392
+ |---|---|
393
+ | `page: 1, size: 50` | `limit: 50` (offset padrão 0) |
394
+ | `page: N, size: S` | `limit: S, offset: (N-1)*S` |
395
+ | `pagination["total"]` | `pagination.has_next` |
396
+ | `pagination["page"]` | `pagination.offset` |
397
+ | Posicional `(page, size)` | Nomeado `limit:`, `offset:` |
398
+
304
399
  ### Exemplos
305
400
 
306
401
  #### Clientes (Customers)