Module: Urbanairship::Push::Audience

Includes:
Common
Included in:
Urbanairship
Defined in:
lib/urbanairship/push/audience.rb

Constant Summary collapse

UUID_PATTERN =
/^\h{8}-\h{4}-\h{4}-\h{4}-\h{12}$/
DEVICE_TOKEN_PATTERN =
/^\h{64}$/
DATE_TERMS =
%i(minutes hours days weeks months years)

Constants included from Common

Common::CONTENT_TYPE

Instance Method Summary collapse

Methods included from Common

#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper

Instance Method Details

#alias(an_alias) ⇒ Object

Select a single alias



40
41
42
# File 'lib/urbanairship/push/audience.rb', line 40

def alias(an_alias)
  { alias: an_alias }
end

#and(*children) ⇒ Object

Select devices that match all of the given selectors.

Examples:

and(tag('sports'), tag('business')) # ==>
  {and: [{tag: 'sports'}, {tag: 'business'}]}


68
69
70
# File 'lib/urbanairship/push/audience.rb', line 68

def and(*children)
  { and: children }
end

#device_token(token) ⇒ Object

Select a single iOS device token



27
28
29
30
# File 'lib/urbanairship/push/audience.rb', line 27

def device_token(token)
  Util.validate(token, 'device_token', DEVICE_TOKEN_PATTERN)
  { device_token: token.upcase.strip }
end

#named_user(named_user) ⇒ Object

Select a single named user



50
51
52
# File 'lib/urbanairship/push/audience.rb', line 50

def named_user(named_user)
  { named_user: named_user }
end

#not(child) ⇒ Object

Select devices that do not match the given selectors.

Examples:

not(and_(tag('sports'), tag('business'))) # ==>
  {not: {and: [{tag: 'sports'}, {tag: 'business'}]}}


77
78
79
# File 'lib/urbanairship/push/audience.rb', line 77

def not(child)
  { not: child }
end

#or(*children) ⇒ Object

Select devices that match at least one of the given selectors.

Examples:

or(tag('sports'), tag('business')) # ==>
  {or: [{tag: 'sports'}, {tag: 'business'}]}


59
60
61
# File 'lib/urbanairship/push/audience.rb', line 59

def or(*children)
  { or: children }
end

#segment(segment) ⇒ Object

Select a single segment using segment_id



45
46
47
# File 'lib/urbanairship/push/audience.rb', line 45

def segment(segment)
  { segment: segment }
end

#tag(tag, group: nil) ⇒ Object

Select a single tag



33
34
35
36
37
# File 'lib/urbanairship/push/audience.rb', line 33

def tag(tag, group: nil)
  tag_params = { tag: tag }
  tag_params[:group] = group unless group.nil?
  tag_params
end