Module: Outbound

Defined in:
lib/outbound.rb

Defined Under Namespace

Modules: Defaults Classes: Client, Result

Constant Summary collapse

VERSION =
'1.2.0'
BASE_URL =
'https://api.outbound.io/v2'
APNS =
"apns"
GCM =
"gcm"
ERROR_USER_ID =
"User ID must be a string or number."
ERROR_PREVIOUS_ID =
"Previous ID must be a string or number."
ERROR_EVENT_NAME =
"Event name must be a string."
ERROR_CONNECTION =
"Outbound connection error"
ERROR_INIT =
"Must call init() before identify() or track()."
ERROR_TOKEN =
"Token must be a string."
ERROR_PLATFORM =
"Unsupported platform specified."
ERROR_CAMPAIGN_IDS =
"At least one campaign ID is required."

Class Method Summary collapse

Class Method Details

.alias(user_id, previous_id) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/outbound.rb', line 39

def Outbound.alias(user_id, previous_id)
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.identify(user_id, previous_id)
end

.disable(platform, user_id, token) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/outbound.rb', line 66

def Outbound.disable(platform, user_id, token)
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.disable(platform, user_id, token)
end

.disable_all(platform, user_id) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/outbound.rb', line 75

def Outbound.disable_all(platform, user_id)
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.disable_all(platform, user_id)
end

.identify(user_id, info = {}) ⇒ Object



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

def Outbound.identify(user_id, info={})
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.identify(user_id, info)
end

.init(api_key, log_level = Logger::ERROR) ⇒ Object



34
35
36
37
# File 'lib/outbound.rb', line 34

def Outbound.init(api_key, log_level=Logger::ERROR)
  @logger.level = log_level
  @ob = Outbound::Client.new api_key, @logger
end

.register(platform, user_id, token) ⇒ Object



84
85
86
87
88
89
90
91
# File 'lib/outbound.rb', line 84

def Outbound.register(platform, user_id, token)
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.register(platform, user_id, token)
end

.subscribe(user_id, all = false, campaign_ids = nil) ⇒ Object



102
103
104
105
106
107
108
109
# File 'lib/outbound.rb', line 102

def Outbound.subscribe user_id, all=false, campaign_ids=nil
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.subscription user_id, false, all, campaign_ids
end

.track(user_id, event, properties = {}, timestamp = Time.now.to_i) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/outbound.rb', line 57

def Outbound.track(user_id, event, properties={}, timestamp=Time.now.to_i)
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.track(user_id, event, properties, timestamp)
end

.unsubscribe(user_id, all = false, campaign_ids = nil) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/outbound.rb', line 93

def Outbound.unsubscribe user_id, all=false, campaign_ids=nil
  if @ob == nil
    res = Result.new Outbound::ERROR_INIT, false
    @logger.error res.error
    return res
  end
  return @ob.subscription user_id, true, all, campaign_ids
end