aliyun_iot 0.1.4 → 0.2.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
- SHA1:
3
- metadata.gz: b77eea144b0719d2d909bf02bf10fb08c3bfa6e6
4
- data.tar.gz: 2b0450faec422ce648dbd016d5656cc1167545ef
2
+ SHA256:
3
+ metadata.gz: e16402e9a3fed201eabae408ecc759c8eb3bd6f9172ff21b78350f4562ebc523
4
+ data.tar.gz: e678f1ce5ce8b2626f92923e7891b2548f18d6f59bda70e02c406fd07f3a3313
5
5
  SHA512:
6
- metadata.gz: 2ecde67ef1d5385fa84b19be5d14e6100a00d921ab9bc67959a9dcb84dd5a3744f3b7270eb3f9c34ed7189017b167f33fe3ad5a1d6562e28d1082257fcbef720
7
- data.tar.gz: 98f5eccf02d8dc2edc26c8bb657aca565294229b774a8b7ba33c1dcdd2f204112c074165b799648124a8214eeda128e34cc85f62d13c549cf6127031f8b395b5
6
+ metadata.gz: 1b5d843de5ec4bad7847bcf172dcccfaaee30ba2767cc5f66400a6b87d23101a301132235f939a2add82075973231ad935b9ac25e2fe1ad26b6325de26889d68
7
+ data.tar.gz: 681a0effe4703068d7647df68ec49d69d21f7585dc01df738491a91cbba91a5dd801a88b28ba12e65958b13071bddb8285cd5a4316543f44c8f1e028c1b2749e
data/.gitignore CHANGED
@@ -10,3 +10,5 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  .gem
13
+ .idea
14
+ .idea/.rakeTasks
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/30557.html)
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].regist_devices({DeviceName.1, DeviceName.2 ....}) ## 批量注册设备
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
  ```
@@ -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.6.0'
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"
@@ -23,6 +23,7 @@ class Hash
23
23
  end
24
24
  end
25
25
  module AliyunIot
26
+ class ParamsError < StandardError; end
26
27
 
27
28
  class << self
28
29
  def configuration
@@ -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, 'RegistDevice'
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
- execute params, 'ApplyDeviceWithNames'
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 RequestException.new(Exception.new("message MessageContent is empty!")) if params[:MessageContent].nil?
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
@@ -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
@@ -28,7 +28,7 @@ module AliyunIot
28
28
  ts = Time.now.utc.strftime('%FT%TZ')
29
29
  base_params = {
30
30
  Format: 'JSON',
31
- Version: '2017-04-20',
31
+ Version: '2018-01-20',
32
32
  AccessKeyId: access_key_id,
33
33
  SignatureMethod: 'HMAC-SHA1',
34
34
  Timestamp: ts,
@@ -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 Request::XmlException.new(Exception.new("subscribe parameters invalid"))
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 Exception.new("publish message parameters invalid")
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)
@@ -1,3 +1,3 @@
1
1
  module AliyunIot
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.4
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: 2018-06-08 00:00:00.000000000 Z
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.6.0
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.6.0
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
- rubyforge_project:
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