Class: DeviceCloud::Monitor
- Inherits:
-
Object
- Object
- DeviceCloud::Monitor
- Defined in:
- lib/device_cloud/monitor.rb
Constant Summary collapse
- DEFAULT_CREATE_OPTIONS =
{ 'monTransportType' => 'http', 'monTransportUrl' => "http://www.example.com/push_notifications", 'monTransportToken' => "USERNAME:PASSWORD", 'monFormatType' => 'json', 'monBatchSize' => '1', 'monCompression' => 'none', 'monBatchDuration' => '0', 'monAutoReplayOnConnect' => 'true' }
Instance Attribute Summary collapse
-
#cstId ⇒ Object
Returns the value of attribute cstId.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#monAutoReplayOnConnect ⇒ Object
Returns the value of attribute monAutoReplayOnConnect.
-
#monBatchDuration ⇒ Object
Returns the value of attribute monBatchDuration.
-
#monBatchSize ⇒ Object
Returns the value of attribute monBatchSize.
-
#monCompression ⇒ Object
Returns the value of attribute monCompression.
-
#monFormatType ⇒ Object
Returns the value of attribute monFormatType.
-
#monId ⇒ Object
Returns the value of attribute monId.
-
#monLastConnect ⇒ Object
Returns the value of attribute monLastConnect.
-
#monLastSent ⇒ Object
Returns the value of attribute monLastSent.
-
#monLastSentUuid ⇒ Object
Returns the value of attribute monLastSentUuid.
-
#monStatus ⇒ Object
Returns the value of attribute monStatus.
-
#monTopic ⇒ Object
Returns the value of attribute monTopic.
-
#monTransportToken ⇒ Object
Returns the value of attribute monTransportToken.
-
#monTransportType ⇒ Object
Returns the value of attribute monTransportType.
-
#monTransportUrl ⇒ Object
Returns the value of attribute monTransportUrl.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #destroy! ⇒ Object
-
#initialize(attributes = {}) ⇒ Monitor
constructor
A new instance of Monitor.
- #persist! ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Monitor
Returns a new instance of Monitor.
37 38 39 40 41 42 43 44 45 |
# File 'lib/device_cloud/monitor.rb', line 37 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end @error = nil set_defaults end |
Instance Attribute Details
#cstId ⇒ Object
Returns the value of attribute cstId.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def cstId @cstId end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/device_cloud/monitor.rb', line 4 def error @error end |
#monAutoReplayOnConnect ⇒ Object
Returns the value of attribute monAutoReplayOnConnect.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monAutoReplayOnConnect @monAutoReplayOnConnect end |
#monBatchDuration ⇒ Object
Returns the value of attribute monBatchDuration.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monBatchDuration @monBatchDuration end |
#monBatchSize ⇒ Object
Returns the value of attribute monBatchSize.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monBatchSize @monBatchSize end |
#monCompression ⇒ Object
Returns the value of attribute monCompression.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monCompression @monCompression end |
#monFormatType ⇒ Object
Returns the value of attribute monFormatType.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monFormatType @monFormatType end |
#monId ⇒ Object
Returns the value of attribute monId.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monId @monId end |
#monLastConnect ⇒ Object
Returns the value of attribute monLastConnect.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monLastConnect @monLastConnect end |
#monLastSent ⇒ Object
Returns the value of attribute monLastSent.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monLastSent @monLastSent end |
#monLastSentUuid ⇒ Object
Returns the value of attribute monLastSentUuid.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monLastSentUuid @monLastSentUuid end |
#monStatus ⇒ Object
Returns the value of attribute monStatus.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monStatus @monStatus end |
#monTopic ⇒ Object
Returns the value of attribute monTopic.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monTopic @monTopic end |
#monTransportToken ⇒ Object
Returns the value of attribute monTransportToken.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monTransportToken @monTransportToken end |
#monTransportType ⇒ Object
Returns the value of attribute monTransportType.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monTransportType @monTransportType end |
#monTransportUrl ⇒ Object
Returns the value of attribute monTransportUrl.
3 4 5 |
# File 'lib/device_cloud/monitor.rb', line 3 def monTransportUrl @monTransportUrl end |
Class Method Details
.all ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/device_cloud/monitor.rb', line 18 def all monitors = DeviceCloud::Request.new(path: '/ws/Monitor/.json').get.to_hash_from_json return [] unless monitors['resultSize'].to_i > 0 monitors['items'].map { |monitor| Monitor.new monitor } end |
.find(monitor_id) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/device_cloud/monitor.rb', line 28 def find(monitor_id) monitors = DeviceCloud::Request.new(path: "/ws/Monitor/#{monitor_id}.json").get.to_hash_from_json return nil unless monitors['resultSize'].to_i > 0 Monitor.new monitors['items'].first end |
Instance Method Details
#attributes ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/device_cloud/monitor.rb', line 70 def attributes { 'monTopic' => monTopic, 'monTransportType' => monTransportType, 'monTransportToken' => monTransportToken, 'monTransportUrl' => monTransportUrl, 'monFormatType' => monFormatType, 'monBatchSize' => monBatchSize, 'monCompression' => monCompression, 'monBatchDuration' => monBatchDuration, 'monAutoReplayOnConnect' => monAutoReplayOnConnect } end |
#destroy! ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/device_cloud/monitor.rb', line 62 def destroy! return false if monId.nil? response = DeviceCloud::Request.new(path: "/ws/Monitor/#{monId}").delete response.code == '200' ? true : false end |
#persist! ⇒ Object
47 48 49 50 |
# File 'lib/device_cloud/monitor.rb', line 47 def persist! @error = nil monId.nil? ? create : update end |
#reset! ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/device_cloud/monitor.rb', line 52 def reset! @error = nil if monId.nil? @error = 'monId is nil' return false else reset_monitor! end end |