This PR allows us to dynamically define api_versions based on the response from https://app.shopify.com/services/apis.json
This removes the need to manually updated the gem every time a new version is released or set to end of life.
When the gem is required, we define a set of known versions from the unauthenticated services/apis.json endpoint and everything behaves more or less like it did before. If an unknown version is attempted to be set (ie as of today, 2020-04 or taco-42) an UnknownVersion error is raised with all known versions as message.
If for some reason the known_version_set cannot be initialized at start, then we default to assuming the version is valid, and rely on the server to handle the request and return an error if necessary. Developers can retry defining the version set by calling ShopifyAPI::ApiVersion.define_known_versions at anytime. Any version that was fetched from the server will have persisted? return true, and any on the fly version instances would return false.
ApiVersion attributes were solidified internally at shopify I think after version support was added to the gem, so I also deprecated and aliased methods like #name and #stable? to #handle and #supported?
该提问来源于开源项目:Shopify/shopify_api