feat: client.colorways.get_photo() for crowd-sourced colorway photos (issue #8)#9
Merged
Conversation
- Add Colorways resource sub-client with get_photo(yarn_id, colorway_id) returning Optional[ColorwayPhoto] via GET /projects/search.json?first_photo - Add AsyncColorways with async get_photo() counterpart - Wire client.colorways onto RavelryClient and AsyncRavelryClient - Add small_url field to ColorwayPhoto - Add first_photo: Optional[ColorwayPhoto] to ProjectsResponse - Document that Colorway.photos is never populated by the yarn embed - Add ColorwayPhoto to responses.py imports - Add 10 tests (get_photo present/null/absent, URL params, errors, regression) - Update resources.md with colorway photo section and client.colorways table row - Update quickstart.md with get_photo usage example - Bump version to 0.2.2 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
client.colorways.get_photo(yarn_id, colorway_id)returnsOptional[ColorwayPhoto]by queryingGET /projects/search.json?yarn_id=X&colorway_id=Y&page_size=1and extractingfirst_photo— the same image Ravelry shows on colorway grid tilesAsyncColorways.get_photo()is the async counterpartColorwayPhotogainssmall_url(third size variant from the API)ProjectsResponsegainsfirst_photo: Optional[ColorwayPhoto] = NoneColorwaydocstring updated to clarifyphotosis never populated by the yarn embed and to direct callers toget_photo()client.colorwayswired onto bothRavelryClientandAsyncRavelryClientget_photo()usageWhy not
GET /colorways/{id}.json?That endpoint redirects to the Ravelry login page for all developer credential types. The
projects/search.jsonpath withyarn_id+colorway_idis the documented approach Ravelry itself uses.Test plan
get_photoreturnsColorwayPhotowhenfirst_photopresent in responseNonewhenfirst_photoisnullor absentyarn_id,colorway_id,page_size=1query paramsRavelryAPIErroron 401 and 404Colorway.photosis empty list from yarn embed (regression)Closes #8
Generated with Claude Code