Module: Kontagent
- Defined in:
- lib/kontagent.rb
Constant Summary collapse
- PARAMS_MAP =
{ :uid => :s, :birth_year => :b, :sex => [:g, :escape], :city => [:ly, :escape], :country => [:lc, :escape], :zip => [:lp, :escape], :state => [:ls, :escape], :friend_count => :f, :short_tag => :su, :tag => :u, :channel => :tu, :link_type => :tu, :st1 => [:st1, :escape], :st2 => [:st2, :escape], :st3 => [:st3, :escape], :responder_uid => :r, :recipient_uids => [:r, :escape], :existing_install? => :i, :timestamp => :ts, }
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.api_url ⇒ Object
Returns the value of attribute api_url.
Class Method Summary collapse
- .application_added(options = {}) ⇒ Object
- .application_removed(options = {}) ⇒ Object
- .base_url ⇒ Object
- .build_url(method, options = {}) ⇒ Object
- .configuration=(options) ⇒ Object
- .create_short_tag ⇒ Object
- .create_tracking_tag ⇒ Object
- .get_page_request_url(options = {}) ⇒ Object
- .track_invite(options = {}) ⇒ Object
- .track_invite_response(options = {}) ⇒ Object
- .track_link(options) ⇒ Object
- .track_post(options = {}) ⇒ Object
- .track_post_response(options = {}) ⇒ Object
- .track_user(options = {}) ⇒ Object
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
30 31 32 |
# File 'lib/kontagent.rb', line 30 def api_key @api_key end |
.api_url ⇒ Object
Returns the value of attribute api_url.
30 31 32 |
# File 'lib/kontagent.rb', line 30 def api_url @api_url end |
Class Method Details
.application_added(options = {}) ⇒ Object
63 64 65 66 |
# File 'lib/kontagent.rb', line 63 def self.application_added( = {}) (, :uid) call_method("apa", ) end |
.application_removed(options = {}) ⇒ Object
68 69 70 71 |
# File 'lib/kontagent.rb', line 68 def self.application_removed( = {}) (, :uid) call_method("apr", ) end |
.base_url ⇒ Object
46 47 48 |
# File 'lib/kontagent.rb', line 46 def self.base_url File.join(api_url, api_key) end |
.build_url(method, options = {}) ⇒ Object
110 111 112 |
# File 'lib/kontagent.rb', line 110 def self.build_url(method, = {}) File.join(self.base_url, method, "?#{kontagent_params()}") end |
.configuration=(options) ⇒ Object
41 42 43 44 |
# File 'lib/kontagent.rb', line 41 def self.configuration=() self.api_url = [:api_url] self.api_key = [:api_key] end |
.create_short_tag ⇒ Object
59 60 61 |
# File 'lib/kontagent.rb', line 59 def self.create_short_tag create_tracking_tag end |
.create_tracking_tag ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/kontagent.rb', line 50 def self.create_tracking_tag tag = UUIDTools::UUID.random_create.to_s.gsub("-", "") if block_given? yield tag else tag end end |
.get_page_request_url(options = {}) ⇒ Object
73 74 75 76 77 |
# File 'lib/kontagent.rb', line 73 def self.get_page_request_url( = {}) (, :uid) [:timestamp] ||= Time.now.strftime("%Y-%m-%dT%H:%M:%S") build_url("pgr", ) end |
.track_invite(options = {}) ⇒ Object
98 99 100 101 102 |
# File 'lib/kontagent.rb', line 98 def self.track_invite( = {}) (, :uid, :tag, :recipient_uids) [:recipient_uids] = [:recipient_uids].join(",") call_method("ins", ) end |
.track_invite_response(options = {}) ⇒ Object
104 105 106 107 108 |
# File 'lib/kontagent.rb', line 104 def self.track_invite_response( = {}) (, :tag, :existing_install?) [:existing_install?] = [:existing_install?] && 1 || 0 call_method("inr", ) end |
.track_link(options) ⇒ Object
114 115 116 117 118 |
# File 'lib/kontagent.rb', line 114 def self.track_link() (, :link_type, :existing_install?, :short_tag) [:existing_install?] = [:existing_install?] ? 1 : 0 call_method("ucc", ) end |
.track_post(options = {}) ⇒ Object
85 86 87 88 89 |
# File 'lib/kontagent.rb', line 85 def self.track_post( = {}) (, :uid, :tag, :channel) assert_channel([:channel]) call_method("pst", ) end |
.track_post_response(options = {}) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/kontagent.rb', line 91 def self.track_post_response( = {}) (, :tag, :channel, :existing_install?) assert_channel([:channel]) [:existing_install?] = [:existing_install?] && 1 || 0 call_method("psr", ) end |
.track_user(options = {}) ⇒ Object
79 80 81 82 83 |
# File 'lib/kontagent.rb', line 79 def self.track_user( = {}) (, :uid) [:sex] = [:sex].to_s[0,1] call_method("cpu", ) end |