Class: M2X::MQTT::Command

Inherits:
Resource show all
Defined in:
lib/m2x/mqtt/command.rb

Overview

Wrapper for AT&T M2X Commands API m2x.att.com/developer/documentation/v2/device

Instance Attribute Summary

Attributes inherited from Resource

#attributes

Instance Method Summary collapse

Methods inherited from Resource

#inspect, #refresh, #view

Constructor Details

#initialize(client, attributes) ⇒ Command

Returns a new instance of Command.



7
8
9
10
# File 'lib/m2x/mqtt/command.rb', line 7

def initialize(client, attributes)
  @client     = client
  @attributes = attributes
end

Instance Method Details

#pathObject



12
13
14
# File 'lib/m2x/mqtt/command.rb', line 12

def path
  @path ||= URI.parse(@attributes.fetch("url")).path
end

#process!(response_data = {}) ⇒ Object

Mark the command as processed, with optional response data. Check the API response after calling to verify success (no status conflict).

m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Processed



20
21
22
# File 'lib/m2x/mqtt/command.rb', line 20

def process!(response_data={})
  @client.post("#{path}/process", response_data)
end

#reject!(response_data = {}) ⇒ Object

Mark the command as rejected, with optional response data. Check the API response after calling to verify success (no status conflict).

m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Rejected



28
29
30
# File 'lib/m2x/mqtt/command.rb', line 28

def reject!(response_data={})
  @client.post("#{path}/reject", response_data)
end