mobpush 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f679e4532f0123955d248a9333731bc47df5a459a24cb5cd9432af753c4fa06
4
- data.tar.gz: 7a7dc462d3a630a9cb104b0a63bab29c3c8b47008dfa0d1b785cf9f0a85f5b0f
3
+ metadata.gz: 56834e1fb803624c33e66c7a04cce9af46a326b93b8af7db01c7ace9019cf334
4
+ data.tar.gz: e80a315736eaded5b5b5e92195e8ac26df3f65ba1300918a14c0868059480541
5
5
  SHA512:
6
- metadata.gz: ad741170847eb814c89a143fe079ddfe649e67981090fb269b517f63d340952c65f4a5993f6f08cc29d40de890e0072dd7de79733cbd96da8a4f15e0196cbe90
7
- data.tar.gz: 8e6a3f7d622abd8365e2d0b1c2ab2738dff3419ff3ca8d52ea9fb58d0b262a33891a6398c151b2ea72d13a0e9ecc66f9ced8484c9cd292201284ed9408504f88
6
+ metadata.gz: 538e771d77570e94544228e8deccefdfa724153b7024093f879bea5aa43095a12870434715f5305d1c90a5ebc0a486cefd297f63d4a20be6ae59dc076f4ad2d4
7
+ data.tar.gz: 950ef7d475e5c23d03ede1f56bc59ec87d50fc59cd2d54bfbde6689e10f2329df2fed25b31b4fec9ba9f9fa90f11249e5744b7f12b7a868b80933758cd3d0d57
@@ -2,4 +2,5 @@
2
2
 
3
3
  require 'mobpush/client/push/push_v3_client'
4
4
  require 'mobpush/client/stat/stats_v3_client'
5
+ require 'mobpush/client/device/device_v3_client'
5
6
  require 'mobpush/config/mobpush_config'
@@ -0,0 +1,52 @@
1
+ # coding: utf-8
2
+
3
+ require "mobpush/config/mobpush_config"
4
+ require "mobpush/http/mob_http"
5
+
6
+ class DeviceV3Client
7
+ @GET_BY_RID = "/device-v3/getById/"
8
+ @GET_DEVICE_DISTRIBUTION = "/device-v3/distribution/"
9
+ @GET_BY_ALIAS = "/device-v3/getByAlias/"
10
+ @UPDATE_ALIAS = "/device-v3/updateAlias/"
11
+ @UPDATE_TAGS = "/device-v3/updateTags"
12
+ @QUERY_BY_TAGS = "/device-v3/queryByTags"
13
+
14
+ class << self
15
+ attr_accessor :GET_BY_RID, :GET_DEVICE_DISTRIBUTION, :GET_BY_ALIAS, :UPDATE_ALIAS, :UPDATE_TAGS, :QUERY_BY_TAGS
16
+ end
17
+
18
+ def getByRid(registrationId)
19
+ params = {:registrationId => registrationId}
20
+ url = MobPushConfig.baseUrl + DeviceV3Client.GET_BY_RID + registrationId
21
+ MobHTTP.get(url, nil, params)
22
+ end
23
+
24
+ def getDeviceDistribution()
25
+ url = MobPushConfig.baseUrl + DeviceV3Client.GET_DEVICE_DISTRIBUTION
26
+ MobHTTP.get(url, nil, {})
27
+ end
28
+
29
+ def queryByAlias(_alias)
30
+ params = {:alias => _alias}
31
+ url = MobPushConfig.baseUrl + DeviceV3Client.GET_BY_ALIAS + _alias
32
+ MobHTTP.get(url, nil, params)
33
+ end
34
+
35
+ def updateAlias(_alias, registrationId)
36
+ params = {:alias => _alias, :registrationId => registrationId}
37
+ url = MobPushConfig.baseUrl + DeviceV3Client.UPDATE_ALIAS
38
+ MobHTTP.post(url, nil, params)
39
+ end
40
+
41
+ def updateTags(tags, registrationId, opType)
42
+ params = {:tags => tags, :registrationId => registrationId, :opType => opType}
43
+ url = MobPushConfig.baseUrl + DeviceV3Client.UPDATE_TAGS
44
+ MobHTTP.post(url, nil, params)
45
+ end
46
+
47
+ def queryByTags(tags)
48
+ params = {:tags => tags}
49
+ url = MobPushConfig.baseUrl + DeviceV3Client.QUERY_BY_TAGS
50
+ MobHTTP.post(url, nil, params)
51
+ end
52
+ end
@@ -11,9 +11,10 @@ class PushV3Client
11
11
  @CANCEL_TASK_URI = "/push/drop"
12
12
  @REPLACE_TASK_URI = "/push/replace"
13
13
  @RECALL_TASK_URI = "/push/recall"
14
+ @PUSH_MULTI = "/v3/push/createMulti"
14
15
 
15
16
  class << self
16
- attr_accessor :PUSH_URI, :GET_BY_WORKID_URI, :GET_BY_WORKNO_URI, :CANCEL_TASK_URI, :REPLACE_TASK_URI, :RECALL_TASK_URI
17
+ attr_accessor :PUSH_URI, :GET_BY_WORKID_URI, :GET_BY_WORKNO_URI, :CANCEL_TASK_URI, :REPLACE_TASK_URI, :RECALL_TASK_URI, :PUSH_MULTI
17
18
  end
18
19
 
19
20
 
@@ -72,4 +73,8 @@ class PushV3Client
72
73
  params = {:workno => workno}
73
74
  MobHTTP.post(MobPushConfig.baseUrl + PushV3Client.GET_BY_WORKNO_URI, nil, params)
74
75
  end
76
+
77
+ def pushMulti(pushMulti)
78
+ MobHTTP.post(MobPushConfig.baseUrl + PushV3Client.PUSH_MULTI, nil, pushMulti)
79
+ end
75
80
  end
@@ -8,7 +8,7 @@ class PushWorkBuilder
8
8
  @push = OpenStruct.new(workno: workno, source: 'webapi')
9
9
  @push.pushTarget = OpenStruct.new(tagsType: 1)
10
10
  @push.pushNotify = OpenStruct.new(title: title, content: content, taskCron: 0,
11
- plats: [1, 2], iosProduction: 1, offlineSeconds: 3600, type: 1)
11
+ plats: [1, 2], iosProduction: 1, offlineSeconds: 3600, type: 1, speed: 1)
12
12
  @push.pushOperator = OpenStruct.new()
13
13
  end
14
14
 
@@ -42,6 +42,32 @@ module MobHTTP
42
42
  result
43
43
  end
44
44
 
45
+ def get(url, headers = nil, data)
46
+ uri = URI(url)
47
+ data["appkey"] = MobPushConfig.appkey
48
+
49
+ headers = headers.nil? ? {} : headers
50
+ headers["sign"] = serverSign(data.to_json, MobPushConfig.appSecret)
51
+ headers["key"] = MobPushConfig.appkey
52
+
53
+ req = Net::HTTP::Get.new(uri, headers)
54
+ req.body = data.to_json
55
+ resp = Net::HTTP.start(uri.hostname, uri.port, :read_timeout => 10, :open_timeout => 10, :write_timeout => 10) do |http|
56
+ http.request(req)
57
+ end
58
+
59
+ result = MobHttp::Result.new()
60
+ result.responseCode = resp.code.to_i
61
+ if resp.code.to_i == MobHttp::Result::SUCCESS
62
+ result.status = MobHttp::Result::SUCCESS
63
+ result.res = hash2os(JSON.parse(resp.body)['res'])
64
+ else
65
+ result.status = MobHttp::Result::ERROR
66
+ result.error = JSON.parse(resp.body)['error']
67
+ end
68
+ result
69
+ end
70
+
45
71
  def serverSign(data, secret)
46
72
  Digest::MD5.hexdigest(data + secret)
47
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mobtech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,6 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/mobpush.rb
20
+ - lib/mobpush/client/device/device_v3_client.rb
20
21
  - lib/mobpush/client/push/push_v3_client.rb
21
22
  - lib/mobpush/client/push/push_work_builder.rb
22
23
  - lib/mobpush/client/stat/stats_v3_client.rb