Commit 0af9a55
authored
refactor: use thingiverse-client SDK instead of manual API calls (#3)
* refactor: use thingiverse-client SDK instead of manual API calls
- Replace requests with thingiverse-client (AuthenticatedClient)
- Use SDK endpoints for: list user things, create/patch thing, get file/image
metadata, delete file/image
- Keep upload flow via client.get_httpx_client() for prepare/finalize and
httpx for S3 upload (SDK has no POST things/id/files)
- Add _thing_to_post_body / _thing_to_patch_body for SDK request bodies
- Raise httpx.HTTPStatusError on API errors via _raise_for_status()
Made-with: Cursor
* fix: raise on non-ok status in _raise_for_status, allow 201 for post_things
- _raise_for_status(response, ok=(200,)) now raises for any status not in ok,
not only >= 400, so 201/204 etc. no longer fall through and use response.parsed
- post_things uses ok=(200, 201) and guards against parsed being None
- All call sites that use response.parsed call _raise_for_status with explicit
success set; delete path unchanged (only calls when status >= 400)
Made-with: Cursor
* fix: use getattr for post_things id (SDK models have no .get())
SDK attrs-based models do not support dict-like .get(); use getattr(created, 'id', None)
and raise if missing instead of created.get('id') which would AttributeError.
Made-with: Cursor
* fix: pass response.request into HTTPStatusError when available
Avoid request=None so code that uses exc.request (e.g. exc.request.url) does not
raise RuntimeError; use getattr(response, 'request', None) from SDK detailed response.
Made-with: Cursor
* fix: add guard for image added field in check_file_mtime
Mirror the file branch behavior: when response.parsed is None or
additional_properties lacks 'added', return True to avoid
datetime.fromisoformat('') raising ValueError.
Made-with: Cursor
* fix: address three PR review issues
- Guard UNSET for file_schema.date in check_file_mtime (avoid fromisoformat crash)
- Use _raise_for_status(resp, ok=(200, 204)) for delete path (consistent error handling)
- Catch httpx.HTTPError so connection/timeout errors allow config save
Made-with: Cursor
* fix: treat date strings without timezone as UTC in check_file_mtime
Add _parse_utc_date() that normalizes Z to +00:00 and, when the string
has no timezone, assigns timezone.utc so comparison is correct (matching
old behavior of appending Z).
Made-with: Cursor
* fix: include is_customizer in _thing_to_patch_body patch_keys
Match _thing_to_post_body and old behavior so PATCH sends is_customizer.
Made-with: Cursor1 parent d7e99c5 commit 0af9a55
2 files changed
+200
-85
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
0 commit comments