Skip to content

Conversation

@jystewart
Copy link

Faraday 2 has been out for a while now, so switch to using that.

Also brings jwt and hashie up to date, and remove support for ruby versions below 3.0

jystewart and others added 24 commits November 19, 2021 13:11
The versions in use were very old
Mostly requires some subtle changes to middleware setup
Pry is only used in the console, and then it's optional.

No need to require it here.
Modern Ruby idiom that's simpler and more readable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Use early return and unary plus operator to reduce unnecessary
string allocations. The unary + creates a mutable string only when
a key is provided, avoiding object allocation in the common case
where no key is needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace complex conditional check with clearer safe navigation
operator (&.) when extracting retry-after header. This is more
readable and follows modern Ruby idioms.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
These attributes are set only in initialize and never mutated
externally, so they should be read-only. This prevents accidental
mutation and makes the API intent clearer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add spacing around hash braces for consistency with the rest of
the codebase. Modern Ruby style guide recommends { key: value }
over {key: value}.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace traditional case/when with modern pattern matching (case/in).
This is a Ruby 3+ feature that provides more expressive and powerful
pattern matching capabilities while maintaining the same behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements automatic pagination for v2.0 API endpoints using the
version-based cursor system. Adds two new methods:

- auto_paginate_v2: Automatically fetches all pages and returns
  a flat array of all results
- each_page_v2: Yields each page to a block for memory-efficient
  processing

The pagination uses the API's version.max cursor to iterate through
pages until an empty data array is returned. Custom parameters are
preserved across paginated requests.

This solves the critical issue of loading large datasets into memory
by providing both automatic and manual pagination options.

Test coverage: 5 new tests covering multiple pages, single page,
custom parameters, empty responses, and block iteration.

Coverage improved from 91.23% to 91.95%

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements Faraday retry middleware to automatically handle:
- 429 Too Many Requests (rate limiting)
- 503 Service Unavailable (transient failures)

Features:
- Automatically retries up to 3 times with exponential backoff
- Respects Retry-After header from API (supports both RFC1123
  date format and integer seconds)
- Configured to retry on both HTTP status codes and raised exceptions
- Adds randomness to retry intervals to avoid thundering herd

Configuration:
- Max retries: 3
- Initial interval: 0.5s with 50% randomness
- Backoff factor: 2x (0.5s, 1s, 2s)
- Retry statuses: 429, 503
- Retry exceptions: TooManyRequests, ServiceUnavailable
- Methods: GET, POST, PUT, DELETE

This solves rate limiting issues by automatically backing off
and respecting API rate limit windows, improving reliability
for high-volume API usage.

Test coverage: 6 new tests covering retry on 429/503, retry
exhaustion, and middleware configuration.

Added dependency: faraday-retry ~> 2.2

Coverage: 90.03% (280/311 lines)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add detailed documentation for all new features including:
- Pagination support (auto_paginate_v2, each_page_v2)
- Automatic retry logic for rate limits
- Error handling and exception types
- Thread-safe usage patterns
- OAuth2 authentication flow
- Advanced usage examples
- Performance optimizations

Includes code examples, best practices, and links to
official API documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Create CHANGELOG.md following mocha project style
- Document all external changes (pagination, retry logic, docs)
- Document all internal improvements (frozen strings, modern Ruby idioms)
- Link changelog into gemspec files list
- Update version from 0.1.0 to 0.2.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This is a comprehensive rebranding to reflect Lightspeed's acquisition
of Vend, while maintaining full backward compatibility.

## Major Changes

* RENAMED: vend-ruby-v2 → lightspeed-retail-ruby
* RENAMED: All Vend module/class references → Lightspeed
* UPDATED: API domain vendhq.com → lightspeedhq.com
* UPDATED: OAuth endpoints to secure.lightspeedhq.com
* UPDATED: Documentation URLs to x-series-api.lightspeedhq.com

## Backward Compatibility

* lib/vend.rb now loads Lightspeed and creates Vend = Lightspeed alias
* All Vend::* classes work via aliasing
* Deprecation warnings shown for legacy usage
* VEND_* and LIGHTSPEED_* environment variables both supported

## New Files

* lib/lightspeed.rb - Main entry point
* lib/lightspeed/* - All 36 transformed library files
* spec/lightspeed/* - All 10 transformed test files
* lightspeed-retail-ruby.gemspec - New gemspec
* MIGRATION.md - Comprehensive migration guide

## Modified Files

* README.md - Complete rewrite for Lightspeed branding
* CHANGELOG.md - Added v0.3.0 section with full details
* Gemfile - Specify lightspeed-retail-ruby gemspec
* examples/* - Updated to use Lightspeed namespace

## Technical Details

* Version: 0.3.0 (breaking change marker, but fully compatible)
* All 50 tests pass with 87.99% coverage
* Environment variable compatibility with deprecation warnings
* Thread-safe configuration maintained
* OAuth2 implementation updated for new domain

See MIGRATION.md for step-by-step migration instructions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant