vindi-rails 0.2.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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.agents/rules/code-style-ruby.md +100 -0
  3. data/CHANGELOG.md +21 -0
  4. data/CHANGELOG.pt-BR.md +21 -0
  5. data/README.md +74 -0
  6. data/README.pt-BR.md +74 -0
  7. data/WIKI.md +246 -0
  8. data/WIKI.pt-BR.md +246 -0
  9. data/lib/generators/vindi/install_generator.rb +17 -0
  10. data/lib/generators/vindi/templates/vindi.rb +11 -0
  11. data/lib/vindi/api_operations/create.rb +14 -0
  12. data/lib/vindi/api_operations/delete.rb +15 -0
  13. data/lib/vindi/api_operations/list.rb +14 -0
  14. data/lib/vindi/api_operations/update.rb +14 -0
  15. data/lib/vindi/client.rb +69 -0
  16. data/lib/vindi/configuration.rb +14 -0
  17. data/lib/vindi/errors.rb +22 -0
  18. data/lib/vindi/railtie.rb +7 -0
  19. data/lib/vindi/resource.rb +31 -0
  20. data/lib/vindi/resources/affiliate.rb +11 -0
  21. data/lib/vindi/resources/bill.rb +14 -0
  22. data/lib/vindi/resources/bill_item.rb +11 -0
  23. data/lib/vindi/resources/charge.rb +13 -0
  24. data/lib/vindi/resources/customer.rb +14 -0
  25. data/lib/vindi/resources/discount.rb +13 -0
  26. data/lib/vindi/resources/export_batch.rb +12 -0
  27. data/lib/vindi/resources/import_batch.rb +12 -0
  28. data/lib/vindi/resources/invoice.rb +11 -0
  29. data/lib/vindi/resources/issue.rb +12 -0
  30. data/lib/vindi/resources/merchant.rb +11 -0
  31. data/lib/vindi/resources/merchant_user.rb +11 -0
  32. data/lib/vindi/resources/message.rb +11 -0
  33. data/lib/vindi/resources/movement.rb +11 -0
  34. data/lib/vindi/resources/notification.rb +11 -0
  35. data/lib/vindi/resources/partner.rb +11 -0
  36. data/lib/vindi/resources/payment_method.rb +11 -0
  37. data/lib/vindi/resources/payment_profile.rb +13 -0
  38. data/lib/vindi/resources/period.rb +11 -0
  39. data/lib/vindi/resources/plan.rb +14 -0
  40. data/lib/vindi/resources/product.rb +14 -0
  41. data/lib/vindi/resources/product_item.rb +14 -0
  42. data/lib/vindi/resources/public.rb +9 -0
  43. data/lib/vindi/resources/role.rb +11 -0
  44. data/lib/vindi/resources/subscription.rb +14 -0
  45. data/lib/vindi/resources/transaction.rb +12 -0
  46. data/lib/vindi/resources/usage.rb +13 -0
  47. data/lib/vindi/resources/user.rb +11 -0
  48. data/lib/vindi/version.rb +5 -0
  49. data/lib/vindi.rb +59 -0
  50. data/vindi-rails.gemspec +33 -0
  51. metadata +109 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8d1b710b6837eb3148aa4dd5d5b683c5031a5dbd42d42ecdf3723f6d3643e707
4
+ data.tar.gz: 22abd03787ace80ad63dcb43d9cbd52862db17b2e69f3b9a6694a29e455b2dda
5
+ SHA512:
6
+ metadata.gz: 4d28a2ed062ddeb3476448a1e5e87227c4e583181eed44694ed1ceda85a9ef150ebd435b9405324c21e5af777bdd048819a44f62566ed47949d7ca8b4627a19a
7
+ data.tar.gz: 4326a2c91cfc5c827b3054d81fcf3553fd09ce625dfd977215aedc437554fe3af2eecc17c7f83e3dd6c01e51f7160b0d6df1f2dd5bf61af8c1398de54bc35e19
@@ -0,0 +1,100 @@
1
+ ---
2
+ trigger: manual
3
+ ---
4
+
5
+ # Rails Engineering Guidelines
6
+ ## Code Style
7
+ * Functions: 4-20 lines. Split if longer.
8
+ * Files: under 500 lines. Split by responsibility.
9
+ * One thing per function, one responsibility per module (SRP).
10
+ * Names: specific and unique. Avoid `data`, `handler`, `manager`, `service`. Prefer names that describe a business action.
11
+ * No code duplication. Extract shared logic into a function/module.
12
+ * Early returns over nested ifs. Max 2 levels of indentation.
13
+ * Exception messages must include the offending value and expected shape.
14
+ * Prefer immutable data flow when possible.
15
+ * Avoid metaprogramming unless it clearly reduces complexity.
16
+ ## Rails Architecture
17
+ * Controllers orchestrate. Business rules belong elsewhere.
18
+ * Controllers should stay under ~30 lines per action.
19
+ * Models own persistence and simple validations.
20
+ * Complex business rules belong in Service Objects.
21
+ * Service Objects should represent actions (`CreateOrder`, `CancelSubscription`, `ImportCustomers`).
22
+ * Avoid generic classes such as `UserService`, `OrderManager`, `PaymentHandler`.
23
+ * Query logic reused more than once belongs in Query Objects.
24
+ * Form Objects should encapsulate complex input validation and transformations.
25
+ * Prefer composition over inheritance.
26
+ ## Active Record
27
+ * Keep models focused and small (<300 lines preferred).
28
+ * Avoid Fat Models.
29
+ * Validations belong in models; workflows belong in services.
30
+ * Always evaluate queries for N+1 risks.
31
+ * Use `includes`, `preload`, or `eager_load` when appropriate.
32
+ * Prefer scopes only for simple reusable queries.
33
+ * Avoid `default_scope`.
34
+ * Use database constraints in addition to model validations.
35
+ * Every foreign key should have a database constraint when possible.
36
+ * Every frequently queried column should be reviewed for indexing.
37
+ ## Database
38
+ * All migrations must be reversible.
39
+ * Use transactions when modifying multiple entities.
40
+ * Prefer database constraints over application-only guarantees.
41
+ * Avoid loading large datasets into memory.
42
+ * Use `find_each` for batch processing.
43
+ * Use `pluck` when only specific columns are needed.
44
+ * Prefer explicit column selection over loading full records.
45
+ ## Background Jobs
46
+ * Jobs orchestrate; business logic lives in services.
47
+ * Jobs should be idempotent.
48
+ * Jobs must be retry-safe.
49
+ * External API calls should happen asynchronously when possible.
50
+ * Long-running work should always be delegated to jobs.
51
+ ## Events & Messaging
52
+ * Prefer event-driven communication over direct service coupling.
53
+ * Commands change state.
54
+ * Events communicate state changes.
55
+ * Event names should be business-oriented (`OrderCreated`, `PaymentApproved`).
56
+ * Consumers must be idempotent.
57
+ * Use correlation IDs across services.
58
+ ## Callbacks
59
+ * Use callbacks only for simple model concerns.
60
+ * Avoid callbacks for external integrations.
61
+ * Avoid callback chains that hide business flow.
62
+ * Prefer explicit service orchestration over lifecycle callbacks.
63
+ ## Testing
64
+ * Tests run with a single command: `<project-specific>`.
65
+ * Every new function gets a test.
66
+ * Bug fixes get a regression test.
67
+ * Tests must be F.I.R.S.T.
68
+ * Prefer request specs for APIs.
69
+ * Test behavior, not implementation details.
70
+ * Do not test private methods directly.
71
+ * Factories should create only required data.
72
+ * Avoid excessive fixture setup.
73
+ ## Dependencies
74
+ * Inject dependencies through constructor/parameter, not global state.
75
+ * Wrap third-party libraries behind project-owned interfaces.
76
+ * Never couple business logic directly to framework APIs when abstraction is reasonable.
77
+ * External integrations should be replaceable through adapters.
78
+ ## Structure
79
+ * Follow Rails conventions before introducing custom patterns.
80
+ * Prefer small focused modules over god files.
81
+ * Predictable paths and responsibilities.
82
+ * Services, Queries, Policies, Forms and Jobs should each have a clear responsibility.
83
+ * Keep domain logic close to the domain it belongs to.
84
+ ## Performance
85
+ * Every new query should be reviewed for N+1 issues.
86
+ * Monitor slow queries.
87
+ * Avoid unnecessary object allocations.
88
+ * Cache only after measuring.
89
+ * Prefer database operations over Ruby loops for large datasets.
90
+ * Measure before optimizing.
91
+ ## Logging & Observability
92
+ * Structured JSON logging for systems and integrations.
93
+ * Include request ID and correlation ID.
94
+ * Log business events, not only technical failures.
95
+ * External calls must log duration, status and failures.
96
+ * Use metrics and tracing for critical flows.
97
+ * Never log secrets, tokens, credentials or personal data.
98
+ ## Formatting
99
+ * Use the language default formatter (`rubocop -A`).
100
+ * Do not debate formatting in code reviews unless readability or correctness is affected.
data/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ---
6
+
7
+ ## [0.2.0] - 2026-06-10
8
+
9
+ ### Added
10
+ - **Rails Generator**: Added `rails generate vindi:install` command to easily bootstrap the initializer configuration.
11
+
12
+ ---
13
+
14
+ ## [0.1.0] - 2026-06-10
15
+
16
+ ### Added
17
+ - **Core SDK**: Initial release of the Vindi Rails SDK using `RestClient` as the default adapter.
18
+ - **Resources**: Map all 28 API resources, with complete CRUD operations and Minitest coverage implemented for all of them, including core billing, catalog (plans/products), billing/transactions, and administration/batch endpoints.
19
+ - **Dockerization**: Dockerfile and docker-compose.yml configuration to run the test suite isolated.
20
+ - **Testing**: Test suite using Minitest and WebMock (23 test runs, 44 assertions).
21
+ - **Documentation**: Detailed bilingual WIKI (EN / PT-BR) and README configuration/usage guides.
@@ -0,0 +1,21 @@
1
+ # Histórico de Alterações
2
+
3
+ Todas as alterações notáveis neste projeto serão documentadas neste arquivo.
4
+
5
+ ---
6
+
7
+ ## [0.2.0] - 10-06-2026
8
+
9
+ ### Adicionado
10
+ - **Gerador Rails**: Adicionado o comando `rails generate vindi:install` para inicializar facilmente as configurações de chaves.
11
+
12
+ ---
13
+
14
+ ## [0.1.0] - 10-06-2026
15
+
16
+ ### Adicionado
17
+ - **Core SDK**: Versão inicial do SDK Rails da Vindi utilizando `RestClient` como adaptador HTTP padrão.
18
+ - **Recursos**: Mapeamento de todos os 28 recursos da API, com operações CRUD completas e cobertura Minitest implementada para todos eles, incluindo faturamento core, catálogo (planos/produtos), cobranças/transações, e lotes/administração.
19
+ - **Dockerização**: Configuração do Dockerfile e docker-compose.yml para rodar a suíte de testes de forma isolada.
20
+ - **Testes**: Suíte de testes unitários utilizando Minitest e WebMock (23 execuções de teste, 44 asserções).
21
+ - **Documentação**: Guias detalhados de configuração e uso na WIKI (EN / PT-BR) e README bilíngue.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Vindi Rails SDK
2
+
3
+ [Leia em Português (README.pt-BR.md)](./README.pt-BR.md)
4
+
5
+ Ruby/Rails integration SDK for the Vindi API v1 (recurring billing platform).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'vindi-rails', path: 'c:/Users/User/develop/estudo/vindi-rails'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```bash
18
+ $ bundle install
19
+ ```
20
+
21
+ ## Configuration
22
+
23
+ Configure the SDK. In a Rails application, you can run the installation generator to create the initializer template:
24
+
25
+ ```bash
26
+ $ rails generate vindi:install
27
+ ```
28
+
29
+ This will create `config/initializers/vindi.rb` where you can set your keys:
30
+
31
+ ```ruby
32
+ Vindi.configure do |config|
33
+ config.api_key = 'your_private_api_key'
34
+ # Optional: Define base URL (default is Sandbox)
35
+ # config.api_url = 'https://gp.vindi.com.br/api/v1'
36
+ end
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ Resources are mapped directly under the `Vindi` namespace.
42
+
43
+ ### Customers
44
+
45
+ ```ruby
46
+ # List customers
47
+ customers = Vindi::Customer.list(page: 1, per_page: 20)
48
+
49
+ # Create a customer
50
+ customer = Vindi::Customer.create(
51
+ name: 'John Doe',
52
+ email: 'john.doe@example.com',
53
+ registry_code: '12345678909' # CPF/CNPJ
54
+ )
55
+
56
+ # Update a customer
57
+ Vindi::Customer.update(customer.id, name: 'John Doe Updated')
58
+
59
+ # Delete a customer
60
+ Vindi::Customer.delete(customer.id)
61
+ ```
62
+
63
+ ## Running Tests with Docker Compose
64
+
65
+ To build and run the Minitest test suite inside Docker:
66
+
67
+ ```bash
68
+ docker compose build
69
+ docker compose run --rm test
70
+ ```
71
+
72
+ ## Detailed Documentation
73
+
74
+ For a full list of mapped resources and detailed usage instructions, check out the [WIKI.md](./WIKI.md).
data/README.pt-BR.md ADDED
@@ -0,0 +1,74 @@
1
+ # Vindi Rails SDK
2
+
3
+ [Read in English (README.md)](./README.md)
4
+
5
+ SDK de integração Ruby/Rails para a API v1 da Vindi (plataforma de cobranças recorrentes).
6
+
7
+ ## Instalação
8
+
9
+ Adicione esta linha ao Gemfile da sua aplicação:
10
+
11
+ ```ruby
12
+ gem 'vindi-rails', path: 'c:/Users/User/develop/estudo/vindi-rails'
13
+ ```
14
+
15
+ E então execute:
16
+
17
+ ```bash
18
+ $ bundle install
19
+ ```
20
+
21
+ ## Configuração
22
+
23
+ Configure o SDK. Em aplicações Rails, você pode rodar o gerador de instalação para criar o template de inicializador:
24
+
25
+ ```bash
26
+ $ rails generate vindi:install
27
+ ```
28
+
29
+ Isso criará o arquivo `config/initializers/vindi.rb` onde você poderá configurar suas chaves:
30
+
31
+ ```ruby
32
+ Vindi.configure do |config|
33
+ config.api_key = 'sua_chave_privada_da_api'
34
+ # Opcional: Define a URL base (padrão é o Sandbox da Vindi)
35
+ # config.api_url = 'https://gp.vindi.com.br/api/v1'
36
+ end
37
+ ```
38
+
39
+ ## Utilização
40
+
41
+ Os recursos são mapeados diretamente sob o namespace `Vindi`.
42
+
43
+ ### Clientes
44
+
45
+ ```ruby
46
+ # Listar clientes
47
+ clientes = Vindi::Customer.list(page: 1, per_page: 20)
48
+
49
+ # Criar cliente
50
+ cliente = Vindi::Customer.create(
51
+ name: 'João Silva',
52
+ email: 'joao.silva@exemplo.com',
53
+ registry_code: '12345678909' # CPF/CNPJ
54
+ )
55
+
56
+ # Atualizar cliente
57
+ Vindi::Customer.update(cliente.id, name: 'João Silva Alterado')
58
+
59
+ # Excluir cliente
60
+ Vindi::Customer.delete(cliente.id)
61
+ ```
62
+
63
+ ## Rodando os Testes com Docker Compose
64
+
65
+ Para construir e executar a suíte de testes Minitest dentro do Docker:
66
+
67
+ ```bash
68
+ docker compose build
69
+ docker compose run --rm test
70
+ ```
71
+
72
+ ## Documentação Detalhada
73
+
74
+ Para ver a lista completa de recursos mapeados e instruções de uso detalhadas, confira a [WIKI.pt-BR.md](./WIKI.pt-BR.md).
data/WIKI.md ADDED
@@ -0,0 +1,246 @@
1
+ # Vindi SDK Wiki
2
+
3
+ [Leia em Português (WIKI.pt-BR.md)](./WIKI.pt-BR.md)
4
+
5
+ Welcome to the `vindi-rails` SDK Wiki. This document details all the mapped resources, operations, and advanced usage guidelines.
6
+
7
+ ---
8
+
9
+ ## 1. SDK Design & Architecture
10
+
11
+ The SDK uses `RestClient` internally to communicate with the Vindi API.
12
+ Resources are represented as Ruby objects inheriting from `Vindi::Resource`. Attributes returned from the API are accessible via dot-notation methods on the instances.
13
+
14
+ ### Error Handling
15
+
16
+ The SDK raises specific error classes based on HTTP status codes. All errors inherit from `Vindi::Error`:
17
+
18
+ - `Vindi::UnauthorizedError` (401)
19
+ - `Vindi::ForbiddenError` (403)
20
+ - `Vindi::NotFoundError` (404)
21
+ - `Vindi::UnprocessableEntityError` (422)
22
+ - `Vindi::RateLimitError` (429)
23
+ - `Vindi::InternalServerError` (500+)
24
+ - `Vindi::APIError` (Fallback for other HTTP statuses)
25
+
26
+ ---
27
+
28
+ ## 2. Resource Mapping & CRUD Capabilities
29
+
30
+ The table below lists all mapped resources and their operations:
31
+
32
+ | Resource Class | Endpoint | CRUD Operations Enabled |
33
+ | :--- | :--- | :--- |
34
+ | `Vindi::Customer` | `customers` | `list`, `create`, `update`, `delete` |
35
+ | `Vindi::PaymentProfile` | `payment_profiles` | `list`, `create`, `delete` |
36
+ | `Vindi::Subscription` | `subscriptions` | `list`, `create`, `update`, `delete` |
37
+ | `Vindi::Charge` | `charges` | `list`, `create`, `update` |
38
+ | `Vindi::Plan` | `plans` | `list`, `create`, `update`, `delete` |
39
+ | `Vindi::Product` | `products` | `list`, `create`, `update`, `delete` |
40
+ | `Vindi::ProductItem` | `product_items` | `list`, `create`, `update`, `delete` |
41
+ | `Vindi::Discount` | `discounts` | `list`, `create`, `delete` |
42
+ | `Vindi::Bill` | `bills` | `list`, `create`, `update`, `delete` |
43
+ | `Vindi::BillItem` | `bill_items` | `list` |
44
+ | `Vindi::Period` | `periods` | `list` |
45
+ | `Vindi::Transaction` | `transactions` | `list`, `create` |
46
+ | `Vindi::Usage` | `usages` | `list`, `create`, `delete` |
47
+ | `Vindi::Invoice` | `invoices` | `list` |
48
+ | `Vindi::Movement` | `movements` | `list` |
49
+ | `Vindi::Message` | `messages` | `list` |
50
+ | `Vindi::ExportBatch` | `export_batches` | `list`, `create` |
51
+ | `Vindi::ImportBatch` | `import_batches` | `list`, `create` |
52
+ | `Vindi::Issue` | `issues` | `list`, `update` |
53
+ | `Vindi::Notification` | `notifications` | `list` |
54
+ | `Vindi::Merchant` | `merchants` | `list` |
55
+ | `Vindi::MerchantUser` | `merchant_users` | `list` |
56
+ | `Vindi::Role` | `roles` | `list` |
57
+ | `Vindi::User` | `users` | `list` |
58
+ | `Vindi::Public` | `public` | None (Static Config) |
59
+ | `Vindi::Affiliate` | `affiliates` | `list` |
60
+ | `Vindi::Partner` | `partner` | `list` |
61
+
62
+ ---
63
+
64
+ ## 3. Usage Examples
65
+
66
+ ### Customers (`Vindi::Customer`)
67
+
68
+ ```ruby
69
+ # Create a customer
70
+ customer = Vindi::Customer.create(
71
+ name: "John Doe",
72
+ email: "john@example.com"
73
+ )
74
+
75
+ # Fetch attribute
76
+ puts customer.id
77
+ puts customer.name
78
+
79
+ # Update customer
80
+ updated = Vindi::Customer.update(customer.id, email: "john.new@example.com")
81
+
82
+ # Delete customer
83
+ Vindi::Customer.delete(customer.id)
84
+ ```
85
+
86
+ ### Payment Profiles (`Vindi::PaymentProfile`)
87
+
88
+ ```ruby
89
+ # Create a card payment profile
90
+ profile = Vindi::PaymentProfile.create(
91
+ customer_id: 12345,
92
+ payment_company_code: "visa",
93
+ holder_name: "JOHN DOE",
94
+ card_number: "4111111111111111",
95
+ card_expiration_date: "12/2030",
96
+ card_cvv: "123"
97
+ )
98
+
99
+ # Delete payment profile
100
+ Vindi::PaymentProfile.delete(profile.id)
101
+ ```
102
+
103
+ ### Subscriptions (`Vindi::Subscription`)
104
+
105
+ ```ruby
106
+ # Create subscription
107
+ subscription = Vindi::Subscription.create(
108
+ customer_id: customer.id,
109
+ plan_id: plan.id,
110
+ payment_method_code: "credit_card"
111
+ )
112
+
113
+ # Cancel/Delete subscription
114
+ Vindi::Subscription.delete(subscription.id)
115
+ ```
116
+
117
+ ### Charges (`Vindi::Charge`)
118
+
119
+ ```ruby
120
+ # List charges
121
+ charges = Vindi::Charge.list(status: "pending")
122
+
123
+ # Charge details
124
+ puts charges.first.amount
125
+ ```
126
+
127
+ ### Plans (`Vindi::Plan`)
128
+
129
+ ```ruby
130
+ # Create a plan
131
+ plan = Vindi::Plan.create(
132
+ name: "Premium Gold Plan",
133
+ code: "gold_premium",
134
+ interval: "months",
135
+ interval_count: 1
136
+ )
137
+
138
+ # List plans
139
+ plans = Vindi::Plan.list
140
+ ```
141
+
142
+ ### Products & Product Items (`Vindi::Product` & `Vindi::ProductItem`)
143
+
144
+ ```ruby
145
+ # Create a product
146
+ product = Vindi::Product.create(
147
+ name: "Hosting Service",
148
+ code: "hosting"
149
+ )
150
+
151
+ # Associate a product to a plan/subscription
152
+ product_item = Vindi::ProductItem.create(
153
+ product_id: product.id,
154
+ plan_id: plan.id
155
+ )
156
+ ```
157
+
158
+ ### Discounts (`Vindi::Discount`)
159
+
160
+ ```ruby
161
+ # Create/apply a discount
162
+ discount = Vindi::Discount.create(
163
+ amount: 15.00,
164
+ discount_type: "percentage",
165
+ percentage: 10
166
+ )
167
+ ```
168
+
169
+ ### Bills & Bill Items (`Vindi::Bill` & `Vindi::BillItem`)
170
+
171
+ ```ruby
172
+ # Create a bill manually
173
+ bill = Vindi::Bill.create(
174
+ customer_id: customer.id,
175
+ payment_method_code: "credit_card",
176
+ bill_items: [
177
+ { product_id: product.id, amount: 99.90 }
178
+ ]
179
+ )
180
+
181
+ # List bill items
182
+ items = Vindi::BillItem.list(bill_id: bill.id)
183
+ ```
184
+
185
+ ### Periods (`Vindi::Period`)
186
+
187
+ ```ruby
188
+ # List subscription periods
189
+ periods = Vindi::Period.list(subscription_id: subscription.id)
190
+ ```
191
+
192
+ ### Transactions (`Vindi::Transaction`)
193
+
194
+ ```ruby
195
+ # Create a manual transaction/charge capture
196
+ transaction = Vindi::Transaction.create(
197
+ charge_id: charge.id,
198
+ amount: 99.90
199
+ )
200
+
201
+ # List transactions
202
+ transactions = Vindi::Transaction.list
203
+ ```
204
+
205
+ ### Usages (`Vindi::Usage`)
206
+
207
+ ```ruby
208
+ # Report a metered usage for a subscription
209
+ usage = Vindi::Usage.create(
210
+ subscription_id: subscription.id,
211
+ quantity: 50,
212
+ description: "API Calls consumed"
213
+ )
214
+
215
+ # List usages
216
+ usages = Vindi::Usage.list(subscription_id: subscription.id)
217
+ ```
218
+
219
+ ### Invoices (`Vindi::Invoice`)
220
+
221
+ ```ruby
222
+ # List invoices
223
+ invoices = Vindi::Invoice.list(status: "issued")
224
+ ```
225
+
226
+ ### Issues (`Vindi::Issue`)
227
+
228
+ ```ruby
229
+ # Update an issue status (e.g. resolve a billing conflict)
230
+ issue = Vindi::Issue.update(issue_id, status: "resolved")
231
+ ```
232
+
233
+ ### Import/Export Batches (`Vindi::ImportBatch` & `Vindi::ExportBatch`)
234
+
235
+ ```ruby
236
+ # Start a new customer/subscription import batch
237
+ import_batch = Vindi::ImportBatch.create(
238
+ batch_type: "customer",
239
+ file_url: "https://example.com/import.csv"
240
+ )
241
+
242
+ # Request a data export batch
243
+ export_batch = Vindi::ExportBatch.create(
244
+ batch_type: "bill"
245
+ )
246
+ ```