Explorar el Código

Merge branch 'master' into docker-setup

Álax de Carvalho Alves hace 6 años
padre
commit
85b237af4e
Se han modificado 4 ficheros con 14 adiciones y 7 borrados
  1. 2 2
      README.md
  2. 1 0
      lib/shopify_api.rb
  3. 2 5
      lib/shopify_api/api_version.rb
  4. 9 0
      lib/shopify_api/defined_versions.rb

+ 2 - 2
README.md

@@ -38,7 +38,7 @@ ShopifyAPI::Session.temp(domain: domain, token: token, api_version: api_version)
 end
 ```
 
-The `api_version` attribute can take the string or symbol name of any known version and correctly coerce it to a `ShopifyAPI::ApiVersion`.  You can find the currently defined versions [here](https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/api_version.rb#L58), follow these [instructions](#adding-aditional-api-versions) to add additional version definitions if needed.
+The `api_version` attribute can take the string or symbol name of any known version and correctly coerce it to a `ShopifyAPI::ApiVersion`.  You can find the currently defined versions [here](https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/defined_versions.rb), follow these [instructions](#adding-aditional-api-versions) to add additional version definitions if needed.
 
 For example if you want to use the `2019-04` version you would create a session like this:
 ```ruby
@@ -344,7 +344,7 @@ result = client.query(SHOP_NAME_QUERY)
 result.data.shop.name
 ```
 
-## Adding aditional API versions
+## Adding additional API versions
 We will release a gem update every time we release a new version of the API. Most of the time upgrading the gem will be all you need to do.
 
 If you want access to a newer version without upgrading you can define an api version.

+ 1 - 0
lib/shopify_api.rb

@@ -6,6 +6,7 @@ require 'digest/md5'
 require 'base64'
 require 'active_resource/detailed_log_subscriber'
 require 'shopify_api/limits'
+require 'shopify_api/defined_versions'
 require 'shopify_api/api_version'
 require 'active_resource/json_errors'
 require 'shopify_api/disable_prefix_check'

+ 2 - 5
lib/shopify_api/api_version.rb

@@ -4,6 +4,8 @@ module ShopifyAPI
     class UnknownVersion < StandardError; end
     class InvalidVersion < StandardError; end
 
+    extend DefinedVersions
+
     include Comparable
 
     def self.coerce_to_version(version_or_name)
@@ -25,11 +27,6 @@ module ShopifyAPI
       @versions = {}
     end
 
-    def self.define_known_versions
-      define_version(Unstable.new)
-      define_version(Release.new('2019-04'))
-    end
-
     def self.latest_stable_version
       @versions.values.select(&:stable?).sort.last
     end

+ 9 - 0
lib/shopify_api/defined_versions.rb

@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+module ShopifyAPI
+  module DefinedVersions
+    def define_known_versions
+      define_version(ShopifyAPI::ApiVersion::Unstable.new)
+      define_version(ShopifyAPI::ApiVersion::Release.new('2019-04'))
+    end
+  end
+end