Module: Talkable

Defined in:
lib/talkable/api/share.rb,
lib/talkable.rb,
lib/talkable/api.rb,
lib/talkable/railtie.rb,
lib/talkable/version.rb,
lib/talkable/api/base.rb,
lib/talkable/api/offer.rb,
lib/talkable/referrals.rb,
lib/talkable/api/coupon.rb,
lib/talkable/api/metric.rb,
lib/talkable/api/origin.rb,
lib/talkable/api/person.rb,
lib/talkable/api/reward.rb,
lib/talkable/middleware.rb,
lib/talkable/api/visitor.rb,
lib/talkable/integration.rb,
lib/talkable/api/campaign.rb,
lib/talkable/api/referral.rb,
lib/talkable/configuration.rb,
lib/talkable/resources/offer.rb,
lib/talkable/resources/origin.rb,
lib/talkable/generators/install_generator.rb,
lib/talkable/generators/invite_standalone_generator.rb,
lib/talkable/generators/example_newsletter_signup_generator.rb

Overview

Defined Under Namespace

Modules: API, SharedGeneratorMethods Classes: Configuration, ExampleNewsletterSignupGenerator, InstallGenerator, InviteStandaloneGenerator, Middleware, Offer, Origin, Railtie

Constant Summary collapse

UUID =
'talkable_visitor_uuid'.freeze
CURRENT_URL =
'talkable_current_url'.freeze
VERSION =
"1.2.0"

Class Method Summary collapse

Class Method Details

.approve_referral(origin_slug) ⇒ Object



3
4
5
# File 'lib/talkable/referrals.rb', line 3

def approve_referral(origin_slug)
  update_referral(origin_slug, Talkable::API::Referral::APPROVED)
end

.configurationObject



21
22
23
# File 'lib/talkable.rb', line 21

def configuration
  @configuration ||= Talkable::Configuration.new
end

.configure(config = nil) {|configuration| ... } ⇒ Object

Yields:



16
17
18
19
# File 'lib/talkable.rb', line 16

def configure(config = nil)
  configuration.apply config if config
  yield(configuration) if block_given?
end

.current_urlObject



41
42
43
# File 'lib/talkable.rb', line 41

def current_url
  Thread.current[CURRENT_URL]
end

.current_url=(url) ⇒ Object



45
46
47
# File 'lib/talkable.rb', line 45

def current_url=(url)
  Thread.current[CURRENT_URL] = url
end

.find_or_generate_uuidObject



37
38
39
# File 'lib/talkable.rb', line 37

def find_or_generate_uuid
  visitor_uuid || SecureRandom.uuid
end

.register_affiliate_member(params = {}) ⇒ Object



3
4
5
# File 'lib/talkable/integration.rb', line 3

def register_affiliate_member(params = {})
  register_origin(Talkable::API::Origin::AFFILIATE_MEMBER, params)
end

.register_event(params = {}) ⇒ Object



11
12
13
# File 'lib/talkable/integration.rb', line 11

def register_event(params = {})
  register_origin(Talkable::API::Origin::EVENT, params)
end

.register_purchase(params = {}) ⇒ Object



7
8
9
# File 'lib/talkable/integration.rb', line 7

def register_purchase(params = {})
  register_origin(Talkable::API::Origin::PURCHASE, params)
end

.reset_configurationObject



25
26
27
# File 'lib/talkable.rb', line 25

def reset_configuration
  configuration.reset
end

.unblock_referral(origin_slug) ⇒ Object



11
12
13
# File 'lib/talkable/referrals.rb', line 11

def unblock_referral(origin_slug)
  update_referral(origin_slug, Talkable::API::Referral::UNBLOCKED)
end

.visitor_uuidObject



29
30
31
# File 'lib/talkable.rb', line 29

def visitor_uuid
  Thread.current[UUID]
end

.visitor_uuid=(uuid) ⇒ Object



33
34
35
# File 'lib/talkable.rb', line 33

def visitor_uuid=(uuid)
  Thread.current[UUID] = uuid
end

.void_referral(origin_slug) ⇒ Object



7
8
9
# File 'lib/talkable/referrals.rb', line 7

def void_referral(origin_slug)
  update_referral(origin_slug, Talkable::API::Referral::VOIDED)
end

.with_uuid_and_url(uuid, url) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/talkable.rb', line 49

def with_uuid_and_url(uuid, url)
  old_url, Talkable.current_url = Talkable.current_url, url
  old_uuid, Talkable.visitor_uuid = Talkable.visitor_uuid, uuid
  yield if block_given?
ensure
  Talkable.current_url = old_url
  Talkable.visitor_uuid = old_uuid
end