shopify_api 4.11.0 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0cc884464a1fe2083dd24a14965d0480f67e292
4
- data.tar.gz: 5a29ecedb51e1ba5c02fbde2c341f9bedef57b9e
3
+ metadata.gz: beef05479b8becd46a2626b66e880345b4e8c5ba
4
+ data.tar.gz: e7a9ccd9ec76a44eed7e12345154e20e36e31f0d
5
5
  SHA512:
6
- metadata.gz: 99151c8edf235fb8b76c90acb943304f330cab627490b5829d968b4c6a35427d51aa4b982adb890a5a061cfe94a5f6a257ae5863189ee056499017a533d8fb90
7
- data.tar.gz: eb2b22d6ff86b6d97b69cc254029ac4bb1dc680ba88ac74f55bab22d2e2809a4a8f3a6efe5d85b14ca16f729beb060af34a64508bec638b9c20c4b46dd17cac8
6
+ metadata.gz: b99a9efcd6c2e045f99404b8defc2f0ddaf4c65ffc2441d69998fd083ca966c1d483ce57ce855739c9b166f15d6c08bf63c8cc18b6ef50b8773c6b520749fcde
7
+ data.tar.gz: 7e5b5b0dfbf739267cbb6643dcb757b5cf0d83f5a22ea6065c1d8f662320f91703a5e7064a02254136b968a85867e797b9ea69d55381f3ac47b0271e937b0cbd
@@ -0,0 +1,8 @@
1
+ inherit_from:
2
+ - https://shopify.github.io/ruby-style-guide/rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+
7
+ Rails:
8
+ Enabled: false
@@ -2,7 +2,6 @@ language: ruby
2
2
  sudo: false
3
3
 
4
4
  rvm:
5
- - '2.0'
6
5
  - 2.3.1
7
6
  - 2.4.0-preview1
8
7
 
@@ -15,9 +14,6 @@ gemfile:
15
14
  - Gemfile_ar_master
16
15
 
17
16
  matrix:
18
- exclude:
19
- - rvm: '2.0'
20
- gemfile: Gemfile_ar_master
21
17
  fast_finish: true
22
18
  allow_failures:
23
19
  - rvm: 2.4.0-preview1
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == Version 4.12.0
2
+
3
+ * Added support for the GraphQL API
4
+
1
5
  == Version 4.11.0
2
6
 
3
7
  * Added `ShopifyAPI::InventoryItem`
data/README.md CHANGED
@@ -221,6 +221,30 @@ gem install shopify_cli
221
221
  shopify-cli help
222
222
  ```
223
223
 
224
+ ## GraphQL
225
+
226
+ This library also supports Shopify's new [GraphQL API](https://help.shopify.com/api/graphql-admin-api)
227
+ via a dependency on the [graphql-client](https://github.com/github/graphql-client) gem.
228
+ The authentication process (steps 1-5 under [Getting Started](#getting-started))
229
+ is identical. Once your session is activated, simply construct a new graphql
230
+ client and use `parse` and `query` as defined by
231
+ [graphql-client](https://github.com/github/graphql-client#defining-queries).
232
+
233
+ ```ruby
234
+ client = ShopifyAPI::GraphQL.new
235
+
236
+ SHOP_NAME_QUERY = client.parse <<-'GRAPHQL'
237
+ {
238
+ shop {
239
+ name
240
+ }
241
+ }
242
+ GRAPHQL
243
+
244
+ result = client.query(SHOP_NAME_QUERY)
245
+ result.data.shop.name
246
+ ```
247
+
224
248
  ## Threadsafety
225
249
 
226
250
  ActiveResource is threadsafe as of version 4.1 (which works with Rails 4.x and above).
@@ -232,7 +256,8 @@ If you were previously using Shopify's [activeresource fork](https://github.com/
232
256
  Download the source code and run:
233
257
 
234
258
  ```bash
235
- rake install
259
+ bundle install
260
+ bundle exec rake test
236
261
  ```
237
262
 
238
263
  ## Additional Resources
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShopifyAPI
4
+ class ApiPermission < Base
5
+ def self.destroy
6
+ delete(:current)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'graphql/client'
3
+ require 'graphql/client/http'
4
+
5
+ module ShopifyAPI
6
+ # GraphQL API.
7
+ class GraphQL
8
+ def initialize
9
+ uri = Base.site.dup
10
+ uri.path = '/admin/api/graphql.json'
11
+ @http = ::GraphQL::Client::HTTP.new(uri.to_s) do
12
+ define_method(:headers) do |_context|
13
+ Base.headers
14
+ end
15
+ end
16
+ @schema = ::GraphQL::Client.load_schema(@http)
17
+ @client = ::GraphQL::Client.new(schema: @schema, execute: @http)
18
+ end
19
+
20
+ delegate :parse, :query, to: :@client
21
+ end
22
+ end
@@ -1,8 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This resource is deprecated and will be removed in a future version of this gem.
4
+ # Use ShopifyAPI::ApiPermission.destroy instead
5
+
1
6
  module ShopifyAPI
2
7
  class OAuth < Base
3
8
  self.collection_name = 'oauth'
4
9
 
5
10
  def self.revoke
11
+ warn '[DEPRECATED] ShopifyAPI::OAuth#revoke is deprecated and will be removed in a future version. ' \
12
+ 'Use ShopifyAPI::ApiPermission#destroy instead.'
13
+
6
14
  delete(:revoke)
7
15
  end
8
16
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyAPI
2
- VERSION = "4.11.0"
2
+ VERSION = "4.12.0"
3
3
  end
@@ -23,10 +23,11 @@ Gem::Specification.new do |s|
23
23
  s.summary = %q{ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web services}
24
24
  s.license = "MIT"
25
25
 
26
- s.required_ruby_version = ">= 2.0"
26
+ s.required_ruby_version = ">= 2.1"
27
27
 
28
28
  s.add_runtime_dependency("activeresource", ">= 3.0.0")
29
29
  s.add_runtime_dependency("rack")
30
+ s.add_runtime_dependency("graphql-client")
30
31
 
31
32
  s.add_development_dependency("mocha", ">= 0.9.8")
32
33
  s.add_development_dependency("fakeweb")
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class ApiPermissionTest < Test::Unit::TestCase
5
+ test "revoke access token" do
6
+ fake "api_permissions/current", method: :delete, status: 200, body: "{}"
7
+ assert ShopifyAPI::ApiPermission.destroy
8
+ end
9
+ end
@@ -5,19 +5,22 @@ class VariantTest < Test::Unit::TestCase
5
5
  def test_get_variants
6
6
  fake "products/632910392/variants", :method => :get, :body => load_fixture('variants')
7
7
 
8
- v = ShopifyAPI::Variant.find(:all, :params => {:product_id => 632910392})
8
+ variants = ShopifyAPI::Variant.find(:all, :params => { :product_id => 632910392 })
9
+ assert_equal variants.map(&:id).sort, [39072856, 49148385, 457924702, 808950810]
9
10
  end
10
11
 
11
12
  def test_get_variant_namespaced
12
13
  fake "products/632910392/variants/808950810", :method => :get, :body => load_fixture('variant')
13
14
 
14
15
  v = ShopifyAPI::Variant.find(808950810, :params => {:product_id => 632910392})
16
+ assert_equal 632910392, v.product_id
15
17
  end
16
18
 
17
19
  def test_get_variant
18
20
  fake "variants/808950810", :method => :get, :body => load_fixture('variant')
19
21
 
20
22
  v = ShopifyAPI::Variant.find(808950810)
23
+ assert_equal 632910392, v.product_id
21
24
  end
22
25
 
23
26
  def test_product_id_should_be_accessible_if_via_product_endpoint
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.0
4
+ version: 4.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: graphql-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: mocha
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,7 @@ extra_rdoc_files:
122
136
  files:
123
137
  - ".document"
124
138
  - ".gitignore"
139
+ - ".rubocop.yml"
125
140
  - ".travis.yml"
126
141
  - CHANGELOG
127
142
  - CONTRIBUTING.md
@@ -155,6 +170,7 @@ files:
155
170
  - lib/shopify_api/resources/access_token.rb
156
171
  - lib/shopify_api/resources/address.rb
157
172
  - lib/shopify_api/resources/announcement.rb
173
+ - lib/shopify_api/resources/api_permission.rb
158
174
  - lib/shopify_api/resources/application_charge.rb
159
175
  - lib/shopify_api/resources/application_credit.rb
160
176
  - lib/shopify_api/resources/article.rb
@@ -183,6 +199,7 @@ files:
183
199
  - lib/shopify_api/resources/fulfillment_request.rb
184
200
  - lib/shopify_api/resources/fulfillment_service.rb
185
201
  - lib/shopify_api/resources/gift_card.rb
202
+ - lib/shopify_api/resources/graphql.rb
186
203
  - lib/shopify_api/resources/image.rb
187
204
  - lib/shopify_api/resources/inventory_item.rb
188
205
  - lib/shopify_api/resources/inventory_level.rb
@@ -230,6 +247,7 @@ files:
230
247
  - shopify_api.gemspec
231
248
  - test/access_token_test.rb
232
249
  - test/active_resource/json_errors_test.rb
250
+ - test/api_permission_test.rb
233
251
  - test/application_charge_test.rb
234
252
  - test/application_credit_test.rb
235
253
  - test/article_test.rb
@@ -383,7 +401,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
383
401
  requirements:
384
402
  - - ">="
385
403
  - !ruby/object:Gem::Version
386
- version: '2.0'
404
+ version: '2.1'
387
405
  required_rubygems_version: !ruby/object:Gem::Requirement
388
406
  requirements:
389
407
  - - ">="