module Particle::Client::Products
Public Instance Methods
Add device to Particle
product on the account
@param product [Product] A product to interact with @param device_id [String] A device id @return [Hash] JSON response as a hash
# File lib/particle/client/products.rb, line 56 def add_device(product:, device_id:) post(product.add_device_path, id: device_id) end
List all Particle
product devices on the account
@return [Array<Device>] List of Particle
product devices to interact with
# File lib/particle/client/products.rb, line 46 def get_devices(target) response_body = get(product(target).devices_path) (response_body[:devices]).map { |attributes| device(attributes) } end
Create a domain model for a Particle
product
@param target [String, Hash, Product] A product id, slug, hash of attributes or {Product} object @return [Product] A product object to interact with
# File lib/particle/client/products.rb, line 13 def product(target) if target.is_a? Product target else Product.new(self, target) end end
Get information about a Particle
product
@param target [String, Product] A product id, slug or {Product} object @return [Hash] The product attributes
# File lib/particle/client/products.rb, line 33 def product_attributes(target) response_body = get(product(target).path) # originally returned as an array, now seems to just return the 1 product as a hash; # this will handle both cases product = response_body[:product] product = product.first if product.is_a?(Array) product end
Remove device from a Particle
product on the account
@param product [Product] A product to interact with @param device_id [String] A device id @return [Hash] JSON response as a hash
# File lib/particle/client/products.rb, line 65 def remove_product_device(product:, device_id:) delete(product.remove_device_path(device_id)) end