我正在用 rails 制作一个 Shopify 应用程序,我有这个:
webhooks_controller.rb
module ShopifyApp
class WebhooksController < ActionController::Base
include ShopifyApp::WebhookVerification
class ShopifyApp::MissingWebhookJobError < StandardError; end
def receive
params.try(:permit!)
job_args = {shop_domain: shop_domain, webhook: webhook_params.to_h}
webhook_job_klass.perform_later(job_args)
head :no_content
end
private
def webhook_params
params.except(:controller, :action, :type)
end
def webhook_job_klass
"#{webhook_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError
end
def webhook_type
params[:type]
end
end
end
orders_create_job.rb
class OrdersCreateJob < ActiveJob::Base
def perform(shop_domain:, webhook:)
shop = Shop.find_by(shopify_domain: shop_domain)
shop.with_shopify_session do
#DATA GOES HERE
end
end
end
是否可以在“#DATA GOES HERE”中获取 webhook 的变量,例如“shipping_lines”的“标题”?
我怎样才能做到这一点?