- How do I install coredump/jdd-api in a Laravel project?
- Run `composer require coredump/jdd-api` in your project root. The package integrates with Laravel’s service container automatically, so no additional configuration is needed unless you’re using custom API endpoints.
- Can I use this package with Laravel 10 or newer?
- The package is designed for modern Laravel versions (8.x+) and should work with Laravel 10. However, verify compatibility by checking the package’s `composer.json` for PHP/Laravel version constraints, as newer Laravel releases may introduce breaking changes.
- How do I chain nested API endpoints like `/users/1/roleObject/users`?
- Use fluent chaining: `this.$api.users[1].roleObject.users.array()`. The package maps paths to intuitive JS accessors, so nested relationships are resolved automatically with minimal syntax.
- Does coredump/jdd-api support calling server-side model methods (e.g., `evaluate()`)?
- Yes. Use `call()`, `arrayCall()`, or `rowCall()` to invoke model methods with parameters. For example, `this.$api.users[1].call('evaluate', {date: today})` sends a POST request to trigger the method remotely.
- Is there built-in caching for frequent API calls (e.g., address validation)?
- No, the package doesn’t include caching. For production, integrate Redis or Laravel’s caching drivers (e.g., `spatie/laravel-caching`) to cache responses for endpoints like address validation.
- How do I handle errors like rate limits or invalid API keys?
- The package relies on Guzzle’s HTTP client for requests. Extend it with middleware (e.g., `spatie/fork` for retries) or wrap calls in try-catch blocks to handle Japan Post-specific errors like rate limits or authentication failures.
- Can I use this package with Laravel Queues for async processing?
- Yes. Dispatch background jobs (e.g., `Bus::dispatch(new TrackDeliveryJob($trackingId))`) to process bulk operations like tracking updates asynchronously, then fetch results later via the API.
- Are there alternatives for Japan Post API integration in Laravel?
- Consider official SDKs (e.g., Japan Post’s native PHP client) or third-party packages like `ShipEngine` for broader logistics support. However, `coredump/jdd-api` offers a Laravel/Vue-specific fluent syntax tailored for JSON-driven APIs.
- How do I test this package in CI/CD without hitting Japan Post’s API?
- Mock Guzzle HTTP client responses using Laravel’s `Http` facade or libraries like `mockery`. Stub API calls in tests to validate logic without requiring live API access.
- Does the Vue mixin (`ResourceMixin`) work with Laravel Vite or Webpack?
- Yes, the mixin is designed to work with both Vite and Webpack. Ensure `window.ResourceMixin` is globally available in your Vue app’s entry point (e.g., `app.js` or `main.js`).