booqable 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c084014d612e3e317590f31144911c3a3907a85075a17b3172edd2f6eb8c7d9f
4
+ data.tar.gz: 23836e46596f37b74175cd45f4e6ee04ee17eb7b0254bb53395972bc801a55aa
5
+ SHA512:
6
+ metadata.gz: 0a2eb78b9a78a239bec1fda211b177533102e78e4cdd95470692cb5a21132180827d2339caadf723564de9d8091d15c4e6160489f5a4694dfe40fc8bd4a630c2
7
+ data.tar.gz: 7210d24c6985facb00617c0949abe55c0b9034acb53b3120039c7d78e1da3ecd763875ff54c69672e39701049a3ab46f46024c1c6511251840891163a19518c0
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.4
3
+ SuggestExtensions: false
4
+
5
+ Style/StringLiterals:
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ EnforcedStyle: double_quotes
10
+
11
+ inherit_gem: { rubocop-37signals: rubocop-ruby.yml }
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-06-27
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Booqable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,403 @@
1
+ # Booqable.rb
2
+
3
+ Ruby toolkit for the [Booqable API](https://developers.booqable.com/).
4
+
5
+ [Booqable](https://booqable.com) is a rental management platform that helps businesses manage their rental inventory, customers, and orders. This gem provides a Ruby interface to interact with all Booqable API endpoints.
6
+
7
+ ## Table of Contents
8
+ - [Installation](#installation)
9
+ - [Making requests](#making-requests)
10
+ - [Authentication](#authentication)
11
+ - [Configuration](#configuration)
12
+ - [Pagination](#pagination)
13
+ - [Rate limiting](#rate-limiting)
14
+ - [Resources](#resources)
15
+ - [Advanced usage](#advanced-usage)
16
+ - [Development](#development)
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'booqable'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ ```bash
29
+ bundle install
30
+ ```
31
+
32
+ Or install it yourself as:
33
+
34
+ ```bash
35
+ gem install booqable
36
+ ```
37
+
38
+ ## Making requests
39
+
40
+ API methods are available as module methods (consuming module-level configuration) or as client instance methods.
41
+
42
+ ```ruby
43
+ # Provide authentication credentials
44
+ Booqable.configure do |c|
45
+ c.api_key = 'your_api_key_here'
46
+ c.company_id = 'your_company_id'
47
+ end
48
+
49
+ # Fetch orders
50
+ orders = Booqable.orders.list
51
+ ```
52
+
53
+ or
54
+
55
+ ```ruby
56
+ # Create a client instance
57
+ client = Booqable::Client.new(
58
+ api_key: 'your_api_key_here',
59
+ company_id: 'your_company_id'
60
+ )
61
+
62
+ # Fetch orders
63
+ orders = client.orders.list
64
+ ```
65
+
66
+ ## Authentication
67
+
68
+ Booqable supports several authentication methods to suit different use cases:
69
+
70
+ ### API Key Authentication (Recommended)
71
+
72
+ The simplest way to authenticate is with an API key:
73
+
74
+ ```ruby
75
+ Booqable.configure do |c|
76
+ c.api_key = 'your_api_key_here'
77
+ c.company_id = 'your_company_id'
78
+ end
79
+ ```
80
+
81
+ Generate your API key from your Booqable account settings. [Learn more about API keys](https://developers.booqable.com/#authentication-access-token).
82
+
83
+ ### OAuth2 Authentication
84
+
85
+ For applications that need to act on behalf of multiple users:
86
+
87
+ ```ruby
88
+ client = Booqable::Client.new(
89
+ client_id: 'your_oauth_client_id',
90
+ client_secret: 'your_oauth_client_secret',
91
+ company_id: 'your_company_id',
92
+ read_token: -> {
93
+ # Return stored token hash
94
+ JSON.parse(File.read('token.json'))
95
+ },
96
+ write_token: ->(token) {
97
+ # Store token hash
98
+ File.write('token.json', token.to_json)
99
+ }
100
+ )
101
+
102
+ # Complete OAuth flow
103
+ client.authenticate_with_code(params[:code])
104
+ ```
105
+
106
+ ### Single-Use Token Authentication
107
+
108
+ For server-to-server communication requiring enhanced security:
109
+
110
+ ```ruby
111
+ client = Booqable::Client.new(
112
+ single_use_token: 'your_token_id',
113
+ single_use_token_algorithm: 'HS256',
114
+ single_use_token_secret: 'your_signing_secret',
115
+ single_use_token_company_id: 'company_uuid',
116
+ single_use_token_user_id: 'user_uuid',
117
+ company_id: 'your_company_id'
118
+ )
119
+ ```
120
+
121
+ Supports HS256 (HMAC), RS256 (RSA), and ES256 (ECDSA) algorithms. [Learn more about request signing](https://developers.booqable.com/#authentication-request-signing).
122
+
123
+ ### Environment Variables
124
+
125
+ All authentication options can be configured via environment variables:
126
+
127
+ ```bash
128
+ export BOOQABLE_API_KEY="your_api_key_here"
129
+ export BOOQABLE_COMPANY="your_company_id"
130
+ export BOOQABLE_CLIENT_ID="your_oauth_client_id"
131
+ export BOOQABLE_CLIENT_SECRET="your_oauth_client_secret"
132
+ ```
133
+
134
+ ## Configuration
135
+
136
+ Booqable is highly configurable to suit different environments and use cases:
137
+
138
+ ```ruby
139
+ Booqable.configure do |c|
140
+ c.api_key = 'your_api_key_here'
141
+ c.company_id = 'your_company_id'
142
+ c.api_domain = 'booqable.com' # Default
143
+ c.api_version = 4 # Default
144
+ c.per_page = 25 # Default pagination size
145
+ c.auto_paginate = true # Auto-fetch all pages
146
+ end
147
+ ```
148
+
149
+ ### Per-client configuration
150
+
151
+ ```ruby
152
+ client = Booqable::Client.new(
153
+ api_key: 'your_api_key_here',
154
+ company_id: 'your_company_id',
155
+ per_page: 50,
156
+ auto_paginate: false
157
+ )
158
+ ```
159
+
160
+ ## Pagination
161
+
162
+ The Booqable API uses cursor-based pagination. Booqable provides several ways to handle paginated responses:
163
+
164
+ ### Manual pagination
165
+
166
+ ```ruby
167
+ # Fetch first page
168
+ orders = Booqable.orders.list(page: { size: 25, number: 1 })
169
+
170
+ # Fetch next page
171
+ next_orders = Booqable.orders.list(page: { size: 25, number: 2 })
172
+ ```
173
+
174
+ ### Auto-pagination
175
+
176
+ ```ruby
177
+ # Configure auto-pagination
178
+ Booqable.auto_paginate = true
179
+
180
+ # This will automatically fetch ALL orders across all pages
181
+ all_orders = Booqable.orders.list
182
+ ```
183
+
184
+ ## Rate limiting
185
+
186
+ Booqable automatically handles rate limiting and provides access to rate limit information:
187
+
188
+ ```ruby
189
+ orders = Booqable.orders.list
190
+
191
+ # Check rate limit status
192
+ rate_limit = Booqable.rate_limit
193
+ puts "Remaining requests: #{rate_limit.remaining}"
194
+ puts "Reset time: #{rate_limit.reset_at}"
195
+ puts "Limit: #{rate_limit.limit}"
196
+ ```
197
+
198
+ ### Automatic retries
199
+
200
+ Booqable includes automatic retry logic so every request will be retried two times
201
+ by default if it fails due to a server error.
202
+
203
+ To disable automatic retries, you can configure it globally:
204
+
205
+ ```ruby
206
+ Booqable.configure do |c|
207
+ c.no_retries = true # Disable automatic retries
208
+ end
209
+ ```
210
+
211
+ ## Resources
212
+
213
+ Booqable provides access to all Booqable API resources through a consistent interface:
214
+
215
+ ### Orders
216
+
217
+ ```ruby
218
+ # List orders with filtering and includes
219
+ orders = Booqable.orders.list(
220
+ include: 'customer,items',
221
+ filter: { status: 'reserved' },
222
+ sort: '-created_at'
223
+ )
224
+
225
+ # Find specific order
226
+ order = Booqable.orders.find('order_id', include: 'customer,items')
227
+ order.items.count
228
+ order.customer.name
229
+
230
+ # Create order
231
+ new_order = Booqable.orders.create(
232
+ starts_at: '2024-01-01T00:00:00Z',
233
+ stops_at: '2024-01-02T00:00:00Z',
234
+ status: 'draft'
235
+ )
236
+ new_order.status # => 'draft'
237
+
238
+ # Update order
239
+ updated_order = Booqable.orders.update('order_id', status: 'reserved')
240
+ updated_order.status # => 'reserved'
241
+
242
+ # Delete order
243
+ deleted_order = Booqable.orders.delete('order_id')
244
+ deleted_order.id # => 'order_id'
245
+ ```
246
+
247
+ ### Customers
248
+
249
+ ```ruby
250
+ # List customers
251
+ customers = Booqable.customers.list(
252
+ filter: { name: 'John' },
253
+ sort: 'created_at'
254
+ )
255
+
256
+ # Create customer
257
+ customer = Booqable.customers.create(
258
+ name: 'John Doe',
259
+ email: 'john@example.com'
260
+ )
261
+
262
+ # Update customer
263
+ Booqable.customers.update('customer_id', name: 'Jane Doe')
264
+
265
+ # Delete customer
266
+ deleted_customer = Booqable.customers.delete('customer_id')
267
+ deleted_customer.id # => 'customer_id'
268
+ ```
269
+
270
+ ### Products
271
+
272
+ ```ruby
273
+ # List products with inventory information
274
+ products = Booqable.products.list(
275
+ include: 'inventory_levels',
276
+ filter: { type: 'trackable' }
277
+ )
278
+
279
+ # Find product
280
+ product = Booqable.products.find('product_id', include: 'properties')
281
+
282
+ # Create product
283
+ product = Booqable.products.create(
284
+ name: 'Camera',
285
+ type: 'trackable',
286
+ base_price_in_cents: 50000
287
+ )
288
+
289
+ # Delete product
290
+ deleted_product = Booqable.products.delete('product_id')
291
+ deleted_product.id # => 'product_id'
292
+ ```
293
+
294
+ ### Available resources
295
+
296
+ Booqable provides access to all Booqable API resources:
297
+
298
+ **Core Resources:**
299
+ - `orders`, `customers`, `products`, `items`
300
+ - `employees`, `companies`, `locations`
301
+ - `payments`, `invoices`, `documents`
302
+
303
+ **Inventory Management:**
304
+ - `inventory_levels`, `stock_items`, `stock_adjustments`
305
+ - `transfers`, `plannings`, `clusters`
306
+
307
+ **Configuration:**
308
+ - `settings`, `properties`, `tax_rates`
309
+ - `payment_methods`, `email_templates`
310
+
311
+ **And many more...** See the [full resource list](lib/booqable/resources.json) for all available endpoints.
312
+
313
+ ## Advanced usage
314
+
315
+ ### Custom middleware
316
+
317
+ Booqable uses Faraday for HTTP requests. You can customize the middleware stack:
318
+
319
+ ```ruby
320
+ Booqable.configure do |c|
321
+ c.middleware = Faraday::RackBuilder.new do |builder|
322
+ builder.use MyCustomMiddleware
323
+ builder.use Booqable::Middleware::RaiseError
324
+ builder.adapter Faraday.default_adapter
325
+ end
326
+ end
327
+ ```
328
+
329
+ ### Connection options
330
+
331
+ ```ruby
332
+ Booqable.configure do |c|
333
+ c.connection_options = {
334
+ headers: { 'X-Custom-Header' => 'value' },
335
+ ssl: { verify: false },
336
+ timeout: 30
337
+ }
338
+ end
339
+ ```
340
+
341
+ ### Proxy support
342
+
343
+ ```ruby
344
+ Booqable.configure do |c|
345
+ c.proxy = 'http://proxy.example.com:8080'
346
+ end
347
+ ```
348
+
349
+ ### Custom serialization
350
+
351
+ ```ruby
352
+ # Access raw response data
353
+ response = Booqable.orders.list
354
+ puts response.class # => Sawyer::Resource
355
+
356
+ # Get response metadata
357
+ puts Booqable.last_response.status
358
+ puts Booqable.last_response.headers
359
+ ```
360
+
361
+ ## Development
362
+
363
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
364
+
365
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
366
+
367
+ ### Running tests
368
+
369
+ ```bash
370
+ # Run all tests
371
+ bundle exec rake spec
372
+
373
+ # Run specific test file
374
+ bundle exec rspec spec/booqable/client_spec.rb
375
+ ```
376
+
377
+ ### Contributing
378
+
379
+ Bug reports and pull requests are welcome on GitHub at https://github.com/booqable/booqable.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/booqable/booqable.rb/blob/master/CODE_OF_CONDUCT.md).
380
+
381
+ ## Versioning
382
+
383
+ This library aims to support and is [tested against](https://github.com/booqable/booqable.rb/actions) the following Ruby versions:
384
+
385
+ - Ruby 3.2
386
+ - Ruby 3.3
387
+ - Ruby 3.4
388
+
389
+ If something doesn't work on one of these versions, it's a bug.
390
+
391
+ This library may inadvertently work (or seem to work) on other Ruby versions, however support will only be provided for the versions listed above.
392
+
393
+ ## License
394
+
395
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
396
+
397
+ ## Code of Conduct
398
+
399
+ Everyone interacting in the Booqable project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/booqable/booqable.rb/blob/master/CODE_OF_CONDUCT.md).
400
+
401
+ ---
402
+
403
+ **Questions?** Check out the [Booqable API documentation](https://developers.booqable.com/) or [open an issue](https://github.com/booqable/booqable.rb/issues/new).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]