From fc4aafb58a789a45df01d1c62477d5e4039cc95f Mon Sep 17 00:00:00 2001 From: zhangwt Date: Wed, 6 May 2015 14:20:46 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=B1=BB=E5=9E=8B=E5=92=8C=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=90=8E=E5=8F=8D=E9=A6=88=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=BD=AC=E6=8D=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xinge/android.rb | 4 ++-- lib/xinge/base.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/xinge/android.rb b/lib/xinge/android.rb index c484dc8..ea2de3f 100644 --- a/lib/xinge/android.rb +++ b/lib/xinge/android.rb @@ -7,8 +7,8 @@ def initialize(accessId = nil, secretKey = nil, options = {}) def pushToSingleDevice(token, title, content, params={}, custom_content={}) self.push_single_device(token, 1, build_simple_message(title, content, custom_content), params) end - def pushToAllDevice(title, content, params={}, custom_content={}) - self.push_all_device(1, build_simple_message(title, content, custom_content), params) + def pushToAllDevice(msg_type, title, content, params={}, custom_content={}) + self.push_all_device(msg_type, build_simple_message(title, content, custom_content), params) end protected diff --git a/lib/xinge/base.rb b/lib/xinge/base.rb index 15edfd8..e67688d 100644 --- a/lib/xinge/base.rb +++ b/lib/xinge/base.rb @@ -144,7 +144,7 @@ def send_request(type,method,params = {}) params.merge!({ sign: sign }) options = { body: params } - result = JSON.parse(self.class.send(HTTP_METHOD,self.get_request_url(type,method), options)) + result = JSON.parse(self.class.send(HTTP_METHOD,self.get_request_url(type,method), options).parsed_response) [result["ret_code"], result["err_msg"]] end From 36823680d85b604064b1f66b4a467d43f80ec246 Mon Sep 17 00:00:00 2001 From: zhangwt Date: Wed, 6 May 2015 15:31:59 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dinitializers=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xinge/base.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/xinge/base.rb b/lib/xinge/base.rb index e67688d..6a8d96e 100644 --- a/lib/xinge/base.rb +++ b/lib/xinge/base.rb @@ -25,6 +25,9 @@ class Base HTTP_METHOD = :post def initialize(accessId = nil, secretKey = nil, options = {}) + accessId ||= Xinge.config[:android_accessId] + secretKey ||= Xinge.config[:android_secretKey] + raise 'accessId is invalid' unless accessId.is_a? Integer raise 'secretKey is invalid' if !secretKey.is_a?(String) or secretKey.strip.size == 0 @accessId = accessId From 216e8c3316f7bab8a010d430dff087b2cc97cb2f Mon Sep 17 00:00:00 2001 From: zhangwt Date: Wed, 6 May 2015 16:15:05 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xinge/android.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/xinge/android.rb b/lib/xinge/android.rb index ea2de3f..c8a8702 100644 --- a/lib/xinge/android.rb +++ b/lib/xinge/android.rb @@ -4,11 +4,11 @@ class Android < Base def initialize(accessId = nil, secretKey = nil, options = {}) super end - def pushToSingleDevice(token, title, content, params={}, custom_content={}) - self.push_single_device(token, 1, build_simple_message(title, content, custom_content), params) + def pushToSingleDevice(token, msg_type, title, content, custom_content={}, params={}) + self.push_single_device(token, msg_type, build_simple_message(title, content, custom_content), params) end - def pushToAllDevice(msg_type, title, content, params={}, custom_content={}) - self.push_all_device(msg_type, build_simple_message(title, content, custom_content), params) + def pushToAllDevice(msg_type, msg_type, title, content, custom_content={}, params={}) + self.push_all_device(msg_type, msg_type, build_simple_message(title, content, custom_content), params) end protected From 270d7b46d88361baadf4b0b50f4982caafe18316 Mon Sep 17 00:00:00 2001 From: zhangwt Date: Wed, 6 May 2015 16:20:22 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xinge/android.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xinge/android.rb b/lib/xinge/android.rb index c8a8702..d58c9d8 100644 --- a/lib/xinge/android.rb +++ b/lib/xinge/android.rb @@ -8,7 +8,7 @@ def pushToSingleDevice(token, msg_type, title, content, custom_content={}, param self.push_single_device(token, msg_type, build_simple_message(title, content, custom_content), params) end def pushToAllDevice(msg_type, msg_type, title, content, custom_content={}, params={}) - self.push_all_device(msg_type, msg_type, build_simple_message(title, content, custom_content), params) + self.push_all_device(msg_type, build_simple_message(title, content, custom_content), params) end protected From fd34de5c9567a0ba7e67b3365ec825df6a653521 Mon Sep 17 00:00:00 2001 From: zhangwt Date: Wed, 6 May 2015 16:46:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=B9=A6=E5=86=99bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xinge/android.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xinge/android.rb b/lib/xinge/android.rb index d58c9d8..60aefd2 100644 --- a/lib/xinge/android.rb +++ b/lib/xinge/android.rb @@ -7,7 +7,7 @@ def initialize(accessId = nil, secretKey = nil, options = {}) def pushToSingleDevice(token, msg_type, title, content, custom_content={}, params={}) self.push_single_device(token, msg_type, build_simple_message(title, content, custom_content), params) end - def pushToAllDevice(msg_type, msg_type, title, content, custom_content={}, params={}) + def pushToAllDevice(msg_type, title, content, custom_content={}, params={}) self.push_all_device(msg_type, build_simple_message(title, content, custom_content), params) end