shopify_api 1.0.4 → 12.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (459) hide show
  1. checksums.yaml +7 -0
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE.md +35 -0
  4. data/.github/dependabot.yml +20 -0
  5. data/.github/pull_request_template.md +20 -0
  6. data/.github/workflows/build.yml +42 -0
  7. data/.github/workflows/cla.yml +22 -0
  8. data/.github/workflows/close-waiting-for-response-issues.yml +20 -0
  9. data/.github/workflows/remove-labels-on-activity.yml +16 -0
  10. data/.github/workflows/stale.yml +32 -0
  11. data/.rubocop.yml +59 -0
  12. data/BREAKING_CHANGES_FOR_OLDER_VERSIONS.md +110 -0
  13. data/CHANGELOG.md +574 -0
  14. data/CONTRIBUTING.md +9 -0
  15. data/Gemfile +13 -0
  16. data/Gemfile.lock +159 -0
  17. data/LICENSE +2 -2
  18. data/README.md +138 -0
  19. data/RELEASING.md +19 -0
  20. data/Rakefile +16 -50
  21. data/SECURITY.md +59 -0
  22. data/bin/tapioca +29 -0
  23. data/dev.yml +32 -0
  24. data/docs/README.md +13 -0
  25. data/docs/getting_started.md +53 -0
  26. data/docs/issues.md +39 -0
  27. data/docs/usage/graphql.md +115 -0
  28. data/docs/usage/graphql_storefront.md +42 -0
  29. data/docs/usage/oauth.md +104 -0
  30. data/docs/usage/rest.md +137 -0
  31. data/docs/usage/session_storage.md +46 -0
  32. data/docs/usage/webhooks.md +98 -0
  33. data/lib/shopify_api/admin_versions.rb +19 -0
  34. data/lib/shopify_api/auth/associated_user.rb +36 -0
  35. data/lib/shopify_api/auth/auth_scopes.rb +75 -0
  36. data/lib/shopify_api/auth/file_session_storage.rb +72 -0
  37. data/lib/shopify_api/auth/jwt_payload.rb +83 -0
  38. data/lib/shopify_api/auth/oauth/auth_query.rb +47 -0
  39. data/lib/shopify_api/auth/oauth/session_cookie.rb +28 -0
  40. data/lib/shopify_api/auth/oauth.rb +135 -0
  41. data/lib/shopify_api/auth/session.rb +119 -0
  42. data/lib/shopify_api/auth/session_storage.rb +30 -0
  43. data/lib/shopify_api/auth.rb +26 -0
  44. data/lib/shopify_api/clients/graphql/admin.rb +15 -0
  45. data/lib/shopify_api/clients/graphql/client.rb +40 -0
  46. data/lib/shopify_api/clients/graphql/storefront.rb +35 -0
  47. data/lib/shopify_api/clients/http_client.rb +100 -0
  48. data/lib/shopify_api/clients/http_request.rb +35 -0
  49. data/lib/shopify_api/clients/http_response.rb +66 -0
  50. data/lib/shopify_api/clients/rest/admin.rb +118 -0
  51. data/lib/shopify_api/context.rb +196 -0
  52. data/lib/shopify_api/errors/context_not_setup_error.rb +9 -0
  53. data/lib/shopify_api/errors/cookie_not_found_error.rb +9 -0
  54. data/lib/shopify_api/errors/feature_deprecated_error.rb +9 -0
  55. data/lib/shopify_api/errors/http_response_error.rb +23 -0
  56. data/lib/shopify_api/errors/invalid_graphql_request_error.rb +9 -0
  57. data/lib/shopify_api/errors/invalid_http_request_error.rb +9 -0
  58. data/lib/shopify_api/errors/invalid_jwt_token_error.rb +9 -0
  59. data/lib/shopify_api/errors/invalid_oauth_error.rb +9 -0
  60. data/lib/shopify_api/errors/invalid_webhook_error.rb +9 -0
  61. data/lib/shopify_api/errors/invalid_webhook_registration_error.rb +9 -0
  62. data/lib/shopify_api/errors/log_level_not_found_error.rb +9 -0
  63. data/lib/shopify_api/errors/max_http_retries_exceeded_error.rb +9 -0
  64. data/lib/shopify_api/errors/missing_jwt_token_error.rb +9 -0
  65. data/lib/shopify_api/errors/missing_required_argument_error.rb +9 -0
  66. data/lib/shopify_api/errors/no_active_session_error.rb +9 -0
  67. data/lib/shopify_api/errors/no_session_cookie_error.rb +9 -0
  68. data/lib/shopify_api/errors/no_webhook_handler.rb +9 -0
  69. data/lib/shopify_api/errors/private_app_error.rb +9 -0
  70. data/lib/shopify_api/errors/request_access_token_error.rb +9 -0
  71. data/lib/shopify_api/errors/session_not_found_error.rb +9 -0
  72. data/lib/shopify_api/errors/session_storage_error.rb +9 -0
  73. data/lib/shopify_api/errors/unsupported_oauth_error.rb +9 -0
  74. data/lib/shopify_api/errors/unsupported_version_error.rb +9 -0
  75. data/lib/shopify_api/errors/webhook_registration_error.rb +9 -0
  76. data/lib/shopify_api/inflector.rb +17 -0
  77. data/lib/shopify_api/logger.rb +82 -0
  78. data/lib/shopify_api/rest/base.rb +387 -0
  79. data/lib/shopify_api/rest/base_errors.rb +32 -0
  80. data/lib/shopify_api/rest/resources/2022_01/abandoned_checkout.rb +190 -0
  81. data/lib/shopify_api/rest/resources/2022_01/access_scope.rb +58 -0
  82. data/lib/shopify_api/rest/resources/2022_01/android_pay_key.rb +77 -0
  83. data/lib/shopify_api/rest/resources/2022_01/apple_pay_certificate.rb +105 -0
  84. data/lib/shopify_api/rest/resources/2022_01/application_charge.rb +104 -0
  85. data/lib/shopify_api/rest/resources/2022_01/application_credit.rb +87 -0
  86. data/lib/shopify_api/rest/resources/2022_01/article.rb +265 -0
  87. data/lib/shopify_api/rest/resources/2022_01/asset.rb +118 -0
  88. data/lib/shopify_api/rest/resources/2022_01/assigned_fulfillment_order.rb +79 -0
  89. data/lib/shopify_api/rest/resources/2022_01/balance.rb +50 -0
  90. data/lib/shopify_api/rest/resources/2022_01/blog.rb +162 -0
  91. data/lib/shopify_api/rest/resources/2022_01/cancellation_request.rb +83 -0
  92. data/lib/shopify_api/rest/resources/2022_01/carrier_service.rb +116 -0
  93. data/lib/shopify_api/rest/resources/2022_01/checkout.rb +209 -0
  94. data/lib/shopify_api/rest/resources/2022_01/collect.rb +142 -0
  95. data/lib/shopify_api/rest/resources/2022_01/collection.rb +110 -0
  96. data/lib/shopify_api/rest/resources/2022_01/collection_listing.rb +155 -0
  97. data/lib/shopify_api/rest/resources/2022_01/comment.rb +283 -0
  98. data/lib/shopify_api/rest/resources/2022_01/country.rb +137 -0
  99. data/lib/shopify_api/rest/resources/2022_01/currency.rb +57 -0
  100. data/lib/shopify_api/rest/resources/2022_01/custom_collection.rb +187 -0
  101. data/lib/shopify_api/rest/resources/2022_01/customer.rb +318 -0
  102. data/lib/shopify_api/rest/resources/2022_01/customer_address.rb +201 -0
  103. data/lib/shopify_api/rest/resources/2022_01/customer_saved_search.rb +169 -0
  104. data/lib/shopify_api/rest/resources/2022_01/deprecated_api_call.rb +57 -0
  105. data/lib/shopify_api/rest/resources/2022_01/discount_code.rb +219 -0
  106. data/lib/shopify_api/rest/resources/2022_01/dispute.rb +111 -0
  107. data/lib/shopify_api/rest/resources/2022_01/draft_order.rb +275 -0
  108. data/lib/shopify_api/rest/resources/2022_01/event.rb +148 -0
  109. data/lib/shopify_api/rest/resources/2022_01/fulfillment.rb +268 -0
  110. data/lib/shopify_api/rest/resources/2022_01/fulfillment_event.rb +166 -0
  111. data/lib/shopify_api/rest/resources/2022_01/fulfillment_order.rb +281 -0
  112. data/lib/shopify_api/rest/resources/2022_01/fulfillment_request.rb +87 -0
  113. data/lib/shopify_api/rest/resources/2022_01/fulfillment_service.rb +130 -0
  114. data/lib/shopify_api/rest/resources/2022_01/gift_card.rb +215 -0
  115. data/lib/shopify_api/rest/resources/2022_01/gift_card_adjustment.rb +118 -0
  116. data/lib/shopify_api/rest/resources/2022_01/image.rb +157 -0
  117. data/lib/shopify_api/rest/resources/2022_01/inventory_item.rb +108 -0
  118. data/lib/shopify_api/rest/resources/2022_01/inventory_level.rb +179 -0
  119. data/lib/shopify_api/rest/resources/2022_01/location.rb +167 -0
  120. data/lib/shopify_api/rest/resources/2022_01/locations_for_move.rb +56 -0
  121. data/lib/shopify_api/rest/resources/2022_01/marketing_event.rb +209 -0
  122. data/lib/shopify_api/rest/resources/2022_01/metafield.rb +349 -0
  123. data/lib/shopify_api/rest/resources/2022_01/mobile_platform_application.rb +110 -0
  124. data/lib/shopify_api/rest/resources/2022_01/order.rb +473 -0
  125. data/lib/shopify_api/rest/resources/2022_01/order_risk.rb +135 -0
  126. data/lib/shopify_api/rest/resources/2022_01/page.rb +194 -0
  127. data/lib/shopify_api/rest/resources/2022_01/payment.rb +140 -0
  128. data/lib/shopify_api/rest/resources/2022_01/payment_gateway.rb +143 -0
  129. data/lib/shopify_api/rest/resources/2022_01/payment_transaction.rb +107 -0
  130. data/lib/shopify_api/rest/resources/2022_01/payout.rb +97 -0
  131. data/lib/shopify_api/rest/resources/2022_01/policy.rb +69 -0
  132. data/lib/shopify_api/rest/resources/2022_01/price_rule.rb +223 -0
  133. data/lib/shopify_api/rest/resources/2022_01/product.rb +223 -0
  134. data/lib/shopify_api/rest/resources/2022_01/product_listing.rb +196 -0
  135. data/lib/shopify_api/rest/resources/2022_01/product_resource_feedback.rb +88 -0
  136. data/lib/shopify_api/rest/resources/2022_01/province.rb +132 -0
  137. data/lib/shopify_api/rest/resources/2022_01/recurring_application_charge.rb +167 -0
  138. data/lib/shopify_api/rest/resources/2022_01/redirect.rb +139 -0
  139. data/lib/shopify_api/rest/resources/2022_01/refund.rb +151 -0
  140. data/lib/shopify_api/rest/resources/2022_01/report.rb +121 -0
  141. data/lib/shopify_api/rest/resources/2022_01/resource_feedback.rb +73 -0
  142. data/lib/shopify_api/rest/resources/2022_01/script_tag.rb +155 -0
  143. data/lib/shopify_api/rest/resources/2022_01/shipping_zone.rb +83 -0
  144. data/lib/shopify_api/rest/resources/2022_01/shop.rb +218 -0
  145. data/lib/shopify_api/rest/resources/2022_01/smart_collection.rb +216 -0
  146. data/lib/shopify_api/rest/resources/2022_01/storefront_access_token.rb +87 -0
  147. data/lib/shopify_api/rest/resources/2022_01/tender_transaction.rb +93 -0
  148. data/lib/shopify_api/rest/resources/2022_01/theme.rb +120 -0
  149. data/lib/shopify_api/rest/resources/2022_01/transaction.rb +181 -0
  150. data/lib/shopify_api/rest/resources/2022_01/usage_charge.rb +97 -0
  151. data/lib/shopify_api/rest/resources/2022_01/user.rb +138 -0
  152. data/lib/shopify_api/rest/resources/2022_01/variant.rb +212 -0
  153. data/lib/shopify_api/rest/resources/2022_01/webhook.rb +168 -0
  154. data/lib/shopify_api/rest/resources/2022_04/abandoned_checkout.rb +190 -0
  155. data/lib/shopify_api/rest/resources/2022_04/access_scope.rb +58 -0
  156. data/lib/shopify_api/rest/resources/2022_04/android_pay_key.rb +77 -0
  157. data/lib/shopify_api/rest/resources/2022_04/apple_pay_certificate.rb +105 -0
  158. data/lib/shopify_api/rest/resources/2022_04/application_charge.rb +104 -0
  159. data/lib/shopify_api/rest/resources/2022_04/application_credit.rb +87 -0
  160. data/lib/shopify_api/rest/resources/2022_04/article.rb +265 -0
  161. data/lib/shopify_api/rest/resources/2022_04/asset.rb +118 -0
  162. data/lib/shopify_api/rest/resources/2022_04/assigned_fulfillment_order.rb +79 -0
  163. data/lib/shopify_api/rest/resources/2022_04/balance.rb +50 -0
  164. data/lib/shopify_api/rest/resources/2022_04/blog.rb +162 -0
  165. data/lib/shopify_api/rest/resources/2022_04/cancellation_request.rb +83 -0
  166. data/lib/shopify_api/rest/resources/2022_04/carrier_service.rb +116 -0
  167. data/lib/shopify_api/rest/resources/2022_04/checkout.rb +209 -0
  168. data/lib/shopify_api/rest/resources/2022_04/collect.rb +142 -0
  169. data/lib/shopify_api/rest/resources/2022_04/collection.rb +110 -0
  170. data/lib/shopify_api/rest/resources/2022_04/collection_listing.rb +155 -0
  171. data/lib/shopify_api/rest/resources/2022_04/comment.rb +283 -0
  172. data/lib/shopify_api/rest/resources/2022_04/country.rb +137 -0
  173. data/lib/shopify_api/rest/resources/2022_04/currency.rb +57 -0
  174. data/lib/shopify_api/rest/resources/2022_04/custom_collection.rb +187 -0
  175. data/lib/shopify_api/rest/resources/2022_04/customer.rb +321 -0
  176. data/lib/shopify_api/rest/resources/2022_04/customer_address.rb +201 -0
  177. data/lib/shopify_api/rest/resources/2022_04/customer_saved_search.rb +169 -0
  178. data/lib/shopify_api/rest/resources/2022_04/deprecated_api_call.rb +57 -0
  179. data/lib/shopify_api/rest/resources/2022_04/discount_code.rb +219 -0
  180. data/lib/shopify_api/rest/resources/2022_04/dispute.rb +111 -0
  181. data/lib/shopify_api/rest/resources/2022_04/draft_order.rb +275 -0
  182. data/lib/shopify_api/rest/resources/2022_04/event.rb +148 -0
  183. data/lib/shopify_api/rest/resources/2022_04/fulfillment.rb +268 -0
  184. data/lib/shopify_api/rest/resources/2022_04/fulfillment_event.rb +166 -0
  185. data/lib/shopify_api/rest/resources/2022_04/fulfillment_order.rb +284 -0
  186. data/lib/shopify_api/rest/resources/2022_04/fulfillment_request.rb +87 -0
  187. data/lib/shopify_api/rest/resources/2022_04/fulfillment_service.rb +130 -0
  188. data/lib/shopify_api/rest/resources/2022_04/gift_card.rb +215 -0
  189. data/lib/shopify_api/rest/resources/2022_04/gift_card_adjustment.rb +118 -0
  190. data/lib/shopify_api/rest/resources/2022_04/image.rb +157 -0
  191. data/lib/shopify_api/rest/resources/2022_04/inventory_item.rb +108 -0
  192. data/lib/shopify_api/rest/resources/2022_04/inventory_level.rb +179 -0
  193. data/lib/shopify_api/rest/resources/2022_04/location.rb +167 -0
  194. data/lib/shopify_api/rest/resources/2022_04/locations_for_move.rb +56 -0
  195. data/lib/shopify_api/rest/resources/2022_04/marketing_event.rb +209 -0
  196. data/lib/shopify_api/rest/resources/2022_04/metafield.rb +342 -0
  197. data/lib/shopify_api/rest/resources/2022_04/mobile_platform_application.rb +110 -0
  198. data/lib/shopify_api/rest/resources/2022_04/order.rb +473 -0
  199. data/lib/shopify_api/rest/resources/2022_04/order_risk.rb +135 -0
  200. data/lib/shopify_api/rest/resources/2022_04/page.rb +194 -0
  201. data/lib/shopify_api/rest/resources/2022_04/payment.rb +140 -0
  202. data/lib/shopify_api/rest/resources/2022_04/payment_gateway.rb +143 -0
  203. data/lib/shopify_api/rest/resources/2022_04/payment_transaction.rb +107 -0
  204. data/lib/shopify_api/rest/resources/2022_04/payout.rb +97 -0
  205. data/lib/shopify_api/rest/resources/2022_04/policy.rb +69 -0
  206. data/lib/shopify_api/rest/resources/2022_04/price_rule.rb +223 -0
  207. data/lib/shopify_api/rest/resources/2022_04/product.rb +223 -0
  208. data/lib/shopify_api/rest/resources/2022_04/product_listing.rb +196 -0
  209. data/lib/shopify_api/rest/resources/2022_04/product_resource_feedback.rb +88 -0
  210. data/lib/shopify_api/rest/resources/2022_04/province.rb +132 -0
  211. data/lib/shopify_api/rest/resources/2022_04/recurring_application_charge.rb +167 -0
  212. data/lib/shopify_api/rest/resources/2022_04/redirect.rb +139 -0
  213. data/lib/shopify_api/rest/resources/2022_04/refund.rb +151 -0
  214. data/lib/shopify_api/rest/resources/2022_04/report.rb +121 -0
  215. data/lib/shopify_api/rest/resources/2022_04/resource_feedback.rb +73 -0
  216. data/lib/shopify_api/rest/resources/2022_04/script_tag.rb +155 -0
  217. data/lib/shopify_api/rest/resources/2022_04/shipping_zone.rb +83 -0
  218. data/lib/shopify_api/rest/resources/2022_04/shop.rb +218 -0
  219. data/lib/shopify_api/rest/resources/2022_04/smart_collection.rb +216 -0
  220. data/lib/shopify_api/rest/resources/2022_04/storefront_access_token.rb +87 -0
  221. data/lib/shopify_api/rest/resources/2022_04/tender_transaction.rb +93 -0
  222. data/lib/shopify_api/rest/resources/2022_04/theme.rb +120 -0
  223. data/lib/shopify_api/rest/resources/2022_04/transaction.rb +181 -0
  224. data/lib/shopify_api/rest/resources/2022_04/usage_charge.rb +97 -0
  225. data/lib/shopify_api/rest/resources/2022_04/user.rb +138 -0
  226. data/lib/shopify_api/rest/resources/2022_04/variant.rb +212 -0
  227. data/lib/shopify_api/rest/resources/2022_04/webhook.rb +168 -0
  228. data/lib/shopify_api/rest/resources/2022_07/abandoned_checkout.rb +190 -0
  229. data/lib/shopify_api/rest/resources/2022_07/access_scope.rb +58 -0
  230. data/lib/shopify_api/rest/resources/2022_07/android_pay_key.rb +77 -0
  231. data/lib/shopify_api/rest/resources/2022_07/apple_pay_certificate.rb +105 -0
  232. data/lib/shopify_api/rest/resources/2022_07/application_charge.rb +104 -0
  233. data/lib/shopify_api/rest/resources/2022_07/application_credit.rb +87 -0
  234. data/lib/shopify_api/rest/resources/2022_07/article.rb +265 -0
  235. data/lib/shopify_api/rest/resources/2022_07/asset.rb +118 -0
  236. data/lib/shopify_api/rest/resources/2022_07/assigned_fulfillment_order.rb +79 -0
  237. data/lib/shopify_api/rest/resources/2022_07/balance.rb +50 -0
  238. data/lib/shopify_api/rest/resources/2022_07/blog.rb +162 -0
  239. data/lib/shopify_api/rest/resources/2022_07/cancellation_request.rb +83 -0
  240. data/lib/shopify_api/rest/resources/2022_07/carrier_service.rb +113 -0
  241. data/lib/shopify_api/rest/resources/2022_07/checkout.rb +209 -0
  242. data/lib/shopify_api/rest/resources/2022_07/collect.rb +142 -0
  243. data/lib/shopify_api/rest/resources/2022_07/collection.rb +110 -0
  244. data/lib/shopify_api/rest/resources/2022_07/collection_listing.rb +155 -0
  245. data/lib/shopify_api/rest/resources/2022_07/comment.rb +283 -0
  246. data/lib/shopify_api/rest/resources/2022_07/country.rb +137 -0
  247. data/lib/shopify_api/rest/resources/2022_07/currency.rb +57 -0
  248. data/lib/shopify_api/rest/resources/2022_07/custom_collection.rb +187 -0
  249. data/lib/shopify_api/rest/resources/2022_07/customer.rb +321 -0
  250. data/lib/shopify_api/rest/resources/2022_07/customer_address.rb +201 -0
  251. data/lib/shopify_api/rest/resources/2022_07/customer_saved_search.rb +169 -0
  252. data/lib/shopify_api/rest/resources/2022_07/deprecated_api_call.rb +57 -0
  253. data/lib/shopify_api/rest/resources/2022_07/discount_code.rb +219 -0
  254. data/lib/shopify_api/rest/resources/2022_07/dispute.rb +111 -0
  255. data/lib/shopify_api/rest/resources/2022_07/dispute_evidence.rb +117 -0
  256. data/lib/shopify_api/rest/resources/2022_07/dispute_file_upload.rb +81 -0
  257. data/lib/shopify_api/rest/resources/2022_07/draft_order.rb +275 -0
  258. data/lib/shopify_api/rest/resources/2022_07/event.rb +148 -0
  259. data/lib/shopify_api/rest/resources/2022_07/fulfillment.rb +221 -0
  260. data/lib/shopify_api/rest/resources/2022_07/fulfillment_event.rb +166 -0
  261. data/lib/shopify_api/rest/resources/2022_07/fulfillment_order.rb +310 -0
  262. data/lib/shopify_api/rest/resources/2022_07/fulfillment_request.rb +87 -0
  263. data/lib/shopify_api/rest/resources/2022_07/fulfillment_service.rb +130 -0
  264. data/lib/shopify_api/rest/resources/2022_07/gift_card.rb +215 -0
  265. data/lib/shopify_api/rest/resources/2022_07/gift_card_adjustment.rb +118 -0
  266. data/lib/shopify_api/rest/resources/2022_07/image.rb +157 -0
  267. data/lib/shopify_api/rest/resources/2022_07/inventory_item.rb +108 -0
  268. data/lib/shopify_api/rest/resources/2022_07/inventory_level.rb +179 -0
  269. data/lib/shopify_api/rest/resources/2022_07/location.rb +167 -0
  270. data/lib/shopify_api/rest/resources/2022_07/locations_for_move.rb +56 -0
  271. data/lib/shopify_api/rest/resources/2022_07/marketing_event.rb +209 -0
  272. data/lib/shopify_api/rest/resources/2022_07/metafield.rb +342 -0
  273. data/lib/shopify_api/rest/resources/2022_07/mobile_platform_application.rb +110 -0
  274. data/lib/shopify_api/rest/resources/2022_07/order.rb +473 -0
  275. data/lib/shopify_api/rest/resources/2022_07/order_risk.rb +135 -0
  276. data/lib/shopify_api/rest/resources/2022_07/page.rb +194 -0
  277. data/lib/shopify_api/rest/resources/2022_07/payment.rb +140 -0
  278. data/lib/shopify_api/rest/resources/2022_07/payment_gateway.rb +143 -0
  279. data/lib/shopify_api/rest/resources/2022_07/payment_transaction.rb +107 -0
  280. data/lib/shopify_api/rest/resources/2022_07/payout.rb +97 -0
  281. data/lib/shopify_api/rest/resources/2022_07/policy.rb +69 -0
  282. data/lib/shopify_api/rest/resources/2022_07/price_rule.rb +223 -0
  283. data/lib/shopify_api/rest/resources/2022_07/product.rb +223 -0
  284. data/lib/shopify_api/rest/resources/2022_07/product_listing.rb +196 -0
  285. data/lib/shopify_api/rest/resources/2022_07/product_resource_feedback.rb +88 -0
  286. data/lib/shopify_api/rest/resources/2022_07/province.rb +132 -0
  287. data/lib/shopify_api/rest/resources/2022_07/recurring_application_charge.rb +167 -0
  288. data/lib/shopify_api/rest/resources/2022_07/redirect.rb +139 -0
  289. data/lib/shopify_api/rest/resources/2022_07/refund.rb +151 -0
  290. data/lib/shopify_api/rest/resources/2022_07/report.rb +121 -0
  291. data/lib/shopify_api/rest/resources/2022_07/resource_feedback.rb +73 -0
  292. data/lib/shopify_api/rest/resources/2022_07/script_tag.rb +155 -0
  293. data/lib/shopify_api/rest/resources/2022_07/shipping_zone.rb +83 -0
  294. data/lib/shopify_api/rest/resources/2022_07/shop.rb +218 -0
  295. data/lib/shopify_api/rest/resources/2022_07/smart_collection.rb +216 -0
  296. data/lib/shopify_api/rest/resources/2022_07/storefront_access_token.rb +87 -0
  297. data/lib/shopify_api/rest/resources/2022_07/tender_transaction.rb +93 -0
  298. data/lib/shopify_api/rest/resources/2022_07/theme.rb +120 -0
  299. data/lib/shopify_api/rest/resources/2022_07/transaction.rb +181 -0
  300. data/lib/shopify_api/rest/resources/2022_07/usage_charge.rb +97 -0
  301. data/lib/shopify_api/rest/resources/2022_07/user.rb +138 -0
  302. data/lib/shopify_api/rest/resources/2022_07/variant.rb +212 -0
  303. data/lib/shopify_api/rest/resources/2022_07/webhook.rb +168 -0
  304. data/lib/shopify_api/rest/resources/2022_10/abandoned_checkout.rb +190 -0
  305. data/lib/shopify_api/rest/resources/2022_10/access_scope.rb +58 -0
  306. data/lib/shopify_api/rest/resources/2022_10/android_pay_key.rb +77 -0
  307. data/lib/shopify_api/rest/resources/2022_10/apple_pay_certificate.rb +105 -0
  308. data/lib/shopify_api/rest/resources/2022_10/application_charge.rb +104 -0
  309. data/lib/shopify_api/rest/resources/2022_10/application_credit.rb +87 -0
  310. data/lib/shopify_api/rest/resources/2022_10/article.rb +265 -0
  311. data/lib/shopify_api/rest/resources/2022_10/asset.rb +118 -0
  312. data/lib/shopify_api/rest/resources/2022_10/assigned_fulfillment_order.rb +79 -0
  313. data/lib/shopify_api/rest/resources/2022_10/balance.rb +50 -0
  314. data/lib/shopify_api/rest/resources/2022_10/blog.rb +162 -0
  315. data/lib/shopify_api/rest/resources/2022_10/cancellation_request.rb +83 -0
  316. data/lib/shopify_api/rest/resources/2022_10/carrier_service.rb +113 -0
  317. data/lib/shopify_api/rest/resources/2022_10/checkout.rb +209 -0
  318. data/lib/shopify_api/rest/resources/2022_10/collect.rb +142 -0
  319. data/lib/shopify_api/rest/resources/2022_10/collection.rb +110 -0
  320. data/lib/shopify_api/rest/resources/2022_10/collection_listing.rb +155 -0
  321. data/lib/shopify_api/rest/resources/2022_10/comment.rb +283 -0
  322. data/lib/shopify_api/rest/resources/2022_10/country.rb +137 -0
  323. data/lib/shopify_api/rest/resources/2022_10/currency.rb +57 -0
  324. data/lib/shopify_api/rest/resources/2022_10/custom_collection.rb +187 -0
  325. data/lib/shopify_api/rest/resources/2022_10/customer.rb +321 -0
  326. data/lib/shopify_api/rest/resources/2022_10/customer_address.rb +201 -0
  327. data/lib/shopify_api/rest/resources/2022_10/customer_saved_search.rb +169 -0
  328. data/lib/shopify_api/rest/resources/2022_10/deprecated_api_call.rb +57 -0
  329. data/lib/shopify_api/rest/resources/2022_10/discount_code.rb +219 -0
  330. data/lib/shopify_api/rest/resources/2022_10/dispute.rb +111 -0
  331. data/lib/shopify_api/rest/resources/2022_10/dispute_evidence.rb +117 -0
  332. data/lib/shopify_api/rest/resources/2022_10/dispute_file_upload.rb +81 -0
  333. data/lib/shopify_api/rest/resources/2022_10/draft_order.rb +275 -0
  334. data/lib/shopify_api/rest/resources/2022_10/event.rb +148 -0
  335. data/lib/shopify_api/rest/resources/2022_10/fulfillment.rb +221 -0
  336. data/lib/shopify_api/rest/resources/2022_10/fulfillment_event.rb +166 -0
  337. data/lib/shopify_api/rest/resources/2022_10/fulfillment_order.rb +310 -0
  338. data/lib/shopify_api/rest/resources/2022_10/fulfillment_request.rb +87 -0
  339. data/lib/shopify_api/rest/resources/2022_10/fulfillment_service.rb +130 -0
  340. data/lib/shopify_api/rest/resources/2022_10/gift_card.rb +215 -0
  341. data/lib/shopify_api/rest/resources/2022_10/gift_card_adjustment.rb +118 -0
  342. data/lib/shopify_api/rest/resources/2022_10/image.rb +157 -0
  343. data/lib/shopify_api/rest/resources/2022_10/inventory_item.rb +108 -0
  344. data/lib/shopify_api/rest/resources/2022_10/inventory_level.rb +179 -0
  345. data/lib/shopify_api/rest/resources/2022_10/location.rb +167 -0
  346. data/lib/shopify_api/rest/resources/2022_10/locations_for_move.rb +56 -0
  347. data/lib/shopify_api/rest/resources/2022_10/marketing_event.rb +209 -0
  348. data/lib/shopify_api/rest/resources/2022_10/metafield.rb +342 -0
  349. data/lib/shopify_api/rest/resources/2022_10/mobile_platform_application.rb +110 -0
  350. data/lib/shopify_api/rest/resources/2022_10/order.rb +476 -0
  351. data/lib/shopify_api/rest/resources/2022_10/order_risk.rb +135 -0
  352. data/lib/shopify_api/rest/resources/2022_10/page.rb +194 -0
  353. data/lib/shopify_api/rest/resources/2022_10/payment.rb +140 -0
  354. data/lib/shopify_api/rest/resources/2022_10/payment_gateway.rb +143 -0
  355. data/lib/shopify_api/rest/resources/2022_10/payment_transaction.rb +107 -0
  356. data/lib/shopify_api/rest/resources/2022_10/payout.rb +97 -0
  357. data/lib/shopify_api/rest/resources/2022_10/policy.rb +69 -0
  358. data/lib/shopify_api/rest/resources/2022_10/price_rule.rb +223 -0
  359. data/lib/shopify_api/rest/resources/2022_10/product.rb +223 -0
  360. data/lib/shopify_api/rest/resources/2022_10/product_listing.rb +196 -0
  361. data/lib/shopify_api/rest/resources/2022_10/product_resource_feedback.rb +88 -0
  362. data/lib/shopify_api/rest/resources/2022_10/province.rb +132 -0
  363. data/lib/shopify_api/rest/resources/2022_10/recurring_application_charge.rb +167 -0
  364. data/lib/shopify_api/rest/resources/2022_10/redirect.rb +139 -0
  365. data/lib/shopify_api/rest/resources/2022_10/refund.rb +151 -0
  366. data/lib/shopify_api/rest/resources/2022_10/report.rb +121 -0
  367. data/lib/shopify_api/rest/resources/2022_10/resource_feedback.rb +73 -0
  368. data/lib/shopify_api/rest/resources/2022_10/script_tag.rb +155 -0
  369. data/lib/shopify_api/rest/resources/2022_10/shipping_zone.rb +83 -0
  370. data/lib/shopify_api/rest/resources/2022_10/shop.rb +221 -0
  371. data/lib/shopify_api/rest/resources/2022_10/smart_collection.rb +216 -0
  372. data/lib/shopify_api/rest/resources/2022_10/storefront_access_token.rb +87 -0
  373. data/lib/shopify_api/rest/resources/2022_10/tender_transaction.rb +93 -0
  374. data/lib/shopify_api/rest/resources/2022_10/theme.rb +120 -0
  375. data/lib/shopify_api/rest/resources/2022_10/transaction.rb +181 -0
  376. data/lib/shopify_api/rest/resources/2022_10/usage_charge.rb +97 -0
  377. data/lib/shopify_api/rest/resources/2022_10/user.rb +138 -0
  378. data/lib/shopify_api/rest/resources/2022_10/variant.rb +212 -0
  379. data/lib/shopify_api/rest/resources/2022_10/webhook.rb +168 -0
  380. data/lib/shopify_api/utils/graphql_proxy.rb +52 -0
  381. data/lib/shopify_api/utils/hmac_validator.rb +44 -0
  382. data/lib/shopify_api/utils/http_utils.rb +17 -0
  383. data/lib/shopify_api/utils/session_utils.rb +152 -0
  384. data/lib/shopify_api/utils/verifiable_query.rb +18 -0
  385. data/lib/shopify_api/version.rb +6 -0
  386. data/lib/shopify_api/webhooks/handler.rb +15 -0
  387. data/lib/shopify_api/webhooks/register_result.rb +14 -0
  388. data/lib/shopify_api/webhooks/registration.rb +73 -0
  389. data/lib/shopify_api/webhooks/registrations/event_bridge.rb +61 -0
  390. data/lib/shopify_api/webhooks/registrations/http.rb +72 -0
  391. data/lib/shopify_api/webhooks/registrations/pub_sub.rb +65 -0
  392. data/lib/shopify_api/webhooks/registry.rb +215 -0
  393. data/lib/shopify_api/webhooks/request.rb +56 -0
  394. data/lib/shopify_api.rb +23 -472
  395. data/service.yml +1 -0
  396. data/shipit.rubygems.yml +1 -0
  397. data/shopify_api.gemspec +43 -102
  398. data/sorbet/config +3 -0
  399. data/sorbet/rbi/gems/activesupport@7.0.1.rbi +654 -0
  400. data/sorbet/rbi/gems/addressable@2.8.0.rbi +290 -0
  401. data/sorbet/rbi/gems/ast@2.4.2.rbi +54 -0
  402. data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
  403. data/sorbet/rbi/gems/concurrent-ruby@1.1.9.rbi +2401 -0
  404. data/sorbet/rbi/gems/crack@0.4.5.rbi +57 -0
  405. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +185 -0
  406. data/sorbet/rbi/gems/fakefs@1.4.1.rbi +571 -0
  407. data/sorbet/rbi/gems/hash_diff@1.0.0.rbi +47 -0
  408. data/sorbet/rbi/gems/hashdiff@1.0.1.rbi +82 -0
  409. data/sorbet/rbi/gems/httparty@0.20.0.rbi +573 -0
  410. data/sorbet/rbi/gems/i18n@1.8.11.rbi +25 -0
  411. data/sorbet/rbi/gems/jwt@2.3.0.rbi +437 -0
  412. data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
  413. data/sorbet/rbi/gems/mime-types-data@3.2022.0105.rbi +73 -0
  414. data/sorbet/rbi/gems/mime-types@3.4.1.rbi +295 -0
  415. data/sorbet/rbi/gems/minitest@5.15.0.rbi +541 -0
  416. data/sorbet/rbi/gems/mocha@1.13.0.rbi +986 -0
  417. data/sorbet/rbi/gems/multi_xml@0.6.0.rbi +36 -0
  418. data/sorbet/rbi/gems/oj@3.13.11.rbi +274 -0
  419. data/sorbet/rbi/gems/openssl@3.0.0.rbi +581 -0
  420. data/sorbet/rbi/gems/parallel@1.21.0.rbi +113 -0
  421. data/sorbet/rbi/gems/parser@3.1.0.0.rbi +1741 -0
  422. data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
  423. data/sorbet/rbi/gems/public_suffix@4.0.6.rbi +145 -0
  424. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +157 -0
  425. data/sorbet/rbi/gems/rake@13.0.6.rbi +814 -0
  426. data/sorbet/rbi/gems/rbi@0.0.11.rbi +1646 -0
  427. data/sorbet/rbi/gems/regexp_parser@2.2.0.rbi +1130 -0
  428. data/sorbet/rbi/gems/rexml@3.2.5.rbi +709 -0
  429. data/sorbet/rbi/gems/rubocop-ast@1.15.1.rbi +1921 -0
  430. data/sorbet/rbi/gems/rubocop-shopify@2.4.0.rbi +8 -0
  431. data/sorbet/rbi/gems/rubocop-sorbet@0.6.5.rbi +295 -0
  432. data/sorbet/rbi/gems/rubocop@1.25.1.rbi +13507 -0
  433. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +405 -0
  434. data/sorbet/rbi/gems/securerandom@0.1.1.rbi +10 -0
  435. data/sorbet/rbi/gems/spoom@1.1.8.rbi +1252 -0
  436. data/sorbet/rbi/gems/tapioca@0.6.3.rbi +1238 -0
  437. data/sorbet/rbi/gems/thor@1.2.1.rbi +844 -0
  438. data/sorbet/rbi/gems/tzinfo@2.0.4.rbi +858 -0
  439. data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +26 -0
  440. data/sorbet/rbi/gems/unparser@0.6.3.rbi +1816 -0
  441. data/sorbet/rbi/gems/webmock@3.14.0.rbi +683 -0
  442. data/sorbet/rbi/gems/webrick@1.7.0.rbi +601 -0
  443. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +199 -0
  444. data/sorbet/rbi/gems/yard@0.9.27.rbi +4145 -0
  445. data/sorbet/rbi/gems/zeitwerk@2.5.4.rbi +200 -0
  446. data/sorbet/rbi/shims/fakefs.rbi +1 -0
  447. data/sorbet/rbi/shims/openssl.rb +3 -0
  448. data/sorbet/rbi/todo.rbi +8 -0
  449. data/sorbet/tapioca/config.yml +4 -0
  450. data/sorbet/tapioca/require.rb +20 -0
  451. metadata +736 -80
  452. data/.document +0 -5
  453. data/.gitignore +0 -5
  454. data/CHANGELOG +0 -5
  455. data/README.rdoc +0 -55
  456. data/VERSION +0 -1
  457. data/test/order_test.rb +0 -48
  458. data/test/shopify_api_test.rb +0 -21
  459. data/test/test_helper.rb +0 -28
data/lib/shopify_api.rb CHANGED
@@ -1,472 +1,23 @@
1
- require 'active_resource'
2
- require 'digest/md5'
3
-
4
- module ShopifyAPI
5
- METAFIELD_ENABLED_CLASSES = %w( Order Product CustomCollection SmartCollection Page Blog Article Variant)
6
-
7
- module Countable
8
- def count(options = {})
9
- Integer(get(:count, options))
10
- end
11
- end
12
-
13
- module Metafields
14
- def metafields
15
- Metafield.find(:all, :params => {:resource => self.class.collection_name, :resource_id => id})
16
- end
17
-
18
- def add_metafield(metafield)
19
- raise ArgumentError, "You can only add metafields to resource that has been saved" if new?
20
-
21
- metafield.prefix_options = {
22
- :resource => self.class.collection_name,
23
- :resource_id => id
24
- }
25
- metafield.save
26
- metafield
27
- end
28
- end
29
-
30
- #
31
- # The Shopify API authenticates each call via HTTP Authentication, using
32
- # * the application's API key as the username, and
33
- # * a hex digest of the application's shared secret and an
34
- # authentication token as the password.
35
- #
36
- # Generation & acquisition of the beforementioned looks like this:
37
- #
38
- # 0. Developer (that's you) registers Application (and provides a
39
- # callback url) and receives an API key and a shared secret
40
- #
41
- # 1. User visits Application and are told they need to authenticate the
42
- # application first for read/write permission to their data (needs to
43
- # happen only once). User is asked for their shop url.
44
- #
45
- # 2. Application redirects to Shopify : GET <user's shop url>/admin/api/auth?api_key=<API key>
46
- # (See Session#create_permission_url)
47
- #
48
- # 3. User logs-in to Shopify, approves application permission request
49
- #
50
- # 4. Shopify redirects to the Application's callback url (provided during
51
- # registration), including the shop's name, and an authentication token in the parameters:
52
- # GET client.com/customers?shop=snake-oil.myshopify.com&t=a94a110d86d2452eb3e2af4cfb8a3828
53
- #
54
- # 5. Authentication password computed using the shared secret and the
55
- # authentication token (see Session#computed_password)
56
- #
57
- # 6. Profit!
58
- # (API calls can now authenticate through HTTP using the API key, and
59
- # computed password)
60
- #
61
- # LoginController and ShopifyLoginProtection use the Session class to set Shopify::Base.site
62
- # so that all API calls are authorized transparently and end up just looking like this:
63
- #
64
- # # get 3 products
65
- # @products = ShopifyAPI::Product.find(:all, :params => {:limit => 3})
66
- #
67
- # # get latest 3 orders
68
- # @orders = ShopifyAPI::Order.find(:all, :params => {:limit => 3, :order => "created_at DESC" })
69
- #
70
- # As an example of what your LoginController should look like, take a look
71
- # at the following:
72
- #
73
- # class LoginController < ApplicationController
74
- # def index
75
- # # Ask user for their #{shop}.myshopify.com address
76
- # end
77
- #
78
- # def authenticate
79
- # redirect_to ShopifyAPI::Session.new(params[:shop]).create_permission_url
80
- # end
81
- #
82
- # # Shopify redirects the logged-in user back to this action along with
83
- # # the authorization token t.
84
- # #
85
- # # This token is later combined with the developer's shared secret to form
86
- # # the password used to call API methods.
87
- # def finalize
88
- # shopify_session = ShopifyAPI::Session.new(params[:shop], params[:t])
89
- # if shopify_session.valid?
90
- # session[:shopify] = shopify_session
91
- # flash[:notice] = "Logged in to shopify store."
92
- #
93
- # return_address = session[:return_to] || '/home'
94
- # session[:return_to] = nil
95
- # redirect_to return_address
96
- # else
97
- # flash[:error] = "Could not log in to Shopify store."
98
- # redirect_to :action => 'index'
99
- # end
100
- # end
101
- #
102
- # def logout
103
- # session[:shopify] = nil
104
- # flash[:notice] = "Successfully logged out."
105
- #
106
- # redirect_to :action => 'index'
107
- # end
108
- # end
109
- #
110
- class Session
111
- cattr_accessor :api_key
112
- cattr_accessor :secret
113
- cattr_accessor :protocol
114
- self.protocol = 'https'
115
-
116
- attr_accessor :url, :token, :name
117
-
118
- def self.setup(params)
119
- params.each { |k,value| send("#{k}=", value) }
120
- end
121
-
122
- def initialize(url, token = nil, params = nil)
123
- self.url, self.token = url, token
124
-
125
- if params && params[:signature]
126
- unless self.class.validate_signature(params) && params[:timestamp].to_i > 24.hours.ago.utc.to_i
127
- raise "Invalid Signature: Possible malicious login"
128
- end
129
- end
130
-
131
- self.class.prepare_url(self.url) if valid?
132
- end
133
-
134
- def shop
135
- Shop.current
136
- end
137
-
138
- def create_permission_url
139
- "http://#{url}/admin/api/auth?api_key=#{api_key}"
140
- end
141
-
142
- # Used by ActiveResource::Base to make all non-authentication API calls
143
- #
144
- # (ShopifyAPI::Base.site set in ShopifyLoginProtection#shopify_session)
145
- def site
146
- "#{protocol}://#{api_key}:#{computed_password}@#{url}/admin"
147
- end
148
-
149
- def valid?
150
- url.present? && token.present?
151
- end
152
-
153
- private
154
-
155
- # The secret is computed by taking the shared_secret which we got when
156
- # registring this third party application and concating the request_to it,
157
- # and then calculating a MD5 hexdigest.
158
- def computed_password
159
- Digest::MD5.hexdigest(secret + token.to_s)
160
- end
161
-
162
- def self.prepare_url(url)
163
- url.gsub!(/https?:\/\//, '') # remove http:// or https://
164
- url.concat(".myshopify.com") unless url.include?('.') # extend url to myshopify.com if no host is given
165
- end
166
-
167
- def self.validate_signature(params)
168
- return false unless signature = params[:signature]
169
-
170
- sorted_params = params.except(:signature, :action, :controller).collect{|k,v|"#{k}=#{v}"}.sort.join
171
- Digest::MD5.hexdigest(secret + sorted_params) == signature
172
- end
173
- end
174
-
175
- class Base < ActiveResource::Base
176
- extend Countable
177
- end
178
-
179
- # Shop object. Use Shop.current to receive
180
- # the shop.
181
- class Shop < Base
182
- def self.current
183
- find(:one, :from => "/admin/shop.xml")
184
- end
185
-
186
- def metafields
187
- Metafield.find(:all)
188
- end
189
-
190
- def add_metafield(metafield)
191
- raise ArgumentError, "You can only add metafields to resource that has been saved" if new?
192
- metafield.save
193
- metafield
194
- end
195
- end
196
-
197
- # Custom collection
198
- #
199
- class CustomCollection < Base
200
- def products
201
- Product.find(:all, :params => {:collection_id => self.id})
202
- end
203
-
204
- def add_product(product)
205
- Collect.create(:collection_id => self.id, :product_id => product.id)
206
- end
207
-
208
- def remove_product(product)
209
- collect = Collect.find(:first, :params => {:collection_id => self.id, :product_id => product.id})
210
- collect.destroy if collect
211
- end
212
- end
213
-
214
- class SmartCollection < Base
215
- def products
216
- Product.find(:all, :params => {:collection_id => self.id})
217
- end
218
- end
219
-
220
- # For adding/removing products from custom collections
221
- class Collect < Base
222
- end
223
-
224
- class ShippingAddress < Base
225
- end
226
-
227
- class BillingAddress < Base
228
- end
229
-
230
- class LineItem < Base
231
- end
232
-
233
- class ShippingLine < Base
234
- end
235
-
236
- class NoteAttribute < Base
237
- end
238
-
239
- class Order < Base
240
- def close; load_attributes_from_response(post(:close)); end
241
-
242
- def open; load_attributes_from_response(post(:open)); end
243
-
244
- def transactions
245
- Transaction.find(:all, :params => { :order_id => id })
246
- end
247
-
248
- def capture(amount = "")
249
- Transaction.create(:amount => amount, :kind => "capture", :order_id => id)
250
- end
251
- end
252
-
253
- class Product < Base
254
-
255
- # Share all items of this store with the
256
- # shopify marketplace
257
- def self.share; post :share; end
258
- def self.unshare; delete :share; end
259
-
260
- # compute the price range
261
- def price_range
262
- prices = variants.collect(&:price)
263
- format = "%0.2f"
264
- if prices.min != prices.max
265
- "#{format % prices.min} - #{format % prices.max}"
266
- else
267
- format % prices.min
268
- end
269
- end
270
-
271
- def collections
272
- CustomCollection.find(:all, :params => {:product_id => self.id})
273
- end
274
-
275
- def smart_collections
276
- SmartCollection.find(:all, :params => {:product_id => self.id})
277
- end
278
-
279
- def add_to_collection(collection)
280
- collection.add_product(self)
281
- end
282
-
283
- def remove_from_collection(collection)
284
- collection.remove_product(self)
285
- end
286
- end
287
-
288
- class Variant < Base
289
- self.prefix = "/admin/products/:product_id/"
290
- end
291
-
292
- class Image < Base
293
- self.prefix = "/admin/products/:product_id/"
294
-
295
- # generate a method for each possible image variant
296
- [:pico, :icon, :thumb, :small, :medium, :large, :original].each do |m|
297
- reg_exp_match = "/\\1_#{m}.\\2"
298
- define_method(m) { src.gsub(/\/(.*)\.(\w{2,4})/, reg_exp_match) }
299
- end
300
-
301
- def attach_image(data, filename = nil)
302
- attributes['attachment'] = Base64.encode64(data)
303
- attributes['filename'] = filename unless filename.nil?
304
- end
305
- end
306
-
307
- class Transaction < Base
308
- self.prefix = "/admin/orders/:order_id/"
309
- end
310
-
311
- class Fulfillment < Base
312
- self.prefix = "/admin/orders/:order_id/"
313
- end
314
-
315
- class Country < Base
316
- end
317
-
318
- class Page < Base
319
- end
320
-
321
- class Blog < Base
322
- def articles
323
- Article.find(:all, :params => { :blog_id => id })
324
- end
325
- end
326
-
327
- class Article < Base
328
- self.prefix = "/admin/blogs/:blog_id/"
329
- end
330
-
331
- class Metafield < Base
332
- self.prefix = "/admin/:resource/:resource_id/"
333
-
334
- # Hack to allow both Shop and other Metafields in through the same AR class
335
- def self.prefix(options={})
336
- options[:resource].nil? ? "/admin/" : "/admin/#{options[:resource]}/#{options[:resource_id]}/"
337
- end
338
-
339
- def value
340
- return if attributes["value"].nil?
341
- attributes["value_type"] == "integer" ? attributes["value"].to_i : attributes["value"]
342
- end
343
-
344
- end
345
-
346
- class Comment < Base
347
- def remove; load_attributes_from_response(post(:remove)); end
348
- def ham; load_attributes_from_response(post(:ham)); end
349
- def spam; load_attributes_from_response(post(:spam)); end
350
- def approve; load_attributes_from_response(post(:approve)); end
351
- end
352
-
353
- class Province < Base
354
- self.prefix = "/admin/countries/:country_id/"
355
- end
356
-
357
- class Redirect < Base
358
- end
359
-
360
- class Webhook < Base
361
- end
362
-
363
- # Assets represent the files that comprise your theme.
364
- # There are different buckets which hold different kinds
365
- # of assets, each corresponding to one of the folders
366
- # within a theme's zip file: layout, templates, and
367
- # assets. The full key of an asset always starts with the
368
- # bucket name, and the path separator is a forward slash,
369
- # like layout/theme.liquid or assets/bg-body.gif.
370
- #
371
- # Initialize with a key:
372
- # asset = ShopifyAPI::Asset.new(:key => 'assets/special.css')
373
- #
374
- # Find by key:
375
- # asset = ShopifyAPI::Asset.find('assets/image.png')
376
- #
377
- # Get the text or binary value:
378
- # asset.value # decodes from attachment attribute if necessary
379
- #
380
- # You can provide new data for assets in a few different ways:
381
- #
382
- # * assign text data for the value directly:
383
- # asset.value = "div.special {color:red;}"
384
- #
385
- # * provide binary data for the value:
386
- # asset.attach(File.read('image.png'))
387
- #
388
- # * set a URL from which Shopify will fetch the value:
389
- # asset.src = "http://mysite.com/image.png"
390
- #
391
- # * set a source key of another of your assets from which
392
- # the value will be copied:
393
- # asset.source_key = "assets/another_image.png"
394
- class Asset < Base
395
- self.primary_key = 'key'
396
-
397
- # find an asset by key:
398
- # ShopifyAPI::Asset.find('layout/theme.liquid')
399
- def self.find(*args)
400
- if args[0].is_a?(Symbol)
401
- super
402
- else
403
- find(:one, :from => "/admin/assets.xml", :params => {:asset => {:key => args[0]}})
404
- end
405
- end
406
-
407
- # For text assets, Shopify returns the data in the 'value' attribute.
408
- # For binary assets, the data is base-64-encoded and returned in the
409
- # 'attachment' attribute. This accessor returns the data in both cases.
410
- def value
411
- attributes['value'] ||
412
- (attributes['attachment'] ? Base64.decode64(attributes['attachment']) : nil)
413
- end
414
-
415
- def attach(data)
416
- self.attachment = Base64.encode64(data)
417
- end
418
-
419
- def destroy #:nodoc:
420
- connection.delete(element_path(:asset => {:key => key}), self.class.headers)
421
- end
422
-
423
- def new? #:nodoc:
424
- false
425
- end
426
-
427
- def self.element_path(id, prefix_options = {}, query_options = nil) #:nodoc:
428
- prefix_options, query_options = split_options(prefix_options) if query_options.nil?
429
- "#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
430
- end
431
-
432
- def method_missing(method_symbol, *arguments) #:nodoc:
433
- if %w{value= attachment= src= source_key=}.include?(method_symbol)
434
- wipe_value_attributes
435
- end
436
- super
437
- end
438
-
439
- private
440
-
441
- def wipe_value_attributes
442
- %w{value attachment src source_key}.each do |attr|
443
- attributes.delete(attr)
444
- end
445
- end
446
- end
447
-
448
- class RecurringApplicationCharge < Base
449
- def self.current
450
- find(:all).find{|charge| charge.status == 'active'}
451
- end
452
-
453
- def cancel
454
- load_attributes_from_response(self.destroy)
455
- end
456
-
457
- def activate
458
- load_attributes_from_response(post(:activate))
459
- end
460
- end
461
-
462
- class ApplicationCharge < Base
463
- def activate
464
- load_attributes_from_response(post(:activate))
465
- end
466
- end
467
-
468
- # Include Metafields module in all enabled classes
469
- METAFIELD_ENABLED_CLASSES.each do |klass|
470
- "ShopifyAPI::#{klass}".constantize.send(:include, Metafields)
471
- end
472
- end
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+
6
+ require "oj"
7
+ require "sorbet-runtime"
8
+ require "securerandom"
9
+ require "cgi"
10
+ require "uri"
11
+ require "openssl"
12
+ require "httparty"
13
+ require "zeitwerk"
14
+ require "jwt"
15
+ require "concurrent"
16
+
17
+ require_relative "shopify_api/inflector"
18
+ require_relative "shopify_api/admin_versions"
19
+
20
+ loader = Zeitwerk::Loader.for_gem
21
+ loader.inflector = ShopifyAPI::Inflector.new(__FILE__)
22
+ loader.ignore("#{__dir__}/shopify_api/rest/resources")
23
+ loader.setup
data/service.yml ADDED
@@ -0,0 +1 @@
1
+ audience: partner
@@ -0,0 +1 @@
1
+ # using the default shipit config
data/shopify_api.gemspec CHANGED
@@ -1,113 +1,54 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{shopify_api}
8
- s.version = "1.0.4"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tobias L\303\274tke", "Cody Fauser", "Dennis Theisen"]
12
- s.date = %q{2010-01-28}
13
- s.description = %q{= Shopify API
14
-
15
- The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores.
16
-
17
- The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we’ve tried to make the API follow the REST principles as much as possible.
18
-
19
-
20
- == Usage
21
-
22
- === Requirements
23
-
24
- All API usage happens through Shopify applications, created by either shop owners for their own shops, or by Shopify Partners for use by other shop owners:
25
-
26
- * Shop owners can create applications for themselves through their own admin (under the Preferences > Applications tab).
27
- * Shopify Partners create applications through their admin: http://app.shopify.com/services/partners
28
-
29
- For more information and detailed documentation about the API visit http://api.shopify.com
30
-
31
- === Getting Started
32
-
33
- ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveResource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps:
34
-
35
- 1. First create a new application in either the partners admin or your store admin and write down your API_KEY and SHARED_SECRET.
36
-
37
- 2. You will need to supply two parameters to the Session class before you instantiate it:
38
-
39
- ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET})
40
-
41
- 3. Create a new Session for a specific shop. That session is not fully valid yet, but it can be used to create a URL that you will redirect your users to:
3
+ $LOAD_PATH.push(File.expand_path("../lib", __FILE__))
4
+ require "shopify_api/version"
42
5
 
43
- session = ShopifyAPI::Session.new("yourshopname.myshopify.com")
44
- session.valid? # returns false
45
-
46
- 4. To access the API shop owners need a "token" from that specific shop. In order to get this token they need to authorize with that shop first. The URL to redirect your user to can be generated via:
47
-
48
- url = session.create_permission_url
49
-
50
- 5. After visiting this URL, the shop redirects the owner to a custom URL of your application where the "token" gets sent to (it's param name is just "t"). Use that token to instantiate a "valid" session, that is ready to make calls to that particular shop.
51
-
52
- token = params[:t]
53
- session = ShopifyAPI::Session.new("yourshopname.myshopify.com", token)
54
- session.valid? # returns true
55
-
56
- 6. Now you can finally get the fully authorized URL for that shop. Use that URL to configure ActiveResource and you're set:
57
-
58
- ActiveResource::Base.site = session.site
59
-
60
- 7. Get data from that shop (returns ActiveResource instances):
6
+ Gem::Specification.new do |s|
7
+ s.name = "shopify_api"
8
+ s.version = ShopifyAPI::VERSION
9
+ s.author = "Shopify"
61
10
 
62
- shop = ShopifyAPI::Shop.current
63
- latest_orders = ShopifyAPI::Order.find(:all)
11
+ s.summary = "The gem for accessing the Shopify API"
12
+ s.description = <<~HERE
13
+ This gem allows Ruby developers to programmatically access the admin
14
+ section of Shopify stores.
15
+ HERE
16
+ s.email = "developers@shopify.com"
17
+ s.homepage = "https://shopify.dev/apps"
64
18
 
65
- == Copyright
19
+ s.metadata["allowed_push_host"] = "https://rubygems.org"
66
20
 
67
- Copyright (c) 2009 "JadedPixel inc.". See LICENSE for details.
68
- }
69
- s.email = %q{developers@jadedpixel.com}
70
21
  s.extra_rdoc_files = [
71
22
  "LICENSE",
72
- "README.rdoc"
73
- ]
74
- s.files = [
75
- ".document",
76
- ".gitignore",
77
- "CHANGELOG",
78
- "LICENSE",
79
- "README.rdoc",
80
- "Rakefile",
81
- "VERSION",
82
- "lib/shopify_api.rb",
83
- "shopify_api.gemspec",
84
- "test/order_test.rb",
85
- "test/shopify_api_test.rb",
86
- "test/test_helper.rb"
87
- ]
88
- s.homepage = %q{http://github.com/Shopify/shopify_api}
89
- s.rdoc_options = ["--charset=UTF-8"]
90
- s.require_paths = ["lib"]
91
- s.rubyforge_project = %q{shopify-api}
92
- s.rubygems_version = %q{1.3.5}
93
- s.summary = %q{ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web services}
94
- s.test_files = [
95
- "test/order_test.rb",
96
- "test/shopify_api_test.rb",
97
- "test/test_helper.rb"
23
+ "README.md",
98
24
  ]
25
+ s.files = Dir.chdir(File.expand_path("..", __FILE__)) do
26
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test)/}) }
27
+ end
99
28
 
100
- if s.respond_to? :specification_version then
101
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
102
- s.specification_version = 3
29
+ s.rdoc_options = ["--charset=UTF-8"]
103
30
 
104
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
105
- s.add_runtime_dependency(%q<activeresource>, [">= 2.2.2"])
106
- else
107
- s.add_dependency(%q<activeresource>, [">= 2.2.2"])
108
- end
109
- else
110
- s.add_dependency(%q<activeresource>, [">= 2.2.2"])
111
- end
31
+ s.license = "MIT"
32
+
33
+ s.required_ruby_version = ">= 2.6"
34
+
35
+ s.add_runtime_dependency("activesupport")
36
+ s.add_runtime_dependency("concurrent-ruby")
37
+ s.add_runtime_dependency("hash_diff")
38
+ s.add_runtime_dependency("httparty")
39
+ s.add_runtime_dependency("jwt")
40
+ s.add_runtime_dependency("oj")
41
+ s.add_runtime_dependency("openssl")
42
+ s.add_runtime_dependency("securerandom")
43
+ s.add_runtime_dependency("sorbet-runtime")
44
+ s.add_runtime_dependency("zeitwerk", "~> 2.5", "< 2.6.5") # https://github.com/Shopify/shopify-api-ruby/issues/1058
45
+
46
+ s.add_development_dependency("pry-byebug")
47
+ s.add_development_dependency("rake")
48
+ s.add_development_dependency("rubocop")
49
+ s.add_development_dependency("rubocop-shopify")
50
+ s.add_development_dependency("rubocop-sorbet")
51
+ s.add_development_dependency("ruby-lsp")
52
+ s.add_development_dependency("sorbet")
53
+ s.add_development_dependency("tapioca")
112
54
  end
113
-
data/sorbet/config ADDED
@@ -0,0 +1,3 @@
1
+ --dir
2
+ .
3
+ --ignore=test/rest