Module: Particle::Client::Publish
- Included in:
- Particle::Client
- Defined in:
- lib/particle/client/publish.rb
Overview
Client methods for the Particle publish API
Constant Summary collapse
- PUBLISH_PATH =
"v1/devices/events"
Instance Method Summary collapse
-
#publish(options) ⇒ boolean
Publish an event to your devices.
Instance Method Details
#publish(options) ⇒ boolean
Publish an event to your devices
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/particle/client/publish.rb', line 20 def publish() params = { name: .fetch(:name) } case [:data] when Hash, Array then params[:data] = [:data].to_json else params[:data] = [:data].to_s end params[:ttl] = [:ttl] if [:ttl] params[:private] = true if [:private] result = post(PUBLISH_PATH, params) result[:ok] end |