Class: Xmpush::Service
- Inherits:
-
Object
- Object
- Xmpush::Service
- Defined in:
- lib/xmpush.rb
Instance Attribute Summary collapse
-
#android_secret ⇒ Object
Returns the value of attribute android_secret.
-
#bundle_id ⇒ Object
Returns the value of attribute bundle_id.
-
#connection_adapter ⇒ Object
Returns the value of attribute connection_adapter.
-
#ios_secret ⇒ Object
Returns the value of attribute ios_secret.
-
#package_name ⇒ Object
Returns the value of attribute package_name.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Class Method Summary collapse
Instance Method Summary collapse
- #build(build_type, message = {}) ⇒ Object
-
#initialize(ios_secret: "", android_secret: "", bundle_id: "", package_name: "", connection_adapter: :net_http, sandbox: false) ⇒ Service
constructor
A new instance of Service.
- #push(push_type, message, options = {}) ⇒ Object
Constructor Details
#initialize(ios_secret: "", android_secret: "", bundle_id: "", package_name: "", connection_adapter: :net_http, sandbox: false) ⇒ Service
Returns a new instance of Service.
18 19 20 21 22 23 24 25 |
# File 'lib/xmpush.rb', line 18 def initialize(ios_secret: "", android_secret: "", bundle_id: "", package_name: "", connection_adapter: :net_http, sandbox: false) @sandbox = sandbox @ios_secret = ios_secret @bundle_id = bundle_id @android_secret = android_secret @package_name = package_name @connection_adapter = connection_adapter end |
Instance Attribute Details
#android_secret ⇒ Object
Returns the value of attribute android_secret.
16 17 18 |
# File 'lib/xmpush.rb', line 16 def android_secret @android_secret end |
#bundle_id ⇒ Object
Returns the value of attribute bundle_id.
16 17 18 |
# File 'lib/xmpush.rb', line 16 def bundle_id @bundle_id end |
#connection_adapter ⇒ Object
Returns the value of attribute connection_adapter.
16 17 18 |
# File 'lib/xmpush.rb', line 16 def connection_adapter @connection_adapter end |
#ios_secret ⇒ Object
Returns the value of attribute ios_secret.
16 17 18 |
# File 'lib/xmpush.rb', line 16 def ios_secret @ios_secret end |
#package_name ⇒ Object
Returns the value of attribute package_name.
16 17 18 |
# File 'lib/xmpush.rb', line 16 def package_name @package_name end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
16 17 18 |
# File 'lib/xmpush.rb', line 16 def sandbox @sandbox end |
Class Method Details
.config {|service = new| ... } ⇒ Object
27 28 29 |
# File 'lib/xmpush.rb', line 27 def self.config yield service = new; service end |
Instance Method Details
#build(build_type, message = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/xmpush.rb', line 31 def build(build_type, ={}) case build_type when :ios = { ios: ios_builder()} when :android = { android: android_builder() } when :both = { ios: ios_builder(), android: android_builder()} end return end |
#push(push_type, message, options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/xmpush.rb', line 43 def push(push_type, , ={}) case push_type when :alias return "must input alias" unless [:alias] .values.each{|v| v.merge!(alias: [:alias])} resource_post('alias', ) when :regid return "must input regid" unless [:regid] .values.each{|v| v.merge!(regid: [:regid])} resource_post('regid', ) when :topic return "must input topic" unless [:topic] .values.each{|v| v.merge!(topic: [:topic])} resource_post('topic', ) when :topics return "must input topics" unless [:topics] .values.each{|v| v.merge!(topics: [:topics].join(";$;"), topic_op: [:topic_op] || "UNION")} resource_post('mtopic', ) when :all resource_post('all', ) end end |