Class: IGeTui::BaseTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/igetui/template/base_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBaseTemplate

Returns a new instance of BaseTemplate.



5
6
7
8
# File 'lib/igetui/template/base_template.rb', line 5

def initialize
  @transmission_type = 0
  @transmission_content = ''
end

Instance Attribute Details

#push_infoObject

Returns the value of attribute push_info.



3
4
5
# File 'lib/igetui/template/base_template.rb', line 3

def push_info
  @push_info
end

#transmission_contentObject

Returns the value of attribute transmission_content.



3
4
5
# File 'lib/igetui/template/base_template.rb', line 3

def transmission_content
  @transmission_content
end

#transmission_typeObject

Returns the value of attribute transmission_type.



3
4
5
# File 'lib/igetui/template/base_template.rb', line 3

def transmission_type
  @transmission_type
end

Instance Method Details

#get_action_chainObject

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/igetui/template/base_template.rb', line 23

def get_action_chain
  raise NotImplementedError, 'Must be implemented by subtypes.'
end

#get_client_data(pusher) ⇒ Object



31
32
33
34
# File 'lib/igetui/template/base_template.rb', line 31

def get_client_data(pusher)
  string = self.get_transparent(pusher).serialize_to_string
  Base64.strict_encode64 string
end

#get_push_infoObject



36
37
38
# File 'lib/igetui/template/base_template.rb', line 36

def get_push_info
  @push_info || init_push_info
end

#get_push_typeObject

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/igetui/template/base_template.rb', line 27

def get_push_type
  raise NotImplementedError, 'Must be implemented by subtypes.'
end

#get_transparent(pusher) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/igetui/template/base_template.rb', line 10

def get_transparent(pusher)
  transparent = GtReq::Transparent.new
  transparent.id = ''
  transparent.messageId = ''
  transparent.taskId = ''
  transparent.action = 'pushmessage'
  transparent.actionChain = get_action_chain
  transparent.pushInfo = get_push_info
  transparent.appId = pusher.app_id
  transparent.appKey = pusher.app_key
  transparent
end

#set_push_info(action_loc_key, badge, message, sound, options = {}) ⇒ Object

NOTE: iOS Pusher need the top four fields of ‘push_info’ are required. options can be includes [:payload, :loc_key, :loc_args, :launch_image] docs.igetui.com/pages/viewpage.action?pageId=590588



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/igetui/template/base_template.rb', line 44

def set_push_info(action_loc_key, badge, message, sound, options = {})
  init_push_info
  @push_info.actionLocKey = action_loc_key
  @push_info.badge = badge.to_s
  @push_info.message = message
  @push_info.sound = sound
  @push_info.payload = options[:payload]
  @push_info.locKey = options[:loc_key]
  @push_info.locArgs = options[:loc_args]
  @push_info.launchImage = options[:launch_image]
  # validate method need refactoring.
  # Validate.new.validate(args)
end