bold-commerce / go-shopify

Go client for the Shopify API
MIT License
328 stars 255 forks source link

Define consts for well known values. #221

Closed c9845 closed 1 year ago

c9845 commented 1 year ago

Define types and constants for well-defined field values to aid in code editor type checking and auto-completion and in reducing back-and-forth between code and Shopify docs to check acceptable values. Since Shopify limits the values certain fields can accept, this library should do so as well!

Shopify defines acceptable values for certain fields. This defines those values, and an associated type, so that users are less likely to provide an unacceptable value. Code editors may even provide a list of acceptable values for a field for auto-completion. This is really just a code-writing improvement to prevent having to look up the acceptable values for a field in the Shopify API docs.

This should not break any existing code since the new types are all strings and string values, in existing code, will still be accepted.

codecov[bot] commented 1 year ago

Codecov Report

Patch and project coverage have no change.

Comparison is base (0319854) 100.00% compared to head (510c8c0) 100.00%.

:exclamation: Current head 510c8c0 differs from pull request most recent head e2934a0. Consider uploading reports for the commit e2934a0 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #221 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 44 44 Lines 1715 1715 ========================================= Hits 1715 1715 ``` | [Files Changed](https://app.codecov.io/gh/bold-commerce/go-shopify/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bold+Commerce) | Coverage Δ | | |---|---|---| | [draft\_order.go](https://app.codecov.io/gh/bold-commerce/go-shopify/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bold+Commerce#diff-ZHJhZnRfb3JkZXIuZ28=) | `100.00% <ø> (ø)` | | | [metafield.go](https://app.codecov.io/gh/bold-commerce/go-shopify/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bold+Commerce#diff-bWV0YWZpZWxkLmdv) | `100.00% <ø> (ø)` | | | [order.go](https://app.codecov.io/gh/bold-commerce/go-shopify/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bold+Commerce#diff-b3JkZXIuZ28=) | `100.00% <ø> (ø)` | | | [product.go](https://app.codecov.io/gh/bold-commerce/go-shopify/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bold+Commerce#diff-cHJvZHVjdC5nbw==) | `100.00% <ø> (ø)` | | | [variant.go](https://app.codecov.io/gh/bold-commerce/go-shopify/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Bold+Commerce#diff-dmFyaWFudC5nbw==) | `100.00% <ø> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

oliver006 commented 1 year ago

This needs a rebase plz.

c9845 commented 1 year ago

@oliver006 I rebased as requested.

c9845 commented 1 year ago

Of note, it looks like similar work has already been done for payouts, wee PayoutStatus and the related const definitions.

The PayoutStatus type could be unexported though. It only needs to be exported to allow for creating of a PayoutStatus with something like var customPayoutStatus PayoutStatus = "custom". But this really should never be needed since the applicable values are defined by Shopify and, even in the off case someone does need a custom value, they can just provide a string to the field in the struct.