Class: JPush::Push::Audience

Inherits:
Object
  • Object
show all
Extended by:
Helper::ArgumentHelper
Defined in:
lib/jpush/push/audience.rb

Constant Summary

Constants included from Helper::ArgumentHelper

Helper::ArgumentHelper::MAX_ALIAS_ARRAY_SIZE, Helper::ArgumentHelper::MAX_MSG_IDS_ARRAY_SIZE, Helper::ArgumentHelper::MAX_REGISTRATION_ID_ARRAY_SIZE, Helper::ArgumentHelper::MAX_TAG_ARRAY_MAX_BYTESIZE, Helper::ArgumentHelper::MAX_TAG_ARRAY_SZIE

Constants included from Helper::Argument

Helper::Argument::MAX_ALIAS_BYTESIZE, Helper::Argument::MAX_TAG_BYTESIZE, Helper::Argument::MOBILE_RE

Instance Method Summary collapse

Methods included from Helper::ArgumentHelper

build_alias, build_extras, build_msg_ids, build_platform, build_registration_ids, build_tags, extended

Methods included from Helper::Argument

#check_alias, #check_mobile, #check_platform, #check_registration_id, #check_tag, #ensure_argument_not_blank, #ensure_argument_required, #ensure_not_over_bytesize, #ensure_not_over_size, #ensure_word_valid

Instance Method Details

#set_alias(alis) ⇒ Object



19
20
21
22
# File 'lib/jpush/push/audience.rb', line 19

def set_alias(alis)
  @alias = Audience.build_alias(alis)
  self
end

#set_registration_id(registration_ids) ⇒ Object



24
25
26
27
# File 'lib/jpush/push/audience.rb', line 24

def set_registration_id(registration_ids)
  @registration_id = Audience.build_registration_ids(registration_ids)
  self
end

#set_tag(tags) ⇒ Object



9
10
11
12
# File 'lib/jpush/push/audience.rb', line 9

def set_tag(tags)
  @tag = Audience.build_tags(tags, 20)
  self
end

#set_tag_and(tags) ⇒ Object



14
15
16
17
# File 'lib/jpush/push/audience.rb', line 14

def set_tag_and(tags)
  @tag_and = Audience.build_tags(tags, 20)
  self
end

#to_hashObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/jpush/push/audience.rb', line 29

def to_hash
  @audience = {
    tag: @tag,
    tag_and: @tag_and,
    alias: @alias,
    registration_id: @registration_id
  }.compact
  raise Utils::Exceptions::JPushError, 'Audience can not be empty.' if @audience.empty?
  @audience
end