ruby_shopify_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (351) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.github/CODEOWNERS +1 -0
  4. data/.github/ISSUE_TEMPLATE.md +36 -0
  5. data/.github/probots.yml +2 -0
  6. data/.github/workflows/build.yml +43 -0
  7. data/.gitignore +15 -0
  8. data/.rubocop.yml +28 -0
  9. data/.rubocop_todo.yml +75 -0
  10. data/CHANGELOG-OLD.md +501 -0
  11. data/CHANGELOG.md +5 -0
  12. data/CONTRIBUTING.md +8 -0
  13. data/CONTRIBUTORS +3 -0
  14. data/Gemfile +10 -0
  15. data/Gemfile.lock +151 -0
  16. data/Gemfile_ar41 +5 -0
  17. data/Gemfile_ar50 +5 -0
  18. data/Gemfile_ar51 +5 -0
  19. data/Gemfile_ar60 +5 -0
  20. data/Gemfile_ar_main +5 -0
  21. data/LICENSE +20 -0
  22. data/README.md +649 -0
  23. data/RELEASING +17 -0
  24. data/Rakefile +55 -0
  25. data/SECURITY.md +59 -0
  26. data/dev.yml +11 -0
  27. data/docker-compose.yml +13 -0
  28. data/docs/_config.yml +1 -0
  29. data/docs/_includes/footer.html +28 -0
  30. data/docs/_includes/head.html +28 -0
  31. data/docs/_layouts/index.html +57 -0
  32. data/docs/graphql.md +241 -0
  33. data/docs/index.md +639 -0
  34. data/lib/active_resource/connection_ext.rb +11 -0
  35. data/lib/active_resource/detailed_log_subscriber.rb +55 -0
  36. data/lib/active_resource/json_errors.rb +37 -0
  37. data/lib/shopify_api/api_access.rb +57 -0
  38. data/lib/shopify_api/api_version.rb +206 -0
  39. data/lib/shopify_api/connection.rb +36 -0
  40. data/lib/shopify_api/countable.rb +15 -0
  41. data/lib/shopify_api/disable_prefix_check.rb +31 -0
  42. data/lib/shopify_api/events.rb +8 -0
  43. data/lib/shopify_api/graphql/http_client.rb +22 -0
  44. data/lib/shopify_api/graphql/railtie.rb +17 -0
  45. data/lib/shopify_api/graphql/task.rake +100 -0
  46. data/lib/shopify_api/graphql.rb +103 -0
  47. data/lib/shopify_api/hmac_params.rb +33 -0
  48. data/lib/shopify_api/limits.rb +77 -0
  49. data/lib/shopify_api/message_enricher.rb +25 -0
  50. data/lib/shopify_api/meta.rb +14 -0
  51. data/lib/shopify_api/metafields.rb +21 -0
  52. data/lib/shopify_api/paginated_collection.rb +69 -0
  53. data/lib/shopify_api/pagination_link_headers.rb +34 -0
  54. data/lib/shopify_api/resources/abandoned_checkout.rb +7 -0
  55. data/lib/shopify_api/resources/access_scope.rb +10 -0
  56. data/lib/shopify_api/resources/access_token.rb +9 -0
  57. data/lib/shopify_api/resources/address.rb +5 -0
  58. data/lib/shopify_api/resources/announcement.rb +5 -0
  59. data/lib/shopify_api/resources/api_permission.rb +9 -0
  60. data/lib/shopify_api/resources/application_charge.rb +16 -0
  61. data/lib/shopify_api/resources/application_credit.rb +5 -0
  62. data/lib/shopify_api/resources/array_base.rb +13 -0
  63. data/lib/shopify_api/resources/article.rb +22 -0
  64. data/lib/shopify_api/resources/asset.rb +101 -0
  65. data/lib/shopify_api/resources/assigned_fulfillment_order.rb +16 -0
  66. data/lib/shopify_api/resources/base.rb +166 -0
  67. data/lib/shopify_api/resources/billing_address.rb +5 -0
  68. data/lib/shopify_api/resources/blog.rb +11 -0
  69. data/lib/shopify_api/resources/carrier_service.rb +5 -0
  70. data/lib/shopify_api/resources/cart.rb +5 -0
  71. data/lib/shopify_api/resources/checkout.rb +30 -0
  72. data/lib/shopify_api/resources/collect.rb +7 -0
  73. data/lib/shopify_api/resources/collection.rb +14 -0
  74. data/lib/shopify_api/resources/collection_listing.rb +19 -0
  75. data/lib/shopify_api/resources/collection_publication.rb +10 -0
  76. data/lib/shopify_api/resources/comment.rb +24 -0
  77. data/lib/shopify_api/resources/country.rb +5 -0
  78. data/lib/shopify_api/resources/currency.rb +6 -0
  79. data/lib/shopify_api/resources/custom_collection.rb +20 -0
  80. data/lib/shopify_api/resources/customer.rb +30 -0
  81. data/lib/shopify_api/resources/customer_group.rb +6 -0
  82. data/lib/shopify_api/resources/customer_invite.rb +5 -0
  83. data/lib/shopify_api/resources/customer_saved_search.rb +12 -0
  84. data/lib/shopify_api/resources/discount_code.rb +10 -0
  85. data/lib/shopify_api/resources/discount_code_batch.rb +34 -0
  86. data/lib/shopify_api/resources/draft_order.rb +15 -0
  87. data/lib/shopify_api/resources/draft_order_invoice.rb +5 -0
  88. data/lib/shopify_api/resources/event.rb +9 -0
  89. data/lib/shopify_api/resources/fulfillment.rb +56 -0
  90. data/lib/shopify_api/resources/fulfillment_event.rb +16 -0
  91. data/lib/shopify_api/resources/fulfillment_order.rb +151 -0
  92. data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +5 -0
  93. data/lib/shopify_api/resources/fulfillment_request.rb +16 -0
  94. data/lib/shopify_api/resources/fulfillment_service.rb +5 -0
  95. data/lib/shopify_api/resources/fulfillment_v2.rb +21 -0
  96. data/lib/shopify_api/resources/gift_card.rb +8 -0
  97. data/lib/shopify_api/resources/image.rb +17 -0
  98. data/lib/shopify_api/resources/inventory_item.rb +6 -0
  99. data/lib/shopify_api/resources/inventory_level.rb +54 -0
  100. data/lib/shopify_api/resources/line_item.rb +15 -0
  101. data/lib/shopify_api/resources/location.rb +8 -0
  102. data/lib/shopify_api/resources/marketing_event.rb +11 -0
  103. data/lib/shopify_api/resources/metafield.rb +14 -0
  104. data/lib/shopify_api/resources/note_attribute.rb +5 -0
  105. data/lib/shopify_api/resources/option.rb +5 -0
  106. data/lib/shopify_api/resources/order.rb +44 -0
  107. data/lib/shopify_api/resources/order_risk.rb +9 -0
  108. data/lib/shopify_api/resources/page.rb +7 -0
  109. data/lib/shopify_api/resources/payment.rb +7 -0
  110. data/lib/shopify_api/resources/payment_details.rb +5 -0
  111. data/lib/shopify_api/resources/ping.rb +3 -0
  112. data/lib/shopify_api/resources/policy.rb +8 -0
  113. data/lib/shopify_api/resources/price_rule.rb +8 -0
  114. data/lib/shopify_api/resources/product.rb +59 -0
  115. data/lib/shopify_api/resources/product_listing.rb +17 -0
  116. data/lib/shopify_api/resources/product_publication.rb +10 -0
  117. data/lib/shopify_api/resources/province.rb +6 -0
  118. data/lib/shopify_api/resources/publication.rb +5 -0
  119. data/lib/shopify_api/resources/receipt.rb +5 -0
  120. data/lib/shopify_api/resources/recurring_application_charge.rb +34 -0
  121. data/lib/shopify_api/resources/redirect.rb +5 -0
  122. data/lib/shopify_api/resources/refund.rb +15 -0
  123. data/lib/shopify_api/resources/report.rb +5 -0
  124. data/lib/shopify_api/resources/resource_feedback.rb +19 -0
  125. data/lib/shopify_api/resources/rule.rb +5 -0
  126. data/lib/shopify_api/resources/script_tag.rb +5 -0
  127. data/lib/shopify_api/resources/shipping_address.rb +5 -0
  128. data/lib/shopify_api/resources/shipping_line.rb +5 -0
  129. data/lib/shopify_api/resources/shipping_rate.rb +7 -0
  130. data/lib/shopify_api/resources/shipping_zone.rb +5 -0
  131. data/lib/shopify_api/resources/shop.rb +26 -0
  132. data/lib/shopify_api/resources/smart_collection.rb +15 -0
  133. data/lib/shopify_api/resources/storefront_access_token.rb +5 -0
  134. data/lib/shopify_api/resources/tax_line.rb +5 -0
  135. data/lib/shopify_api/resources/tax_service.rb +5 -0
  136. data/lib/shopify_api/resources/tender_transaction.rb +6 -0
  137. data/lib/shopify_api/resources/theme.rb +5 -0
  138. data/lib/shopify_api/resources/transaction.rb +6 -0
  139. data/lib/shopify_api/resources/usage_charge.rb +6 -0
  140. data/lib/shopify_api/resources/user.rb +5 -0
  141. data/lib/shopify_api/resources/variant.rb +43 -0
  142. data/lib/shopify_api/resources/webhook.rb +5 -0
  143. data/lib/shopify_api/resources.rb +4 -0
  144. data/lib/shopify_api/session.rb +203 -0
  145. data/lib/shopify_api/version.rb +4 -0
  146. data/lib/shopify_api.rb +45 -0
  147. data/lib/verify_docs.rb +8 -0
  148. data/service.yml +2 -0
  149. data/shipit.rubygems.yml +1 -0
  150. data/shopify_api.gemspec +47 -0
  151. data/test/abandoned_checkouts_test.rb +29 -0
  152. data/test/access_scope_test.rb +23 -0
  153. data/test/access_token_test.rb +20 -0
  154. data/test/active_resource/json_errors_test.rb +19 -0
  155. data/test/api_access_test.rb +153 -0
  156. data/test/api_permission_test.rb +9 -0
  157. data/test/api_version_test.rb +157 -0
  158. data/test/application_charge_test.rb +82 -0
  159. data/test/application_credit_test.rb +36 -0
  160. data/test/article_test.rb +72 -0
  161. data/test/asset_test.rb +26 -0
  162. data/test/assigned_fulfillment_order_test.rb +78 -0
  163. data/test/base_test.rb +213 -0
  164. data/test/blog_test.rb +9 -0
  165. data/test/carrier_service_test.rb +18 -0
  166. data/test/cart_test.rb +14 -0
  167. data/test/checkouts_test.rb +77 -0
  168. data/test/collect_test.rb +10 -0
  169. data/test/collection_listing_test.rb +84 -0
  170. data/test/collection_publication_test.rb +40 -0
  171. data/test/collection_test.rb +50 -0
  172. data/test/countable_test.rb +14 -0
  173. data/test/currency_test.rb +21 -0
  174. data/test/custom_collection_test.rb +10 -0
  175. data/test/customer_saved_search_test.rb +37 -0
  176. data/test/customer_test.rb +58 -0
  177. data/test/detailed_log_subscriber_test.rb +143 -0
  178. data/test/discount_code_batch_test.rb +41 -0
  179. data/test/discount_code_test.rb +59 -0
  180. data/test/draft_order_test.rb +167 -0
  181. data/test/fixtures/abandoned_checkout.json +184 -0
  182. data/test/fixtures/abandoned_checkouts.json +186 -0
  183. data/test/fixtures/access_scopes.json +10 -0
  184. data/test/fixtures/access_token_delegate.json +4 -0
  185. data/test/fixtures/api_versions.json +38 -0
  186. data/test/fixtures/apis.json +42 -0
  187. data/test/fixtures/application_charge.json +16 -0
  188. data/test/fixtures/application_charges.json +57 -0
  189. data/test/fixtures/application_credit.json +12 -0
  190. data/test/fixtures/application_credits.json +24 -0
  191. data/test/fixtures/article.json +15 -0
  192. data/test/fixtures/articles.json +39 -0
  193. data/test/fixtures/asset.json +9 -0
  194. data/test/fixtures/assets.json +136 -0
  195. data/test/fixtures/assigned_fulfillment_orders.json +80 -0
  196. data/test/fixtures/authors.json +1 -0
  197. data/test/fixtures/blog.json +13 -0
  198. data/test/fixtures/blogs.json +13 -0
  199. data/test/fixtures/carrier_service.json +9 -0
  200. data/test/fixtures/carts.json +43 -0
  201. data/test/fixtures/checkout.json +160 -0
  202. data/test/fixtures/checkouts.json +162 -0
  203. data/test/fixtures/collect.json +12 -0
  204. data/test/fixtures/collection.json +17 -0
  205. data/test/fixtures/collection_listing.json +11 -0
  206. data/test/fixtures/collection_listing_product_ids.json +1 -0
  207. data/test/fixtures/collection_listing_product_ids2.json +1 -0
  208. data/test/fixtures/collection_listings.json +13 -0
  209. data/test/fixtures/collection_products.json +47 -0
  210. data/test/fixtures/collection_publication.json +11 -0
  211. data/test/fixtures/collection_publications.json +13 -0
  212. data/test/fixtures/currencies.json +25 -0
  213. data/test/fixtures/custom_collection.json +17 -0
  214. data/test/fixtures/customer_invite.json +9 -0
  215. data/test/fixtures/customer_saved_search.json +9 -0
  216. data/test/fixtures/customer_saved_search_customers.json +60 -0
  217. data/test/fixtures/customers.json +59 -0
  218. data/test/fixtures/customers_account_activation_url.json +3 -0
  219. data/test/fixtures/customers_search.json +60 -0
  220. data/test/fixtures/discount_code.json +10 -0
  221. data/test/fixtures/discount_code_batch.json +14 -0
  222. data/test/fixtures/discount_code_batch_discount_codes.json +21 -0
  223. data/test/fixtures/discount_codes.json +12 -0
  224. data/test/fixtures/draft_order.json +159 -0
  225. data/test/fixtures/draft_order_completed.json +159 -0
  226. data/test/fixtures/draft_order_invoice.json +9 -0
  227. data/test/fixtures/draft_orders.json +161 -0
  228. data/test/fixtures/engagement.json +15 -0
  229. data/test/fixtures/events.json +31 -0
  230. data/test/fixtures/fulfillment.json +49 -0
  231. data/test/fixtures/fulfillment_event.json +12 -0
  232. data/test/fixtures/fulfillment_order.json +39 -0
  233. data/test/fixtures/fulfillment_order_locations_for_move.json +18 -0
  234. data/test/fixtures/fulfillment_orders.json +80 -0
  235. data/test/fixtures/fulfillment_request.json +28 -0
  236. data/test/fixtures/fulfillment_service.json +10 -0
  237. data/test/fixtures/fulfillments.json +53 -0
  238. data/test/fixtures/gift_card.json +20 -0
  239. data/test/fixtures/gift_card_disabled.json +20 -0
  240. data/test/fixtures/graphql/2019-10.json +1083 -0
  241. data/test/fixtures/graphql/dummy_schema.rb +16 -0
  242. data/test/fixtures/graphql/unstable.json +1083 -0
  243. data/test/fixtures/image.json +10 -0
  244. data/test/fixtures/images.json +20 -0
  245. data/test/fixtures/inventory_level.json +7 -0
  246. data/test/fixtures/inventory_levels.json +24 -0
  247. data/test/fixtures/marketing_event.json +28 -0
  248. data/test/fixtures/marketing_events.json +54 -0
  249. data/test/fixtures/metafield.json +12 -0
  250. data/test/fixtures/metafields.json +34 -0
  251. data/test/fixtures/order.json +297 -0
  252. data/test/fixtures/order_risk.json +14 -0
  253. data/test/fixtures/order_risks.json +28 -0
  254. data/test/fixtures/order_with_properties.json +373 -0
  255. data/test/fixtures/orders.json +299 -0
  256. data/test/fixtures/payment.json +7 -0
  257. data/test/fixtures/payments.json +9 -0
  258. data/test/fixtures/ping/conversation.json +1 -0
  259. data/test/fixtures/ping/failed_delivery_confirmation.json +1 -0
  260. data/test/fixtures/ping/message.json +1 -0
  261. data/test/fixtures/ping/successful_delivery_confirmation.json +1 -0
  262. data/test/fixtures/policies.json +8 -0
  263. data/test/fixtures/price_rule.json +27 -0
  264. data/test/fixtures/price_rules.json +28 -0
  265. data/test/fixtures/product.json +116 -0
  266. data/test/fixtures/product_listing.json +86 -0
  267. data/test/fixtures/product_listing_product_ids.json +1 -0
  268. data/test/fixtures/product_listing_product_ids2.json +1 -0
  269. data/test/fixtures/product_listings.json +174 -0
  270. data/test/fixtures/product_publication.json +11 -0
  271. data/test/fixtures/product_publications.json +13 -0
  272. data/test/fixtures/publications.json +9 -0
  273. data/test/fixtures/recurring_application_charge.json +22 -0
  274. data/test/fixtures/recurring_application_charge_adjustment.json +5 -0
  275. data/test/fixtures/recurring_application_charges.json +106 -0
  276. data/test/fixtures/redirect.json +7 -0
  277. data/test/fixtures/refund.json +112 -0
  278. data/test/fixtures/report.json +9 -0
  279. data/test/fixtures/reports.json +11 -0
  280. data/test/fixtures/script_tag.json +10 -0
  281. data/test/fixtures/script_tags.json +18 -0
  282. data/test/fixtures/shipping_rates.json +12 -0
  283. data/test/fixtures/shipping_zones.json +315 -0
  284. data/test/fixtures/shop.json +26 -0
  285. data/test/fixtures/smart_collection.json +21 -0
  286. data/test/fixtures/smart_collection_products.json +155 -0
  287. data/test/fixtures/storefront_access_token.json +9 -0
  288. data/test/fixtures/storefront_access_tokens.json +18 -0
  289. data/test/fixtures/tags.json +1 -0
  290. data/test/fixtures/tax_service.json +9 -0
  291. data/test/fixtures/tender_transactions.json +52 -0
  292. data/test/fixtures/transaction.json +29 -0
  293. data/test/fixtures/usage_charge.json +11 -0
  294. data/test/fixtures/usage_charges.json +23 -0
  295. data/test/fixtures/user.json +21 -0
  296. data/test/fixtures/users.json +42 -0
  297. data/test/fixtures/variant.json +23 -0
  298. data/test/fixtures/variants.json +88 -0
  299. data/test/fixtures/webhook.json +10 -0
  300. data/test/fixtures/webhooks.json +18 -0
  301. data/test/fulfillment_event_test.rb +74 -0
  302. data/test/fulfillment_order_test.rb +530 -0
  303. data/test/fulfillment_order_test_helper.rb +8 -0
  304. data/test/fulfillment_request_test.rb +35 -0
  305. data/test/fulfillment_service_test.rb +18 -0
  306. data/test/fulfillment_test.rb +239 -0
  307. data/test/fulfillment_v2_test.rb +66 -0
  308. data/test/gift_card_test.rb +24 -0
  309. data/test/graphql/http_client_test.rb +26 -0
  310. data/test/graphql_test.rb +190 -0
  311. data/test/hmac_params_test.rb +25 -0
  312. data/test/image_test.rb +41 -0
  313. data/test/inventory_level_test.rb +68 -0
  314. data/test/lib/webmock_extensions/last_request.rb +16 -0
  315. data/test/limits_test.rb +39 -0
  316. data/test/location_test.rb +15 -0
  317. data/test/marketing_event_test.rb +68 -0
  318. data/test/message_enricher_test.rb +45 -0
  319. data/test/meta_test.rb +47 -0
  320. data/test/metafield_test.rb +56 -0
  321. data/test/order_risk_test.rb +47 -0
  322. data/test/order_test.rb +140 -0
  323. data/test/pagination_test.rb +290 -0
  324. data/test/payment_test.rb +19 -0
  325. data/test/policy_test.rb +20 -0
  326. data/test/price_rule_test.rb +70 -0
  327. data/test/product_listing_test.rb +97 -0
  328. data/test/product_publication_test.rb +40 -0
  329. data/test/product_test.rb +111 -0
  330. data/test/publication_test.rb +12 -0
  331. data/test/recurring_application_charge_test.rb +204 -0
  332. data/test/redirect_test.rb +10 -0
  333. data/test/refund_test.rb +37 -0
  334. data/test/report_test.rb +37 -0
  335. data/test/resource_feedback_test.rb +43 -0
  336. data/test/script_tag_test.rb +31 -0
  337. data/test/session_test.rb +640 -0
  338. data/test/shipping_rate_test.rb +17 -0
  339. data/test/shipping_zone_test.rb +11 -0
  340. data/test/shop_test.rb +82 -0
  341. data/test/smart_collection_test.rb +11 -0
  342. data/test/storefront_access_token_test.rb +30 -0
  343. data/test/tax_service_test.rb +12 -0
  344. data/test/tender_transaction_test.rb +18 -0
  345. data/test/test_helper.rb +126 -0
  346. data/test/transaction_test.rb +18 -0
  347. data/test/usage_charge_test.rb +25 -0
  348. data/test/user_test.rb +18 -0
  349. data/test/variant_test.rb +73 -0
  350. data/test/webhook_test.rb +24 -0
  351. metadata +555 -0
data/RELEASING ADDED
@@ -0,0 +1,17 @@
1
+ Releasing ShopifyAPI
2
+
3
+ 1. Check the Semantic Versioning page for info on how to version the new release: http://semver.org
4
+ 2. Update the version of ShopifyAPI in lib/shopify_api/version.rb
5
+ 3. Run `bundle`
6
+ 4. Add a CHANGELOG entry for the new release
7
+ 5. Commit the changes with a commit message like "Packaging for release X.Y.Z"
8
+ 6. Tag the release with the version (Leave REV blank for HEAD or provide a SHA)
9
+ $ git tag vX.Y.Z REV
10
+ 7. Push out the changes
11
+ $ git push
12
+ 8. Push out the tags
13
+ $ git push --tags
14
+ 9. Publish the gem using Shipit
15
+ 10. Consider if the dependency in Shopify/shopify needs updated. It's used only by the tests so is a low risk change.
16
+ Also consider Shopify/shopify_app whose gemspec depends on this.
17
+ We don't need to do this for every release, but we should try to keep them relatively up to date.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+ require 'rake'
3
+ require "bundler/gem_tasks"
4
+ require 'rake/testtask'
5
+ require 'rubocop/rake_task'
6
+
7
+ Rake::TestTask.new(:test) do |test|
8
+ test.libs << 'lib' << 'test'
9
+ test.pattern = 'test/**/*_test.rb'
10
+ test.warning = false
11
+ end
12
+
13
+ RuboCop::RakeTask.new
14
+
15
+ begin
16
+ require 'rcov/rcovtask'
17
+ Rcov::RcovTask.new do |test|
18
+ test.libs << 'test'
19
+ test.pattern = 'test/**/*_test.rb'
20
+ test.verbose = true
21
+ end
22
+ rescue LoadError
23
+ task(:rcov) do
24
+ abort("RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov")
25
+ end
26
+ end
27
+
28
+ task(default: [:test, :rubocop, :verify_docs])
29
+
30
+ require 'verify_docs'
31
+ task(:verify_docs) do
32
+ unless VerifyDocs.call
33
+ abort("\nWARNING: docs/index.md and README.md no longer have identical content. Please correct this.")
34
+ end
35
+ end
36
+
37
+ require 'rdoc/task'
38
+ Rake::RDocTask.new do |rdoc|
39
+ if File.exist?('VERSION.yml')
40
+ config = YAML.load(File.read('VERSION.yml'))
41
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
42
+ else
43
+ version = ""
44
+ end
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "shopify_api #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
51
+
52
+ task(:docker) do
53
+ cmd = "docker-compose up -d && docker exec -i -t shopify_api bash"
54
+ exec(cmd, err: File::NULL)
55
+ end
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
@@ -0,0 +1,13 @@
1
+ version: '3.5'
2
+ services:
3
+ api:
4
+ container_name: shopify_api
5
+ image: ruby:2.6
6
+ working_dir: /shopify_api
7
+ volumes:
8
+ - .:/shopify_api
9
+ - bundle:/usr/local/bundle
10
+ command: bash -c "bundle install && tail -f /dev/null"
11
+
12
+ volumes:
13
+ bundle:
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 ADDED
@@ -0,0 +1,241 @@
1
+ # GraphQL client
2
+
3
+ The `shopify_api` gem includes a full featured GraphQL client to interact with
4
+ Shopify's [GraphQL Admin API](https://help.shopify.com/en/api/graphql-admin-api).
5
+ GitHub's [graphql-client](https://github.com/github/graphql-client) is used as
6
+ the underlying client and this library integrates it with our existing
7
+ session, authentication, and API versioning features.
8
+
9
+ ## Example
10
+
11
+ ```ruby
12
+ client = ShopifyAPI::GraphQL.client
13
+
14
+ SHOP_NAME_QUERY = client.parse <<-'GRAPHQL'
15
+ {
16
+ shop {
17
+ name
18
+ }
19
+ }
20
+ GRAPHQL
21
+
22
+ result = client.query(SHOP_NAME_QUERY)
23
+ result.data.shop.name
24
+ ```
25
+
26
+ * [Getting started](#getting-started)
27
+ * [Rails integration](#rails-integration)
28
+ * [API versioning](#api-versioning)
29
+ * [Initialization process](#initialization-process)
30
+ * [Migration guide](#migration-guide)
31
+
32
+ ## Getting started
33
+
34
+ 1. [Dump the schema](#dump-the-schema)
35
+ 2. [Configure session/authentication](#sessions-and-authentication)
36
+ 3. [Make queries](#make-queries)
37
+
38
+ ### Dump the schema
39
+ One of the main benefits of GraphQL is its [schema and type system](https://graphql.org/learn/schema/)
40
+ which enables tools like graphql-client to ensure your queries are valid in development.
41
+
42
+ So the first step in making GraphQL queries is having a local JSON file of Shopify's Admin schema.
43
+ This gem provides a `shopify_api:graphql:dump` Rake task to make it as easy as possible:
44
+
45
+ #### Private apps
46
+ ```bash
47
+ $ rake shopify_api:graphql:dump SHOP_URL="https://API_KEY:PASSWORD@SHOP_NAME.myshopify.com" API_VERSION=2020-01
48
+ ```
49
+ #### Public apps
50
+ ```bash
51
+ $ rake shopify_api:graphql:dump SHOP_DOMAIN="SHOP_NAME.myshopify.com" ACCESS_TOKEN="SHOP_TOKEN" API_VERSION=2020-01
52
+ ```
53
+
54
+ If successful `db/shopify_graphql_schemas/2020-01.json` will be created.
55
+
56
+ You can either use private app authentication or an OAuth access token. Run `rake shopify_api:graphql:dump`
57
+ to see full usage details.
58
+
59
+ If you're using shopify_api in a Rails app, the default location for schema files is `db/shopify_graphql_schemas`.
60
+ For non-Rails applications, the default is `shopify_graphql_schemas` in your project root.
61
+
62
+ The schema path location can be changed via `ShopifyAPI::GraphQL.schema_location`:
63
+
64
+ ```ruby
65
+ ShopifyAPI::GraphQL.schema_location = 'assets/schemas'
66
+ ```
67
+
68
+ #### Updating schemas
69
+ Each time you want to use a new API version, or update an existing one
70
+ (such as the `unstable` version), simply run the Rake task again to overwrite the file.
71
+
72
+ ### Sessions and authentication
73
+ The GraphQL client is designed to be integrated with the rest of shopify_api so
74
+ all its features such as sessions, authentication, and API versioning work the
75
+ exact same.
76
+
77
+ If you've already been using the shopify_api gem in your application to make
78
+ REST API calls then no other configuration is necessary.
79
+
80
+ Steps 1-5 of our main [Getting started](https://github.com/Shopify/shopify_api#getting-started)
81
+ section still apply for the GraphQL client as well.
82
+
83
+ ### Make queries
84
+ Now that you've dumped a schema file and configured an authenticated session, you can make GraphQL API requests.
85
+ graphql-client encourages all queries to be defined statically as constants:
86
+
87
+ ```ruby
88
+ SHOP_NAME_QUERY = ShopifyAPI::GraphQL.client.parse <<-'GRAPHQL'
89
+ {
90
+ shop {
91
+ name
92
+ }
93
+ }
94
+ GRAPHQL
95
+
96
+ result = ShopifyAPI::GraphQL.client.query(SHOP_NAME_QUERY)
97
+ result.data.shop.name
98
+ ```
99
+
100
+ But we've also enabled its `allow_dynamic_queries` option if you prefer:
101
+
102
+ ```ruby
103
+ query = ShopifyAPI::GraphQL.client.parse <<-'GRAPHQL'
104
+ {
105
+ shop {
106
+ name
107
+ }
108
+ }
109
+ GRAPHQL
110
+
111
+ result = ShopifyAPI::GraphQL.client.query(query)
112
+ result.data.shop.name
113
+ ```
114
+
115
+ See the [graphql-client documentation](https://github.com/github/graphql-client#defining-queries)
116
+ for more details on defining and executing queries.
117
+
118
+ ## Rails integration
119
+ `ShopifyAPI::GraphQL` integrates with Rails to automatically do the following:
120
+
121
+ * load the `shopify_api:graphql:dump` Rake task
122
+ * set the `schema_location` to be in the `db` directory in your Rails root
123
+ * initialize clients in the Rails app initializer phase
124
+
125
+ ## API versioning
126
+ `ShopifyAPI::GraphQL` is version aware and lets you easily make queries to multiple
127
+ API versions through version specific clients if need be.
128
+
129
+ If you have multiple clients and need to be explicit you can specify the version parameter:
130
+
131
+ ```ruby
132
+ ShopifyAPI::GraphQL.client # defaults to the client using ShopifyAPI::Base.api_version
133
+ ShopifyAPI::GraphQL.client('unstable')
134
+ ```
135
+
136
+ ## Initialization process
137
+ `ShopifyAPI::GraphQL` is a thin integration layer which initializes `GraphQL::Client`s
138
+ from local schema files.
139
+
140
+ `ShopifyAPI::GraphQL.initialize_clients` scans `ShopifyAPI::GraphQL.schema_location`
141
+ and creates a client for each version specific schema file found.
142
+
143
+ This happens automatically in a Rails application due to our [integration](#rails-integration).
144
+ For non-Rails applications, ensure you call `ShopifyAPI::GraphQL.initialize_clients`
145
+ during your boot process.
146
+
147
+ The goal is to have all clients created at boot so there's no schema loading,
148
+ parsing, or client instantiation done during runtime when your app serves a request.
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
+
195
+ ## Migration guide
196
+ Prior to shopify_api v9.0 the GraphQL client implementation was limited and almost
197
+ unusable due to the client making dynamic introspection queries to Shopify's API.
198
+ This was not only very slow but also led to unbounded memory growth.
199
+
200
+ There are two steps to migrate to the new client:
201
+ 1. [Dump a local schema file](#dump-the-schema)
202
+ 2. [Migrate `client` usage](#migrate-usage)
203
+
204
+ ### Migrate usage
205
+
206
+ Previously a client was initialized with `ShopifyAPI::GraphQL.new`:
207
+ ```ruby
208
+ client = ShopifyAPI::GraphQL.new
209
+
210
+ SHOP_NAME_QUERY = client.parse <<-'GRAPHQL'
211
+ {
212
+ shop {
213
+ name
214
+ }
215
+ }
216
+ GRAPHQL
217
+
218
+ result = client.query(SHOP_NAME_QUERY)
219
+ result.data.shop.name
220
+ ```
221
+
222
+ Now there's no need to initialize a client so all references to
223
+ `ShopifyAPI::GraphQL.new` should be removed and instead the client is called
224
+ via `ShopifyAPI::GraphQL.client`:
225
+
226
+ ```ruby
227
+ client = ShopifyAPI::GraphQL.client
228
+
229
+ SHOP_NAME_QUERY = client.parse <<-'GRAPHQL'
230
+ {
231
+ shop {
232
+ name
233
+ }
234
+ }
235
+ GRAPHQL
236
+
237
+ result = client.query(SHOP_NAME_QUERY)
238
+ result.data.shop.name
239
+ ```
240
+
241
+ See [make queries](#make-queries) for more usage details.