shopify_api 5.2.0 → 5.2.1

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
- SHA1:
3
- metadata.gz: 8c6dee9517f8b39f0509a1fc782c3fbd31f0acab
4
- data.tar.gz: 9c7c14bccda5997dff52cfc9cfe102856896f134
2
+ SHA256:
3
+ metadata.gz: e9c77838f7f17c68d5a215c1f7be62d2cbd7d14307435694070f8252efe222af
4
+ data.tar.gz: 0dc09a8b02adb8471380384683150949fe081eb8304bb1e7a0fd82ee1af28e48
5
5
  SHA512:
6
- metadata.gz: d4d18fbc6064f642bee7575ebbd4fd00919b852c201cebb0ee668e809163a13a289f22c5d886903479d71c0ee87dc3fa507abe14c210d9f9beecd6b418256cd2
7
- data.tar.gz: a508c15999e3ca6b83a124fe5198200221bf76625cbc77755d23229b55950792ff6e45dcf547a6f933df0f627a84172aca5665f220fc0c98a2c1d13f1e67b6aa
6
+ metadata.gz: d75774779c87aec609443674312a27d4c9b8530745ff7127bcb149ba6a01b84ebdfe0a986a04b07b7aa5be4c6e9ba8e88cafdd3f4ec41c530c87c12cd6ffe940
7
+ data.tar.gz: c22a07f6fb4af17fa6c9d76fc8e6e806e339e948a6d64481c5d29525d109cb0cff44dadf2b0b99ee18a16c94bf45941c47aeb821ab71c1f99ea1c43a67fcb75e
@@ -0,0 +1 @@
1
+ * @shopify/app-partner-dev-tools-education
@@ -0,0 +1,2 @@
1
+ enabled:
2
+ - cla
data/.gitignore CHANGED
@@ -9,3 +9,5 @@ pkg
9
9
  *.gem
10
10
  .idea
11
11
  .dev/
12
+ .bundle/
13
+ vendor/
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == Version 5.2.1
2
+
3
+ * Log warning when Shopify indicates deprecated API call was performed
4
+
1
5
  == Version 5.2.0
2
6
 
3
7
  * Added `ShopifyAPI::Currency` to fetch list of supported currencies on a shop
@@ -1,6 +1,17 @@
1
1
  module ActiveResource
2
2
  class DetailedLogSubscriber < ActiveSupport::LogSubscriber
3
3
  def request(event)
4
+ log_request_response_details(event)
5
+ warn_on_deprecated_header(event)
6
+ end
7
+
8
+ def logger
9
+ ActiveResource::Base.logger
10
+ end
11
+
12
+ private
13
+
14
+ def log_request_response_details(event)
4
15
  data = event.payload[:data]
5
16
  headers = data.extract_options!
6
17
  request_body = data.first
@@ -10,8 +21,20 @@ module ActiveResource
10
21
  info "Response:\n#{event.payload[:response].body}"
11
22
  end
12
23
 
13
- def logger
14
- ActiveResource::Base.logger
24
+ def warn_on_deprecated_header(event)
25
+ payload = event.payload
26
+
27
+ payload[:response].each do |header_name, header_value|
28
+ case header_name.downcase
29
+ when 'x-shopify-api-deprecated-reason'
30
+ warning_message = <<~MSG
31
+ [DEPRECATED] ShopifyAPI made a call to #{payload[:method].upcase} #{payload[:path]}, and this call made
32
+ use of a deprecated endpoint, behaviour, or parameter. See #{header_value} for more details.
33
+ MSG
34
+
35
+ warn warning_message
36
+ end
37
+ end
15
38
  end
16
39
  end
17
40
  end
@@ -13,15 +13,17 @@ module ShopifyAPI
13
13
  module RequestNotification
14
14
  def request(method, path, *arguments)
15
15
  super.tap do |response|
16
- notify_about_request(response, arguments)
16
+ notify_about_request(method, path, response, arguments)
17
17
  end
18
18
  rescue => e
19
- notify_about_request(e.response, arguments) if e.respond_to?(:response)
19
+ notify_about_request(method, path, e.response, arguments) if e.respond_to?(:response)
20
20
  raise
21
21
  end
22
22
 
23
- def notify_about_request(response, arguments)
23
+ def notify_about_request(method, path, response, arguments)
24
24
  ActiveSupport::Notifications.instrument("request.active_resource_detailed") do |payload|
25
+ payload[:method] = method
26
+ payload[:path] = path
25
27
  payload[:response] = response
26
28
  payload[:data] = arguments
27
29
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyAPI
2
- VERSION = "5.2.0"
2
+ VERSION = "5.2.1"
3
3
  end
data/service.yml ADDED
@@ -0,0 +1,8 @@
1
+ audience: partner
2
+ classification: library
3
+ org_line: App & Partner Platform
4
+ owners:
5
+ - Shopify/app-partner-dev-tools-education
6
+ slack_channels:
7
+ - dev-tools-education
8
+ - api-patterns-team
data/shopify_api.gemspec CHANGED
@@ -34,4 +34,6 @@ Gem::Specification.new do |s|
34
34
  s.add_development_dependency("minitest", ">= 4.0")
35
35
  s.add_development_dependency("rake")
36
36
  s.add_development_dependency("timecop")
37
+ s.add_development_dependency("pry")
38
+ s.add_development_dependency("pry-byebug")
37
39
  end
@@ -30,7 +30,6 @@ class LogSubscriberTest < Test::Unit::TestCase
30
30
  assert_match /\-\-\> 200/, @logger.logged(:info)[1]
31
31
  assert_equal "Headers: {\"Accept\"=>\"application/json\", #{@ua_header}}", @logger.logged(:info)[2]
32
32
  assert_match /Response:\n\{\"page\"\:\{((\"id\"\:1)|(\"title\"\:\"Shopify API\")),((\"id\"\:1)|(\"title\"\:\"Shopify API\"))\}\}/, @logger.logged(:info)[3]
33
-
34
33
  end
35
34
 
36
35
  test "logging on #find with an error" do
@@ -46,4 +45,23 @@ class LogSubscriberTest < Test::Unit::TestCase
46
45
  assert_equal "Headers: {\"Accept\"=>\"application/json\", #{@ua_header}}", @logger.logged(:info)[2]
47
46
  assert_equal "Response:", @logger.logged(:info)[3]
48
47
  end
48
+
49
+ test "warns when the server responds with a x-shopify-api-deprecated-reason header" do
50
+ fake(
51
+ "pages/1",
52
+ method: :get,
53
+ body: @page,
54
+ x_shopify_api_deprecated_reason: 'https://help.shopify.com/en/api/getting-started/api-deprecations'
55
+ )
56
+
57
+ ShopifyAPI::Page.find(1)
58
+
59
+ assert_equal 1, @logger.logged(:warn).size
60
+
61
+ assert_match %r{\[DEPRECATED\] ShopifyAPI made a call to GET \/admin\/pages\/1.json}, @logger.logged(:warn).first
62
+ assert_match(
63
+ %r{See https:\/\/help.shopify.com\/en\/api\/getting-started\/api-deprecations for more details.},
64
+ @logger.logged(:warn).first
65
+ )
66
+ end
49
67
  end
data/test/test_helper.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'minitest/autorun'
3
3
  require 'fakeweb'
4
4
  require 'mocha/setup'
5
+ require 'pry'
5
6
 
6
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
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: 5.2.0
4
+ version: 5.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2018-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description: The Shopify API gem allows Ruby developers to programmatically access
126
154
  the admin section of Shopify stores. The API is implemented as JSON or XML over
127
155
  HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product,
@@ -135,6 +163,8 @@ extra_rdoc_files:
135
163
  - README.md
136
164
  files:
137
165
  - ".document"
166
+ - ".github/CODEOWNERS"
167
+ - ".github/probots.yml"
138
168
  - ".gitignore"
139
169
  - ".rubocop.yml"
140
170
  - ".travis.yml"
@@ -254,6 +284,7 @@ files:
254
284
  - lib/shopify_api/resources/webhook.rb
255
285
  - lib/shopify_api/session.rb
256
286
  - lib/shopify_api/version.rb
287
+ - service.yml
257
288
  - shipit.rubygems.yml
258
289
  - shopify_api.gemspec
259
290
  - test/abandoned_checkouts_test.rb
@@ -445,7 +476,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
445
476
  version: '0'
446
477
  requirements: []
447
478
  rubyforge_project:
448
- rubygems_version: 2.6.14
479
+ rubygems_version: 2.7.6
449
480
  signing_key:
450
481
  specification_version: 4
451
482
  summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web