Class: Roguelytics::ProcessJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/roguelytics/process_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(event, params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/roguelytics/process_job.rb', line 8

def perform(event,params)

	params[:sitekey] = ROGUELYTICS_SITEKEY

	url_base = "https://www.roguelytics.com"

	if event == 'create'
		url = "#{url_base}/api/v1/site_event/create.json"
	elsif event == 'update'
		url = "#{url_base}/api/v1/site_event/update.json"
	elsif event == 'delete'
		url = "#{url_base}/api/v1/site_event/delete.json"
	else
		raise "unknown event:#{event}"
		return
	end

	#begin
		uri 		= URI url
		uri.query 	= URI.encode_www_form(params)
		res 		= Net::HTTP.get_response(uri)
		puts res.body if res.is_a?(Net::HTTPSuccess)
	#rescue
	#end

	true
end