Class: Umengo::Params
- Inherits:
-
Object
- Object
- Umengo::Params
- Defined in:
- lib/umengo/params.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#data ⇒ Object
Returns the value of attribute data.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#policy ⇒ Object
Returns the value of attribute policy.
Instance Method Summary collapse
- #build_android ⇒ Object
- #build_ios ⇒ Object
-
#initialize(data, payload, body, extra, policy) ⇒ Params
constructor
A new instance of Params.
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
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/umengo/params.rb', line 3 def body @body end |
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/umengo/params.rb', line 3 def data @data end |
#extra ⇒ Object
Returns the value of attribute extra.
3 4 5 |
# File 'lib/umengo/params.rb', line 3 def extra @extra end |
#payload ⇒ Object
Returns the value of attribute payload.
3 4 5 |
# File 'lib/umengo/params.rb', line 3 def payload @payload end |
#policy ⇒ Object
Returns the value of attribute policy.
3 4 5 |
# File 'lib/umengo/params.rb', line 3 def policy @policy end |
Instance Method Details
#build_android ⇒ Object
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_ios ⇒ Object
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 |