-
Notifications
You must be signed in to change notification settings - Fork 0
Add inspector_image_url support to createInspection #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Update the createInspection method to accept an optional inspectorImageUrl parameter and include it in the API request when provided. This allows the gcp-fixle Cloud Function to use the SDK instead of making direct HTTP requests. Closes #1 🤖 Generated with [Claude Code](https://claude.com/claude-code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for an optional inspectorImageUrl parameter to the createInspection method, allowing the SDK to pass inspector profile images to the Fixle API. This change enables the gcp-fixle Cloud Function to use the SDK natively instead of making custom HTTP requests to include the inspector image URL received from Spectora webhooks.
Key changes:
- Extended
createInspectionmethod to accept an optionalinspectorImageUrlparameter - Updated
InspectionRequestinterface to include theinspector_image_urlfield - Added comprehensive test coverage for both scenarios (with and without the image URL)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/client.ts | Added optional inspectorImageUrl parameter to createInspection method signature, updated InspectionRequest interface, and implemented conditional payload inclusion using spread operator |
| tests/client.test.ts | Added two test cases covering createInspection behavior both with and without the inspectorImageUrl parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/client.test.ts
Outdated
| const mockResponse = { | ||
| statusCode: 201, | ||
| on: jest.fn((event, handler) => { | ||
| if (event === 'data') handler('{"data":{"id":"456"}}'); | ||
| if (event === 'end') handler(); | ||
| }), | ||
| }; | ||
|
|
||
| const http = require('http'); | ||
| let capturedBody = ''; | ||
| http.request = jest.fn((options, callback) => { | ||
| callback(mockResponse); | ||
| return { | ||
| on: jest.fn(), | ||
| write: jest.fn((data: string) => { capturedBody = data; }), | ||
| end: jest.fn(), | ||
| }; | ||
| }); | ||
|
|
||
| await client.createInspection(123, 45678); | ||
|
|
||
| const parsedBody = JSON.parse(capturedBody); | ||
| expect(parsedBody.inspection.external_id).toBe('45678'); | ||
| expect(parsedBody.inspection.inspector_image_url).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should create inspection with inspectorImageUrl', async () => { | ||
| const mockResponse = { | ||
| statusCode: 201, | ||
| on: jest.fn((event, handler) => { | ||
| if (event === 'data') handler('{"data":{"id":"456"}}'); | ||
| if (event === 'end') handler(); | ||
| }), | ||
| }; | ||
|
|
||
| const http = require('http'); | ||
| let capturedBody = ''; | ||
| http.request = jest.fn((options, callback) => { | ||
| callback(mockResponse); | ||
| return { | ||
| on: jest.fn(), | ||
| write: jest.fn((data: string) => { capturedBody = data; }), | ||
| end: jest.fn(), | ||
| }; | ||
| }); |
Copilot
AI
Dec 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is significant code duplication between the two test cases. The mock setup code (lines 52-69 and 79-96) is nearly identical. Consider extracting the common mock setup into a helper function or a beforeEach block to improve maintainability and reduce duplication.
🤖 Claude Code ReviewPR Review: Add Inspector Image URL Support✅ What's Good
🔧 Potential Improvements1. URL ValidationConsider adding basic URL validation for the if (inspectorImageUrl && !isValidUrl(inspectorImageUrl)) {
throw new Error('Invalid inspector image URL provided');
}2. Test DuplicationThe test setup is duplicated across both test cases. Consider extracting to a helper function: const setupMockHttp = () => {
const mockResponse = {
statusCode: 201,
on: jest.fn((event, handler) => {
if (event === 'data') handler('{"data":{"id":"456"}}');
if (event === 'end') handler();
}),
};
let capturedBody = '';
const http = require('http');
http.request = jest.fn((options, callback) => {
callback(mockResponse);
return {
on: jest.fn(),
write: jest.fn((data: string) => { capturedBody = data; }),
end: jest.fn(),
};
});
return { capturedBody: () => capturedBody };
};3. Documentation EnhancementConsider adding validation details to the JSDoc: * @param inspectorImageUrl - Optional URL to the inspector's profile image (must be valid HTTP/HTTPS URL)4. Edge Case TestingConsider adding tests for edge cases:
📝 Minor Notes
🎯 Overall AssessmentThis is a solid, well-implemented feature addition. The code follows good practices and maintains backward compatibility. The main areas for improvement are around input validation and test organization, but these are minor enhancements to an already good implementation. Recommendation: ✅ Approve with minor suggestions Automated review by Claude Code (Sonnet 4) |
🤖 Cursor Agent Review
Automated review by cursor-agent (GPT-5.1 Codex) |
🤖 Cursor Agent Review (GPT-5.2)High-signal feedback✅ What’s good
|
- Fix test mock isolation: use jest.mock with proper reset in beforeEach - Extract mock setup into reusable helper function - Fix empty string behavior: use !== undefined check so empty strings can be explicitly sent to clear inspector images - Add test case for empty string inspectorImageUrl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add inspector_image_url support to createInspection method Update the createInspection method to accept an optional inspectorImageUrl parameter and include it in the API request when provided. This allows the gcp-fixle Cloud Function to use the SDK instead of making direct HTTP requests. Closes #1 🤖 Generated with [Claude Code](https://claude.com/claude-code) * Address PR review feedback - Fix test mock isolation: use jest.mock with proper reset in beforeEach - Extract mock setup into reusable helper function - Fix empty string behavior: use !== undefined check so empty strings can be explicitly sent to clear inspector images - Add test case for empty string inspectorImageUrl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add README with installation and API documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Summary
inspectorImageUrlparameter to thecreateInspectionmethodInspectionRequestinterface to includeinspector_image_urlfieldinspector_image_urlin API request payload when providedChanges
src/client.ts: Updated method signature and request building logictests/client.test.ts: Added tests for both with and without inspector image URLRelated Issues
Closes #1
Closes #2
Test plan
createInspectionwithoutinspectorImageUrlcreateInspectionwithinspectorImageUrl🤖 Generated with Claude Code