Module: BrmClient::Event
- Included in:
- Logger
- Defined in:
- lib/brm_client/event.rb
Instance Method Summary collapse
- #action(type, context = nil, event_ref = "") ⇒ Object
- #connect(type, action, with_id, with_type, attributes = nil, context = nil, event_ref = "") ⇒ Object
- #create(resource_id, resource_type, resource_attributes = nil, context = nil, event_ref = "") ⇒ Object
- #delete(resource_id, resource_type, context = nil, event_ref = "") ⇒ Object
- #describe(type, resource, context = nil, event_ref = "") ⇒ Object
- #location(location_id = nil, location_type = "url", referrer_id = nil, referrer_type = "url", context = nil, event_ref = "") ⇒ Object
- #message(type, recipients, msg, context = nil, event_ref = "") ⇒ Object
- #register_event(service, step_name, step_num = 0, step_status = "success", complete = true, context = nil, event_ref = "") ⇒ Object
- #resource_event(type, resource_id, resource_type, attributes = nil, context = nil, event_ref = "") ⇒ Object
- #session_event(type, service_name, agent_id, agent_type, context, event_ref) ⇒ Object
- #session_expired(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
- #share(destination, resource_id, resource_type, context = nil, event_ref = "") ⇒ Object
- #sign_in(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
- #sign_in_failed(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
- #sign_out(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
- #sign_up(service, step_status = "success", context = nil, event_ref = "") ⇒ Object
- #system(type, msg = "", context = nil, event_ref = "") ⇒ Object
- #transaction(type, resources, from_id, from_type, context = nil, event_ref = "") ⇒ Object
- #unsubscribe(service, context = nil, event_ref = "") ⇒ Object
- #update(resource_id, resource_type, resource_attributes = nil, context = nil, event_ref = "") ⇒ Object
Instance Method Details
#action(type, context = nil, event_ref = "") ⇒ Object
4 5 6 |
# File 'lib/brm_client/event.rb', line 4 def action(type, context=nil, event_ref="") event "Action", { "type" => type }, context, event_ref end |
#connect(type, action, with_id, with_type, attributes = nil, context = nil, event_ref = "") ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/brm_client/event.rb', line 52 def connect(type, action, with_id, with_type, attributes=nil, context=nil, event_ref="") data = { "action" => action, "type" => type, "withAgent" => { "id" => with_id, "type" => with_type } } data["attributes"] = attributes if attributes; event("Connect", data, context, event_ref) end |
#create(resource_id, resource_type, resource_attributes = nil, context = nil, event_ref = "") ⇒ Object
30 31 32 |
# File 'lib/brm_client/event.rb', line 30 def create(resource_id, resource_type, resource_attributes=nil, context=nil, event_ref="") resource_event("create", resource_id, resource_type, resource_attributes || {}, context, event_ref) end |
#delete(resource_id, resource_type, context = nil, event_ref = "") ⇒ Object
38 39 40 |
# File 'lib/brm_client/event.rb', line 38 def delete(resource_id, resource_type, context=nil, event_ref="") resource_event("delete", resource_id, resource_type, {}, context, event_ref) end |
#describe(type, resource, context = nil, event_ref = "") ⇒ Object
76 77 78 |
# File 'lib/brm_client/event.rb', line 76 def describe(type, resource, context=nil, event_ref="") event("Describe", { "type" => type, "resource" => resource }, context, event_ref) end |
#location(location_id = nil, location_type = "url", referrer_id = nil, referrer_type = "url", context = nil, event_ref = "") ⇒ Object
24 25 26 27 28 |
# File 'lib/brm_client/event.rb', line 24 def location(location_id=nil, location_type="url", referrer_id=nil, referrer_type="url", context=nil, event_ref="") data = { "location" => { "type" => location_type, "id" => location_id } } data["referrer"] = { "id" => referrer_id, "type" => referrer_type } if referrer_id event("Location", data, context, event_ref) end |
#message(type, recipients, msg, context = nil, event_ref = "") ⇒ Object
47 48 49 50 |
# File 'lib/brm_client/event.rb', line 47 def (type, recipients, msg, context=nil, event_ref="") data = { "message" => msg, "recipients" => recipients, "type" => type } event("Message", data, context, event_ref) end |
#register_event(service, step_name, step_num = 0, step_status = "success", complete = true, context = nil, event_ref = "") ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/brm_client/event.rb', line 111 def register_event(service, step_name, step_num=0, step_status="success", complete=true, context=nil, event_ref="") data = { "service" => service, "step" => { "num" => step_num, "name" => step_name, "status" => step_status }, "complete" => complete } event("Register", data, context, event_ref) end |
#resource_event(type, resource_id, resource_type, attributes = nil, context = nil, event_ref = "") ⇒ Object
105 106 107 108 109 |
# File 'lib/brm_client/event.rb', line 105 def resource_event(type, resource_id, resource_type, attributes=nil, context=nil, event_ref="") resource = attributes || {} resource.update("id" => resource_id, "type" => resource_type) event "Resource", { "resource" => resource, "type" => type }, context, event_ref end |
#session_event(type, service_name, agent_id, agent_type, context, event_ref) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/brm_client/event.rb', line 89 def session_event(type, service_name, agent_id, agent_type, context, event_ref) if type != "start" user_id = nil facet_id = nil elsif agent_id if agent_type == "facet" facet_id = agent_id else user_id = agent_id end end event("Session", { "type" => type, "service" => service_name }, context, event_ref) end |
#session_expired(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
20 21 22 |
# File 'lib/brm_client/event.rb', line 20 def session_expired(service_name, agent_id=nil, agent_type=nil, context=nil, event_ref="") session_event("expired", service_name, agent_id, agent_type, context, event_ref) end |
#share(destination, resource_id, resource_type, context = nil, event_ref = "") ⇒ Object
42 43 44 45 |
# File 'lib/brm_client/event.rb', line 42 def share(destination, resource_id, resource_type, context=nil, event_ref="") resource = {"id" => resource_id, "type" => resource_type } event("Share", {"resource" => resource, "destination" => destination }, context, event_ref) end |
#sign_in(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
8 9 10 |
# File 'lib/brm_client/event.rb', line 8 def sign_in(service_name, agent_id=nil, agent_type=nil, context=nil, event_ref="") session_event("start", service_name, agent_id, agent_type, context, event_ref) end |
#sign_in_failed(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
16 17 18 |
# File 'lib/brm_client/event.rb', line 16 def sign_in_failed(service_name, agent_id=nil, agent_type=nil, context=nil, event_ref="") session_event("failed", service_name, agent_id, agent_type, context, event_ref) end |
#sign_out(service_name, agent_id = nil, agent_type = nil, context = nil, event_ref = "") ⇒ Object
12 13 14 |
# File 'lib/brm_client/event.rb', line 12 def sign_out(service_name, agent_id=nil, agent_type=nil, context=nil, event_ref="") session_event("end", service_name, agent_id, agent_type, context, event_ref) end |
#sign_up(service, step_status = "success", context = nil, event_ref = "") ⇒ Object
81 82 83 |
# File 'lib/brm_client/event.rb', line 81 def sign_up(service, step_status="success", context=nil, event_ref="") register_event(service, "register", 1, step_status, true, context, event_ref) end |
#system(type, msg = "", context = nil, event_ref = "") ⇒ Object
72 73 74 |
# File 'lib/brm_client/event.rb', line 72 def system(type, msg="", context=nil, event_ref="") event("System", { "type" => type, "message" => msg }, context, event_ref) end |
#transaction(type, resources, from_id, from_type, context = nil, event_ref = "") ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/brm_client/event.rb', line 62 def transaction(type, resources, from_id, from_type, context=nil, event_ref="") data = { "type" => type, "resources" => resources, "fromAgent" => { "id" => from_id, "type" => from_type } } event("Transaction", data, context, event_ref) end |
#unsubscribe(service, context = nil, event_ref = "") ⇒ Object
85 86 87 |
# File 'lib/brm_client/event.rb', line 85 def unsubscribe(service, context=nil, event_ref="") register_event(service, "unsubscribe", -1, "success", true, context, event_ref) end |
#update(resource_id, resource_type, resource_attributes = nil, context = nil, event_ref = "") ⇒ Object
34 35 36 |
# File 'lib/brm_client/event.rb', line 34 def update(resource_id, resource_type, resource_attributes=nil, context=nil, event_ref="") resource_event("update", resource_id, resource_type, resource_attributes || {}, context, event_ref) end |