bold-commerce / go-shopify

Go client for the Shopify API
MIT License
330 stars 256 forks source link

Add published param to Page #305

Closed k-yomo closed 3 months ago

k-yomo commented 3 months ago

This PR adds Published field to Page to make it possible to pass published parameter for create/update. Also not to let user confuse, the field will be consistent with published_at when it's read.

curl -d '{"page":{"title":"Warranty information","body_html":"<h2>Warranty</h2>\n<p>Returns accepted if we receive items <strong>30 days after purchase</strong>.</p>","published":false}}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2024-07/pages.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"

https://shopify.dev/docs/api/admin-rest/2024-07/resources/page#post-pages-examples

oliver006 commented 3 months ago

Thanks for the PR! If the published field isn't returned than we should make it optional, e.g. nullable and not populate when we think we know what the value should be. So let's just change published to *bool and no longer set it based on the published_at value when parsing a response and we should be good to go.

k-yomo commented 3 months ago

@oliver006 Thanks for the review! I fixed published to *bool as suggested!