-
Notifications
You must be signed in to change notification settings - Fork 0
Fix API compatibility issues and update response structures #2
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
base: main
Are you sure you want to change the base?
Conversation
- Add configurable userIdentifier field to Client (replaces hardcoded "MTS API") - Add QueueID support for Submit endpoint (printer ID and queue ID are separate) - Fix Submit endpoint to properly handle v1.1 API requirements: - Send version: 1.1 header for v1.1 features - Keep title, user, PDL in query params (not body) for v1.1 - Add userMapping and releaseImmediately parameter support - Update PrintOptions with v1.1 fields (MediaSize, Scaling) - Fix SubmitResponse structure to match actual API: - Change timestamps from int64 to ISO format strings - Add nested _links section within job object - Update root _links structure - Update Printer response structures for proper HAL+JSON parsing: - Fix Copies.Default field name (defaultz) - Add proper HAL link structures instead of generic maps - Update PrintFile and PrintData to accept separate queueID parameter Breaking changes: - PrintFile and PrintData now require queueID parameter - Submit requires QueueID to be set (no backward compatibility) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary of Changes
Hello @Fank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request primarily focuses on enhancing the Printix API client's compatibility and functionality by addressing discrepancies with the actual API endpoints. It introduces support for the v1.1 API, refines the print job submission process with mandatory queue IDs, and standardizes response structures for improved reliability.
Highlights
- API Compatibility & V1.1 Support: The client has been updated for full compatibility with the actual Printix API endpoints, including comprehensive support for the v1.1 API. This involves adjusting request formats, adding new parameters like
userMapping
,releaseImmediately
,MediaSize
, andScaling
, and ensuringtitle
,user
,PDL
are correctly sent as query parameters for v1.1 requests. - Queue ID Integration (Breaking Change): A
QueueID
field has been introduced to thePrintJob
struct, and thesubmitEndpoint
now explicitly includes it. This is a breaking change asQueueID
is now a required parameter for job submission, and thePrintFile
andPrintData
function signatures have been updated to accept this new parameter. - User Identifier Configuration: A configurable
userIdentifier
has been added to theClient
struct, allowing the client to specify its identity (defaulting to 'API Client') instead of using hardcoded strings like 'MTS API' in print job submissions. - Response Structure Harmonization: The
SubmitResponse
structure has been corrected to align with the actual API, changing job timestamps fromint64
to ISO string format and properly structuring nested_links
sections. Additionally,Printer
response structures were refined to use explicit HAL link types and fix a specific field name (Copies.Default
todefaultz
).
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request addresses API compatibility issues and improves the client library. The changes include adding queueID
support, correcting the v1.1 API request format, and using strongly-typed structs for API responses. The tests have also been updated.
if job.ReleaseImmediately != nil && !*job.ReleaseImmediately { | ||
params.Set("releaseImmediately", "false") | ||
} else if job.ReleaseImmediately == nil { | ||
params.Set("releaseImmediately", "true") | ||
} |
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.
The logic for handling the releaseImmediately
query parameter is incomplete. It misses the case where job.ReleaseImmediately
is explicitly set to true
. In that scenario, the parameter is not added to the query string at all, which is a bug.
if job.ReleaseImmediately != nil && !*job.ReleaseImmediately { | |
params.Set("releaseImmediately", "false") | |
} else if job.ReleaseImmediately == nil { | |
params.Set("releaseImmediately", "true") | |
} | |
if job.ReleaseImmediately != nil && !*job.ReleaseImmediately { | |
params.Set("releaseImmediately", "false") | |
} else { | |
params.Set("releaseImmediately", "true") | |
} |
if job.UserMapping != nil { | ||
v11Body["userMapping"] = job.UserMapping | ||
} else { | ||
v11Body["userMapping"] = nil | ||
} |
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.
- Remove separate HTTP client creation in UploadDocument - Use the same httpClient configured when creating the client - This respects custom timeouts, transports, and other configurations - Enables better testing and consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
This PR fixes several API compatibility issues discovered while testing against the actual Printix API endpoints.
Changes
1. User Identifier Configuration
userIdentifier
field to Client structWithUserIdentifier()
option to configure it (defaults to "API Client")2. Queue ID Support
QueueID
field to PrintJob struct/printers/{printerId}/queues/{queueId}/submit
3. v1.1 API Compatibility
title
,user
,PDL
parameters stay in query string (not body)version: 1.1
header for v1.1 featuresuserMapping
for user assignmentreleaseImmediately
parameter (defaults to true)MediaSize
andScaling
in PrintOptions4. Response Structure Fixes
int64
tostring
(ISO format)_links
section within job object_links
structureCopies.Default
field (API returns "defaultz")Test plan
Breaking Changes
PrintFile
signature changed:PrintFile(ctx, printerID, queueID, title, filePath, options)
PrintData
signature changed:PrintData(ctx, printerID, queueID, title, data, pdl, options)
Submit
now requiresQueueID
to be set (returns error if empty)🤖 Generated with Claude Code