shopify_api 9.0.4 → 9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/ISSUE_TEMPLATE.md +36 -0
  4. data/.github/workflows/build.yml +44 -0
  5. data/.gitignore +2 -1
  6. data/.rubocop.yml +23 -3
  7. data/.rubocop_todo.yml +75 -0
  8. data/CHANGELOG.md +41 -0
  9. data/CONTRIBUTING.md +1 -1
  10. data/Gemfile +5 -0
  11. data/Gemfile.lock +153 -0
  12. data/Gemfile_ar51 +1 -1
  13. data/README.md +42 -32
  14. data/RELEASING +10 -6
  15. data/Rakefile +16 -5
  16. data/SECURITY.md +59 -0
  17. data/dev.yml +11 -0
  18. data/docs/_config.yml +1 -0
  19. data/docs/_includes/footer.html +28 -0
  20. data/docs/_includes/head.html +28 -0
  21. data/docs/_layouts/index.html +57 -0
  22. data/docs/graphql.md +47 -2
  23. data/docs/index.md +639 -0
  24. data/lib/active_resource/connection_ext.rb +1 -0
  25. data/lib/active_resource/detailed_log_subscriber.rb +10 -7
  26. data/lib/active_resource/json_errors.rb +8 -2
  27. data/lib/shopify_api/api_access.rb +57 -0
  28. data/lib/shopify_api/api_version.rb +6 -5
  29. data/lib/shopify_api/connection.rb +1 -0
  30. data/lib/shopify_api/countable.rb +3 -2
  31. data/lib/shopify_api/disable_prefix_check.rb +2 -2
  32. data/lib/shopify_api/events.rb +2 -1
  33. data/lib/shopify_api/graphql.rb +28 -8
  34. data/lib/shopify_api/hmac_params.rb +23 -0
  35. data/lib/shopify_api/limits.rb +3 -2
  36. data/lib/shopify_api/message_enricher.rb +11 -9
  37. data/lib/shopify_api/meta.rb +0 -1
  38. data/lib/shopify_api/metafields.rb +5 -4
  39. data/lib/shopify_api/pagination_link_headers.rb +5 -4
  40. data/lib/shopify_api/resources/access_scope.rb +1 -1
  41. data/lib/shopify_api/resources/access_token.rb +1 -0
  42. data/lib/shopify_api/resources/address.rb +1 -0
  43. data/lib/shopify_api/resources/announcement.rb +2 -1
  44. data/lib/shopify_api/resources/application_charge.rb +1 -0
  45. data/lib/shopify_api/resources/application_credit.rb +1 -0
  46. data/lib/shopify_api/resources/article.rb +3 -2
  47. data/lib/shopify_api/resources/asset.rb +6 -5
  48. data/lib/shopify_api/resources/assigned_fulfillment_order.rb +1 -1
  49. data/lib/shopify_api/resources/base.rb +12 -8
  50. data/lib/shopify_api/resources/billing_address.rb +1 -0
  51. data/lib/shopify_api/resources/blog.rb +2 -1
  52. data/lib/shopify_api/resources/carrier_service.rb +1 -0
  53. data/lib/shopify_api/resources/cart.rb +2 -1
  54. data/lib/shopify_api/resources/collect.rb +1 -0
  55. data/lib/shopify_api/resources/collection_listing.rb +1 -0
  56. data/lib/shopify_api/resources/comment.rb +20 -5
  57. data/lib/shopify_api/resources/country.rb +1 -0
  58. data/lib/shopify_api/resources/custom_collection.rb +4 -3
  59. data/lib/shopify_api/resources/customer.rb +2 -1
  60. data/lib/shopify_api/resources/customer_group.rb +1 -0
  61. data/lib/shopify_api/resources/customer_invite.rb +1 -0
  62. data/lib/shopify_api/resources/customer_saved_search.rb +2 -1
  63. data/lib/shopify_api/resources/discount_code.rb +1 -0
  64. data/lib/shopify_api/resources/discount_code_batch.rb +4 -2
  65. data/lib/shopify_api/resources/draft_order.rb +1 -0
  66. data/lib/shopify_api/resources/draft_order_invoice.rb +1 -0
  67. data/lib/shopify_api/resources/event.rb +1 -0
  68. data/lib/shopify_api/resources/fulfillment.rb +12 -3
  69. data/lib/shopify_api/resources/fulfillment_event.rb +1 -0
  70. data/lib/shopify_api/resources/fulfillment_order.rb +30 -16
  71. data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +1 -0
  72. data/lib/shopify_api/resources/fulfillment_request.rb +1 -0
  73. data/lib/shopify_api/resources/fulfillment_service.rb +1 -0
  74. data/lib/shopify_api/resources/fulfillment_v2.rb +3 -2
  75. data/lib/shopify_api/resources/gift_card.rb +1 -0
  76. data/lib/shopify_api/resources/image.rb +2 -1
  77. data/lib/shopify_api/resources/inventory_level.rb +3 -4
  78. data/lib/shopify_api/resources/line_item.rb +4 -3
  79. data/lib/shopify_api/resources/location.rb +1 -1
  80. data/lib/shopify_api/resources/marketing_event.rb +1 -0
  81. data/lib/shopify_api/resources/metafield.rb +1 -0
  82. data/lib/shopify_api/resources/note_attribute.rb +1 -0
  83. data/lib/shopify_api/resources/option.rb +1 -0
  84. data/lib/shopify_api/resources/order.rb +2 -1
  85. data/lib/shopify_api/resources/order_risk.rb +1 -0
  86. data/lib/shopify_api/resources/page.rb +1 -0
  87. data/lib/shopify_api/resources/payment_details.rb +1 -0
  88. data/lib/shopify_api/resources/policy.rb +1 -0
  89. data/lib/shopify_api/resources/price_rule.rb +1 -1
  90. data/lib/shopify_api/resources/product.rb +27 -3
  91. data/lib/shopify_api/resources/product_listing.rb +1 -0
  92. data/lib/shopify_api/resources/province.rb +1 -0
  93. data/lib/shopify_api/resources/receipt.rb +1 -0
  94. data/lib/shopify_api/resources/recurring_application_charge.rb +4 -1
  95. data/lib/shopify_api/resources/redirect.rb +1 -0
  96. data/lib/shopify_api/resources/refund.rb +2 -1
  97. data/lib/shopify_api/resources/report.rb +1 -0
  98. data/lib/shopify_api/resources/resource_feedback.rb +1 -1
  99. data/lib/shopify_api/resources/rule.rb +1 -0
  100. data/lib/shopify_api/resources/script_tag.rb +1 -0
  101. data/lib/shopify_api/resources/shipping_address.rb +1 -0
  102. data/lib/shopify_api/resources/shipping_line.rb +1 -0
  103. data/lib/shopify_api/resources/shipping_zone.rb +1 -0
  104. data/lib/shopify_api/resources/shop.rb +2 -1
  105. data/lib/shopify_api/resources/smart_collection.rb +4 -8
  106. data/lib/shopify_api/resources/storefront_access_token.rb +1 -0
  107. data/lib/shopify_api/resources/tax_line.rb +1 -0
  108. data/lib/shopify_api/resources/tax_service.rb +1 -0
  109. data/lib/shopify_api/resources/theme.rb +1 -0
  110. data/lib/shopify_api/resources/transaction.rb +1 -0
  111. data/lib/shopify_api/resources/usage_charge.rb +1 -0
  112. data/lib/shopify_api/resources/user.rb +1 -0
  113. data/lib/shopify_api/resources/variant.rb +35 -0
  114. data/lib/shopify_api/resources/webhook.rb +1 -0
  115. data/lib/shopify_api/resources.rb +1 -0
  116. data/lib/shopify_api/session.rb +51 -20
  117. data/lib/shopify_api/version.rb +2 -1
  118. data/lib/shopify_api.rb +9 -1
  119. data/lib/verify_docs.rb +8 -0
  120. data/service.yml +2 -5
  121. data/shopify_api.gemspec +13 -7
  122. data/test/access_token_test.rb +6 -5
  123. data/test/active_resource/json_errors_test.rb +6 -6
  124. data/test/api_access_test.rb +153 -0
  125. data/test/api_version_test.rb +3 -3
  126. data/test/application_charge_test.rb +30 -27
  127. data/test/application_credit_test.rb +10 -9
  128. data/test/article_test.rb +34 -35
  129. data/test/asset_test.rb +14 -6
  130. data/test/assigned_fulfillment_order_test.rb +5 -4
  131. data/test/base_test.rb +64 -49
  132. data/test/blog_test.rb +4 -3
  133. data/test/carrier_service_test.rb +7 -6
  134. data/test/cart_test.rb +2 -1
  135. data/test/collect_test.rb +4 -3
  136. data/test/collection_listing_test.rb +21 -16
  137. data/test/collection_publication_test.rb +8 -8
  138. data/test/collection_test.rb +20 -19
  139. data/test/countable_test.rb +3 -2
  140. data/test/currency_test.rb +5 -5
  141. data/test/custom_collection_test.rb +4 -3
  142. data/test/customer_saved_search_test.rb +18 -8
  143. data/test/customer_test.rb +22 -14
  144. data/test/detailed_log_subscriber_test.rb +16 -12
  145. data/test/discount_code_batch_test.rb +11 -10
  146. data/test/discount_code_test.rb +21 -15
  147. data/test/draft_order_test.rb +68 -52
  148. data/test/fixtures/assigned_fulfillment_orders.json +2 -0
  149. data/test/fixtures/fulfillment_order.json +1 -0
  150. data/test/fixtures/fulfillment_orders.json +2 -0
  151. data/test/fulfillment_event_test.rb +31 -26
  152. data/test/fulfillment_order_test.rb +217 -149
  153. data/test/fulfillment_order_test_helper.rb +1 -0
  154. data/test/fulfillment_request_test.rb +10 -8
  155. data/test/fulfillment_service_test.rb +13 -12
  156. data/test/fulfillment_test.rb +81 -66
  157. data/test/fulfillment_v2_test.rb +16 -12
  158. data/test/gift_card_test.rb +6 -4
  159. data/test/graphql_test.rb +55 -23
  160. data/test/hmac_params_test.rb +25 -0
  161. data/test/image_test.rb +19 -17
  162. data/test/inventory_level_test.rb +24 -15
  163. data/test/lib/webmock_extensions/last_request.rb +1 -1
  164. data/test/limits_test.rb +2 -1
  165. data/test/location_test.rb +2 -1
  166. data/test/marketing_event_test.rb +20 -20
  167. data/test/message_enricher_test.rb +6 -6
  168. data/test/meta_test.rb +9 -11
  169. data/test/metafield_test.rb +30 -20
  170. data/test/order_risk_test.rb +17 -16
  171. data/test/order_test.rb +43 -28
  172. data/test/pagination_test.rb +89 -56
  173. data/test/policy_test.rb +6 -5
  174. data/test/price_rule_test.rb +20 -15
  175. data/test/product_listing_test.rb +20 -20
  176. data/test/product_publication_test.rb +8 -8
  177. data/test/product_test.rb +71 -20
  178. data/test/publication_test.rb +3 -3
  179. data/test/recurring_application_charge_test.rb +104 -42
  180. data/test/redirect_test.rb +4 -3
  181. data/test/refund_test.rb +22 -17
  182. data/test/report_test.rb +12 -10
  183. data/test/resource_feedback_test.rb +14 -13
  184. data/test/script_tag_test.rb +10 -9
  185. data/test/session_test.rb +319 -45
  186. data/test/shipping_zone_test.rb +4 -3
  187. data/test/shop_test.rb +47 -33
  188. data/test/smart_collection_test.rb +5 -29
  189. data/test/storefront_access_token_test.rb +13 -15
  190. data/test/tax_service_test.rb +7 -4
  191. data/test/tender_transaction_test.rb +3 -3
  192. data/test/test_helper.rb +14 -12
  193. data/test/transaction_test.rb +4 -3
  194. data/test/usage_charge_test.rb +12 -8
  195. data/test/user_test.rb +4 -3
  196. data/test/variant_test.rb +50 -23
  197. data/test/webhook_test.rb +10 -7
  198. metadata +44 -17
  199. data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1027
  200. data/.travis.yml +0 -23
  201. data/bin/shopify +0 -3
data/SECURITY.md ADDED
@@ -0,0 +1,59 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ ### New features
6
+
7
+ New features will only be added to the master branch and will not be made available in point releases.
8
+
9
+ ### Bug fixes
10
+
11
+ Only the latest release series will receive bug fixes. When enough bugs are fixed and its deemed worthy to release a new gem, this is the branch it happens from.
12
+
13
+ ### Security issues
14
+
15
+ Only the latest release series will receive patches and new versions in case of a security issue.
16
+
17
+ ### Severe security issues
18
+
19
+ For severe security issues we will provide new versions as above, and also the last major release series will receive patches and new versions. The classification of the security issue is judged by the core team.
20
+
21
+ ### Unsupported Release Series
22
+
23
+ When a release series is no longer supported, it's your own responsibility to deal with bugs and security issues. If you are not comfortable maintaining your own versions, you should upgrade to a supported version.
24
+
25
+ ## Reporting a bug
26
+
27
+ All security bugs in shopify repositories should be reported to [our hackerone program](https://hackerone.com/shopify)
28
+ Shopify's whitehat program is our way to reward security researchers for finding serious security vulnerabilities in the In Scope properties listed at the bottom of this page, including our core application (all functionality associated with a Shopify store, particularly your-store.myshopify.com/admin) and certain ancillary applications.
29
+
30
+ ## Disclosure Policy
31
+
32
+ We look forward to working with all security researchers and strive to be respectful, always assume the best and treat others as peers. We expect the same in return from all participants. To achieve this, our team strives to:
33
+
34
+ - Reply to all reports within one business day and triage within two business days (if applicable)
35
+ - Be as transparent as possible, answering all inquires about our report decisions and adding hackers to duplicate HackerOne reports
36
+ - Award bounties within a week of resolution (excluding extenuating circumstances)
37
+ - Only close reports as N/A when the issue reported is included in Known Issues, Ineligible Vulnerabilities Types or lacks evidence of a vulnerability
38
+
39
+ **The following rules must be followed in order for any rewards to be paid:**
40
+
41
+ - You may only test against shops you have created which include your HackerOne YOURHANDLE @ wearehackerone.com registered email address.
42
+ - You must not attempt to gain access to, or interact with, any shops other than those created by you.
43
+ - The use of commercial scanners is prohibited (e.g., Nessus).
44
+ - Rules for reporting must be followed.
45
+ - Do not disclose any issues publicly before they have been resolved.
46
+ - Shopify reserves the right to modify the rules for this program or deem any submissions invalid at any time. Shopify may cancel the whitehat program without notice at any time.
47
+ - Contacting Shopify Support over chat, email or phone about your HackerOne report is not allowed. We may disqualify you from receiving a reward, or from participating in the program altogether.
48
+ - You are not an employee of Shopify; employees should report bugs to the internal bug bounty program.
49
+ - You hereby represent, warrant and covenant that any content you submit to Shopify is an original work of authorship and that you are legally entitled to grant the rights and privileges conveyed by these terms. You further represent, warrant and covenant that the consent of no other person or entity is or will be necessary for Shopify to use the submitted content.
50
+ - By submitting content to Shopify, you irrevocably waive all moral rights which you may have in the content.
51
+ - All content submitted by you to Shopify under this program is licensed under the MIT License.
52
+ - You must report any discovered vulnerability to Shopify as soon as you have validated the vulnerability.
53
+ - Failure to follow any of the foregoing rules will disqualify you from participating in this program.
54
+
55
+ ** Please see our [Hackerone Profile](https://hackerone.com/shopify) for full details
56
+
57
+ ## Receiving Security Updates
58
+
59
+ To recieve all general updates to vulnerabilities, please subscribe to our hackerone [Hacktivity](https://hackerone.com/shopify/hacktivity)
data/dev.yml ADDED
@@ -0,0 +1,11 @@
1
+ name: shopify-api
2
+
3
+ type: ruby
4
+
5
+ up:
6
+ - ruby: "3.0"
7
+ - bundler
8
+
9
+ commands:
10
+ test:
11
+ run: bundle exec rake test
data/docs/_config.yml ADDED
@@ -0,0 +1 @@
1
+ markdown: kramdown
@@ -0,0 +1,28 @@
1
+ <meta charset="utf-8">
2
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
3
+
4
+ <title>Shopify Open Source > {{ site.github.project_title }}</title>
5
+
6
+ {% if page.description %}
7
+ <meta name="description" content="{{ site.github.project_tagline }}">
8
+ {% endif %}
9
+
10
+ <link rel="canonical" href="http://shopify.github.io">
11
+
12
+ <meta name="robots" content="index, follow">
13
+ <meta name="st:robots" content="index, follow">
14
+
15
+ <meta name="viewport" content="width=device-width, initial-scale=1">
16
+
17
+ <meta property='st:title' content="Shopify Open Source > {{ site.github.project_title }}">
18
+
19
+ <link rel="shortcut icon" href="//cdn.shopify.com/assets/favicon.ico" type="image/x-icon">
20
+
21
+ <link href="//shopify.github.io/css/sub.css" rel="stylesheet" type="text/css">
22
+ <!--[if lt IE 9]>
23
+ <link href="http://shopify.github.io/css/subie.css" rel="stylesheet" type="text/css">
24
+ <![endif]-->
25
+
26
+ <!--[if IE]>
27
+ <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
28
+ <![endif]-->
@@ -0,0 +1,28 @@
1
+ <meta charset="utf-8">
2
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
3
+
4
+ <title>Shopify Open Source > {{ site.github.project_title }}</title>
5
+
6
+ {% if page.description %}
7
+ <meta name="description" content="{{ site.github.project_tagline }}">
8
+ {% endif %}
9
+
10
+ <link rel="canonical" href="http://shopify.github.io">
11
+
12
+ <meta name="robots" content="index, follow">
13
+ <meta name="st:robots" content="index, follow">
14
+
15
+ <meta name="viewport" content="width=device-width, initial-scale=1">
16
+
17
+ <meta property='st:title' content="Shopify Open Source > {{ site.github.project_title }}">
18
+
19
+ <link rel="shortcut icon" href="//cdn.shopify.com/assets/favicon.ico" type="image/x-icon">
20
+
21
+ <link href="//shopify.github.io/css/sub.css" rel="stylesheet" type="text/css">
22
+ <!--[if lt IE 9]>
23
+ <link href="http://shopify.github.io/css/subie.css" rel="stylesheet" type="text/css">
24
+ <![endif]-->
25
+
26
+ <!--[if IE]>
27
+ <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
28
+ <![endif]-->
@@ -0,0 +1,57 @@
1
+ <!doctype html>
2
+ <!--[if IE 8]><html class="no-js lt-ie9" lang="en"> <![endif]-->
3
+ <!--[if IE 9 ]><html class="ie9 no-js"> <![endif]-->
4
+ <!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js"> <!--<![endif]-->
5
+ <head>
6
+ {% include head.html %}
7
+ </head>
8
+ <body>
9
+ <div class="hero">
10
+ <div class="hero-lines"></div>
11
+ <header class="hero-header">
12
+ <div class="pagewidth">
13
+ <div class="logo--ie">
14
+ <img src="http://shopify.github.io/images/shopify-open-source-sub.svg" alt="Shopify Open Source" class="logo">
15
+ <span class="breadcrumb"><a href="http://shopify.github.io">Open Source</a> > {{ site.github.project_title }}</span>
16
+ </div>
17
+ <div class="repo-lang {{ site.github.language | downcase }}">
18
+ {{ site.github.language }}
19
+ </div>
20
+ </div>
21
+ </header>
22
+ <div class="pagewidth">
23
+ <div class="hero-inner">
24
+ <h1 class="hero-logo">{{ site.github.project_title }}</h1>
25
+ <h2 class="hero-text">{{ site.github.project_tagline }}</h2>
26
+ <div class="cta-buttons">
27
+ <a href="{{ site.github.zip_url }}" class="float">Download ZIP</a>
28
+ <a href="{{ site.github.repository_url }}" class="float github">
29
+ Github Repo
30
+ <i class="icon-star" title="Stars"></i> <span id="starCount"></span>
31
+ <i class="icon-forks" title="Forks"></i> <span id="forkCount"></span>
32
+ </a>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
38
+ <div class="documentation">
39
+ <div class="pagewidth">
40
+
41
+ {{ content }}
42
+
43
+ </div>
44
+ </div>
45
+ {% include footer.html %}
46
+
47
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
48
+ <script src="//shopify.github.io/javascripts/sub.js"></script>
49
+ <script>
50
+ jQuery(function($) {
51
+ shopifyOpenSource.init({
52
+ repo_name: '{{ site.github.repository_nwo }}'
53
+ });
54
+ });
55
+ </script>
56
+ </body>
57
+ </html>
data/docs/graphql.md CHANGED
@@ -32,7 +32,7 @@ result.data.shop.name
32
32
  ## Getting started
33
33
 
34
34
  1. [Dump the schema](#dump-the-schema)
35
- 2. [Configure session/authencation](#sessions-and-authentication)
35
+ 2. [Configure session/authentication](#sessions-and-authentication)
36
36
  3. [Make queries](#make-queries)
37
37
 
38
38
  ### Dump the schema
@@ -147,6 +147,51 @@ during your boot process.
147
147
  The goal is to have all clients created at boot so there's no schema loading,
148
148
  parsing, or client instantiation done during runtime when your app serves a request.
149
149
 
150
+
151
+ ## Using a custom GraphQL Client
152
+ By default `ShopifyAPI::GraphQL` wraps the Github GraphQL Client library. However, this client
153
+ may not suitable for various reasons. If you wish to expand on the interface of the client or
154
+ improve the required functions for your use case you can implement a client of your own.
155
+
156
+ To use a custom GraphQL Client:
157
+ ```
158
+ class CustomGraphQLClient < ::GraphQL::Client
159
+ end
160
+
161
+ ShopifyAPI::GraphQL.graphql_client = CustomGraphQLClient
162
+ ```
163
+
164
+
165
+ ## Using a custom query execution adapter
166
+ Github's GraphQL Client uses an adapter pattern so that you can define how you interact
167
+ with GraphQL API's. Shopify provides a minimal implementation in `ShopifyAPI::GraphQL::HTTPClient`.
168
+ If you need to add additional functionality pre, during or post query execution you can
169
+ consider implementing these within a custom query execution adapter, inheriting from
170
+ `ShopifyAPI::GraphQL::HTTPClient` which provides the necessary implementation for
171
+ headers, url, and api versions
172
+
173
+
174
+ To set a custom query executiona dapter set `ShopifyAPI::GraphQL.execution_adapter` to your client:
175
+ ```ruby
176
+ class RaisingHTTPClient < ShopifyAPI::GraphQL::HTTPClient
177
+ def execute(document:, operation_name: nil, variables: {}, context: {})
178
+ result = super
179
+ do_work(result)
180
+ end
181
+
182
+ private
183
+
184
+ def do_work(result)
185
+ result
186
+ end
187
+ end
188
+
189
+ ShopifyAPI::GraphQL.execution_adapter = RaisingHTTPClient
190
+ ```
191
+
192
+ Note, the execution adapter has `client` in the name. This is to remain consistent with
193
+ the naming conventions within the Github GraphQL Client library.
194
+
150
195
  ## Migration guide
151
196
  Prior to shopify_api v9.0 the GraphQL client implementation was limited and almost
152
197
  unusable due to the client making dynamic introspection queries to Shopify's API.
@@ -193,4 +238,4 @@ result = client.query(SHOP_NAME_QUERY)
193
238
  result.data.shop.name
194
239
  ```
195
240
 
196
- See [making queries](#making-queries) for more usage details.
241
+ See [make queries](#make-queries) for more usage details.