You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/jobs/sync_user_forge_job.rb

33 lines
862 B

require 'uri'
require 'net/http'
class SyncUserForgeJob < ApplicationJob
queue_as :default
def perform(params)
Rails.logger.info("#######____sync_user_to_forge_start__########")
begin
api_host = EduSetting.get('sync_forge_url')
url = "#{api_host}/api/sync_forge"
sync_json = {
"sync_params": params
}
uri = URI.parse(url)
if api_host
http = Net::HTTP.new(uri.hostname, uri.port)
if api_host.include?("https://")
http.use_ssl = true
end
response = http.send_request('POST', uri.path, sync_json.to_json, {'Content-Type' => 'application/json'})
Rails.logger.info("#######_________response__sync__end_____#########{response.body}")
end
rescue => e
Rails.logger.info("#######____sync_user_to_forge_failed__########{e}")
end
end
end