Class: Umengo::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/umengo/params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, payload, body, extra, policy) ⇒ Params

Returns a new instance of Params.



5
6
7
8
9
10
11
# File 'lib/umengo/params.rb', line 5

def initialize(data, payload, body, extra, policy)
  @data    = data
  @payload = payload
  @body    = body || {}
  @extra   = extra || {}
  @policy  = policy || {}
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/umengo/params.rb', line 3

def body
  @body
end

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/umengo/params.rb', line 3

def data
  @data
end

#extraObject

Returns the value of attribute extra.



3
4
5
# File 'lib/umengo/params.rb', line 3

def extra
  @extra
end

#payloadObject

Returns the value of attribute payload.



3
4
5
# File 'lib/umengo/params.rb', line 3

def payload
  @payload
end

#policyObject

Returns the value of attribute policy.



3
4
5
# File 'lib/umengo/params.rb', line 3

def policy
  @policy
end

Instance Method Details

#build_androidObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/umengo/params.rb', line 21

def build_android
  check_require(data, [:appkey, :timestamp, :type])
  display_type = payload.fetch(:display_type, "notifcation")
  @data[:payload] = payload

  case display_type
  when "notifcation"
    check_require(body, [:ticker, :title, :text, :after_open])
  when "message"
    check_require(body, [:custom])
  end

  @data[:payload][:body] = body
  build_default_android!
end

#build_iosObject



13
14
15
16
17
18
19
# File 'lib/umengo/params.rb', line 13

def build_ios
  check_require(data, [:appkey, :timestamp, :type])
  @data[:payload] = payload
  check_require(body, [:alert])
  @data[:payload][:aps] = body
  build_default_ios!
end