aliyun_iot 0.1.4 → 0.2.0
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 +5 -5
- data/.gitignore +2 -0
- data/README.md +5 -5
- data/aliyun_iot.gemspec +1 -1
- data/lib/aliyun_iot.rb +1 -0
- data/lib/aliyun_iot/product.rb +25 -3
- data/lib/aliyun_iot/queue.rb +14 -0
- data/lib/aliyun_iot/request/json.rb +1 -1
- data/lib/aliyun_iot/topic.rb +2 -2
- data/lib/aliyun_iot/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e16402e9a3fed201eabae408ecc759c8eb3bd6f9172ff21b78350f4562ebc523
|
4
|
+
data.tar.gz: e678f1ce5ce8b2626f92923e7891b2548f18d6f59bda70e02c406fd07f3a3313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b5d843de5ec4bad7847bcf172dcccfaaee30ba2767cc5f66400a6b87d23101a301132235f939a2add82075973231ad935b9ac25e2fe1ad26b6325de26889d68
|
7
|
+
data.tar.gz: 681a0effe4703068d7647df68ec49d69d21f7585dc01df738491a91cbba91a5dd801a88b28ba12e65958b13071bddb8285cd5a4316543f44c8f1e028c1b2749e
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@ AliyunIot
|
|
3
3
|
|
4
4
|
AliyunIot gem 可以帮助开发者方便地在Rails环境中使用[阿里云物联网套件](https://help.aliyun.com/product/30520.html)提供的服务,包括
|
5
5
|
|
6
|
-
- [服务器端API](https://help.aliyun.com/document_detail/
|
6
|
+
- [服务器端API](https://help.aliyun.com/document_detail/69893.html)
|
7
7
|
- [消息服务](https://help.aliyun.com/product/27412.html)
|
8
8
|
|
9
9
|
## 安装
|
@@ -83,13 +83,13 @@ production:
|
|
83
83
|
|
84
84
|
```ruby
|
85
85
|
AliyunIot::Product.create(Name) ## 创建产品
|
86
|
-
AliyunIot::Product.batch_get_device_state({DeviceName.1, DeviceName.2 ....}) ## 批量查询设备状态
|
87
|
-
AliyunIot::Product.check_regist_state(ApplyId) ## 查询注册状态
|
88
|
-
AliyunIot::Product.list_regist_info(ApplyId, PageSize, CurrentPage) ## 批量查询注册状态
|
89
86
|
AliyunIot::Product[ProductKey].update({ProductName, ProductDesc}) ## 修改产品信息
|
90
87
|
AliyunIot::Product[ProductKey].list({PageSize, CurrentPage}) ## 查询产品的设备列表
|
91
88
|
AliyunIot::Product[ProductKey].regist_device({DeviceName}) ## 设备注册
|
92
|
-
AliyunIot::Product[ProductKey].
|
89
|
+
AliyunIot::Product[ProductKey].batch_check_device_names({DeviceName.1: 'ppp', DeviceName.2: 'abc'}) ## 批量注册的设备的名称
|
90
|
+
AliyunIot::Product[ProductKey].query_batch_register_status(apply_id) #查看名称设置结果
|
91
|
+
AliyunIot::Product[ProductKey].batch_register_device_with_apply_id(apply_id) #批量注册设备
|
92
|
+
AliyunIot::Product.query_page_by_apply_id(ApplyId, PageSize, CurrentPage) ## 查看批量注册的设备信息
|
93
93
|
AliyunIot::Product[ProductKey].pub({TopicFullName, MessageContent}) ## 发布消息到设备
|
94
94
|
AliyunIot::Product[ProductKey].rrpc({DeviceName, RequestBase64Byte, Timeout}) ## 发消息给设备并同步返回响应
|
95
95
|
```
|
data/aliyun_iot.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
33
|
spec.add_runtime_dependency 'activesupport', '>= 3.2', '<= 5.2'
|
34
|
-
spec.add_runtime_dependency 'nokogiri', '>=1.
|
34
|
+
spec.add_runtime_dependency 'nokogiri', '>= 1.10.4'
|
35
35
|
spec.add_runtime_dependency "rest-client", '>= 1.8.0'
|
36
36
|
spec.add_development_dependency "bundler", "~> 1.16"
|
37
37
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/aliyun_iot.rb
CHANGED
data/lib/aliyun_iot/product.rb
CHANGED
@@ -23,6 +23,11 @@ module AliyunIot
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def list_regist_info(apply_id, page_size, current_page)
|
26
|
+
warn "WARNING: Product.list_regist_info is deprecated. Please, use Product.query_page_by_apply_id instead"
|
27
|
+
query_page_by_apply_id(apply_id, page_size, current_page)
|
28
|
+
end
|
29
|
+
|
30
|
+
def query_page_by_apply_id(apply_id, page_size, current_page)
|
26
31
|
params = { ApplyId: apply_id, PageSize: page_size, CurrentPage: current_page }
|
27
32
|
execute params, 'QueryPageByApplyId'
|
28
33
|
end
|
@@ -45,11 +50,28 @@ module AliyunIot
|
|
45
50
|
end
|
46
51
|
|
47
52
|
def regist_device(params = {})
|
48
|
-
execute params, '
|
53
|
+
execute params, 'RegisterDevice'
|
54
|
+
end
|
55
|
+
|
56
|
+
def query_device_detail_by_name(device_name)
|
57
|
+
execute({DeviceName: device_name}, 'QueryDeviceDetail')
|
49
58
|
end
|
50
59
|
|
51
60
|
def regist_devices(params = {})
|
52
|
-
|
61
|
+
warn "WARNING: Product#regist_devices is deprecated. Please, use Product#batch_check_device_names instead"
|
62
|
+
batch_check_device_names params
|
63
|
+
end
|
64
|
+
|
65
|
+
def batch_check_device_names(params = {})
|
66
|
+
execute params, 'BatchCheckDeviceNames'
|
67
|
+
end
|
68
|
+
|
69
|
+
def batch_register_device_with_apply_id(apply_id)
|
70
|
+
execute({ApplyId: apply_id}, 'BatchRegisterDeviceWithApplyId')
|
71
|
+
end
|
72
|
+
|
73
|
+
def query_batch_register_status(apply_id)
|
74
|
+
execute({ApplyId: apply_id}, 'QueryBatchRegisterDeviceStatus')
|
53
75
|
end
|
54
76
|
|
55
77
|
def batch_get_device_state(params = {})
|
@@ -57,7 +79,7 @@ module AliyunIot
|
|
57
79
|
end
|
58
80
|
|
59
81
|
def pub(params = {})
|
60
|
-
raise
|
82
|
+
raise ParamsError, "message MessageContent is empty!" if params[:MessageContent].nil?
|
61
83
|
params[:MessageContent] = Base64.encode64(params[:MessageContent]).chomp
|
62
84
|
execute params, 'Pub'
|
63
85
|
end
|
data/lib/aliyun_iot/queue.rb
CHANGED
@@ -82,6 +82,20 @@ module AliyunIot
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
#批量消费消息
|
86
|
+
def batch_receive_message(num = 16, wait_seconds = 3)
|
87
|
+
result = Request::Xml.get(messages_path, query: {waitseconds: wait_seconds, numOfMessages: num})
|
88
|
+
return nil if result.nil?
|
89
|
+
Result.new(self, result, "Messages", "Message").get_message
|
90
|
+
end
|
91
|
+
|
92
|
+
#设置队列属性
|
93
|
+
def set_attr(opts = {})
|
94
|
+
Request::Xml.put(queue_path, query: {Metaoverride: true}) do |request|
|
95
|
+
request.content(:Queue, opts)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
85
99
|
def queue_path
|
86
100
|
"/queues/#{name}"
|
87
101
|
end
|
data/lib/aliyun_iot/topic.rb
CHANGED
@@ -58,7 +58,7 @@ module AliyunIot
|
|
58
58
|
#订阅topic
|
59
59
|
def subscribe(opts = {})
|
60
60
|
if opts[:Endpoint].nil? || opts[:Endpoint].blank?
|
61
|
-
raise
|
61
|
+
raise ParamsError, "subscribe parameters invalid"
|
62
62
|
else
|
63
63
|
Request::Xml.put(subscribe_path) do |request|
|
64
64
|
request.content(:Subscription, opts)
|
@@ -74,7 +74,7 @@ module AliyunIot
|
|
74
74
|
#发布消息
|
75
75
|
def publish_message(opts = {})
|
76
76
|
if opts[:MessageBody].nil? || opts[:MessageBody].blank?
|
77
|
-
raise
|
77
|
+
raise ParamsError, "publish message parameters invalid"
|
78
78
|
else
|
79
79
|
Request::Xml.post(message_path) do |request|
|
80
80
|
request.content(:Message, opts)
|
data/lib/aliyun_iot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyun_iot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CooCOccO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.
|
39
|
+
version: 1.10.4
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 1.10.4
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,8 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
|
-
|
155
|
-
rubygems_version: 2.6.12
|
154
|
+
rubygems_version: 3.0.4
|
156
155
|
signing_key:
|
157
156
|
specification_version: 4
|
158
157
|
summary: 阿里云物联网套件ruby sdk
|