ixintui 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ixintui.gemspec +15 -0
- data/lib/ixintui/android_service.rb +22 -0
- data/lib/ixintui/ios_service.rb +15 -0
- data/lib/ixintui/service.rb +47 -0
- data/lib/ixintui/version.rb +3 -0
- data/readme.md +31 -0
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccea250132bb0b0b1aee89c53b702bfc3c8c9746
|
|
4
|
+
data.tar.gz: 4a66f88386e216fd2442f53ee0a51b2f3130b3c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec5e11a86ea5bbce51ad6541263dcc1ebb6962b7dfbb03aaa4ff29a302fea90a6fe0b636ae012887d0696203b9a3d4abac1dff9f08f9a3e6dc41b7678d335f1a
|
|
7
|
+
data.tar.gz: 0df0108c24cc97ca55285645711231f5658e65983bfd1065b1ce4f39d10c8828882fb83ac8a6ca7bea961504e1b61618bff066adbee6e96a63deb10bb9591acf
|
data/ixintui.gemspec
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/ixintui/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Shawn Yu"]
|
|
6
|
+
gem.email = ["yu.chaong@gmail.com"]
|
|
7
|
+
gem.description = gem.summary = "ixintui(www.ixintui.com) push service"
|
|
8
|
+
gem.homepage = "https://github.com/baozoumanhua/ixintui"
|
|
9
|
+
gem.license = "LGPL-3.0"
|
|
10
|
+
gem.files = `git ls-files`.split("\n")
|
|
11
|
+
gem.name = "ixintui"
|
|
12
|
+
gem.require_paths = ["lib"]
|
|
13
|
+
gem.version = Ixintui::VERSION
|
|
14
|
+
gem.add_runtime_dependency 'rest-client'
|
|
15
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Ixintui
|
|
2
|
+
class AndroidService < Service
|
|
3
|
+
def self.server
|
|
4
|
+
'http://androidmis.ixintui.com:8001/push'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.app_key
|
|
8
|
+
Ixintui.options[:android_app_key]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.app_secret_key
|
|
12
|
+
Ixintui.options[:android_secret_key]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.base_data
|
|
16
|
+
super.merge({
|
|
17
|
+
click_action: 'open_app',
|
|
18
|
+
open_app: true
|
|
19
|
+
})
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Ixintui
|
|
2
|
+
class IosService < Service
|
|
3
|
+
def self.server
|
|
4
|
+
'http://iosmis.ixintui.com:8200/push'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.app_key
|
|
8
|
+
Ixintui.options[:ios_app_key]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.app_secret_key
|
|
12
|
+
Ixintui.options[:ios_secret_key]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Ixintui
|
|
2
|
+
class Service
|
|
3
|
+
def self.server
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def self.app_key
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.app_secret_key
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.base_data
|
|
13
|
+
{
|
|
14
|
+
appkey: app_key,
|
|
15
|
+
is_notif: 1
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.sign(params)
|
|
20
|
+
data = Hash[params.sort]
|
|
21
|
+
string = data.to_json
|
|
22
|
+
string += app_secret_key
|
|
23
|
+
Digest::MD5.hexdigest(string)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.validates(params)
|
|
27
|
+
case params[:click_action]
|
|
28
|
+
when 'open_app', 'open_url', 'intent'
|
|
29
|
+
raise ArgumentError, "设置了 click_action 参数为 '#{params[:click_action]}' 但是没有设置 #{params[:click_action]} 参数" if params[params[:click_action].to_sym].blank?
|
|
30
|
+
else
|
|
31
|
+
raise ArgumentError, "click_action 参数可选值为:'open_app', 'open_url', 'intent'"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
raise ArgumentError, "app_key 未设置" if params[:app_key].blank?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.push(options = {})
|
|
38
|
+
params = base_data.merge(options)
|
|
39
|
+
validates(params)
|
|
40
|
+
params[:sign] = sign(params)
|
|
41
|
+
|
|
42
|
+
puts params.inspect
|
|
43
|
+
res = RestClient.post(server, params.to_json, :content_type => :json)
|
|
44
|
+
res.body
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/readme.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## 爱心推送 Ruby SDK
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Step 1
|
|
5
|
+
|
|
6
|
+
Add ixintui to your gemfile
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
gem 'ixintui', '~> 1.0.0'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Step 2
|
|
13
|
+
|
|
14
|
+
Add ixintui config file to config/initializers
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
# config/initializers/ixintui.rb
|
|
18
|
+
# -*- encoding : utf-8 -*-
|
|
19
|
+
Ixintui.configure_keys do |config|
|
|
20
|
+
config.ios_key YOUR_IOS_APP_KEY, YOUR_IOS_SECRET_KEY
|
|
21
|
+
config.android_key YOUR_ANDROID_APP_KEY, YOUR_ANDROID_SECRET_KEY
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Push messages
|
|
26
|
+
```
|
|
27
|
+
Ixintui::IosService.push message: 'test'
|
|
28
|
+
Ixintui::AndroidService.push message: 'test'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Read [Document](http://www.ixintui.com/ddoc/doclist.php?f=3) for more information
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ixintui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shawn Yu
|
|
@@ -31,7 +31,13 @@ executables: []
|
|
|
31
31
|
extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
|
33
33
|
files:
|
|
34
|
+
- ixintui.gemspec
|
|
34
35
|
- lib/ixintui.rb
|
|
36
|
+
- lib/ixintui/android_service.rb
|
|
37
|
+
- lib/ixintui/ios_service.rb
|
|
38
|
+
- lib/ixintui/service.rb
|
|
39
|
+
- lib/ixintui/version.rb
|
|
40
|
+
- readme.md
|
|
35
41
|
homepage: https://github.com/baozoumanhua/ixintui
|
|
36
42
|
licenses:
|
|
37
43
|
- LGPL-3.0
|
|
@@ -52,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
52
58
|
version: '0'
|
|
53
59
|
requirements: []
|
|
54
60
|
rubyforge_project:
|
|
55
|
-
rubygems_version: 2.4.
|
|
61
|
+
rubygems_version: 2.4.4
|
|
56
62
|
signing_key:
|
|
57
63
|
specification_version: 4
|
|
58
64
|
summary: ixintui(www.ixintui.com) push service
|