dawarich/app/jobs/users/trial_webhook_job.rb

31 lines
722 B
Ruby
Raw Normal View History

2025-08-13 14:25:48 -04:00
# frozen_string_literal: true
class Users::TrialWebhookJob < ApplicationJob
queue_as :default
def perform(user_id)
user = User.find(user_id)
2026-01-08 15:12:47 -05:00
# Skip webhook for soft-deleted users
return if user.deleted?
payload = {
user_id: user.id,
email: user.email,
active_until: user.active_until,
2025-08-19 12:29:34 -04:00
status: user.status,
action: 'create_user'
}
token = Subscription::EncodeJwtToken.new(payload, ENV['JWT_SECRET_KEY']).call
2025-08-13 14:25:48 -04:00
request_url = "#{ENV['MANAGER_URL']}/api/v1/users"
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
HTTParty.post(request_url, headers: headers, body: { token: token }.to_json)
end
end