class Particle::Product
Domain model for one Particle
product
Constants
- ID_REGEX
Public Class Methods
list_path()
click to toggle source
# File lib/particle/product.rb, line 85 def self.list_path "v1/products" end
new(client, attributes)
click to toggle source
Calls superclass method
Particle::Model::new
# File lib/particle/product.rb, line 9 def initialize(client, attributes) super(client, attributes) attributes = attributes.to_s if attributes.is_a?(Integer) if attributes.is_a? String if attributes =~ ID_REGEX @attributes = { id: attributes } else @attributes = { slug: attributes } end else # Listing all devices returns partial attributes so check if the # device was fully loaded or not @fully_loaded = true if attributes.key?(:name) end end
Public Instance Methods
add_device(device_id)
click to toggle source
add_device_path()
click to toggle source
# File lib/particle/product.rb, line 89 def add_device_path "/v1/products/#{id_or_slug}/devices" end
devices()
click to toggle source
# File lib/particle/product.rb, line 37 def devices @devices = @client.get_devices(id_or_slug) end
devices_path()
click to toggle source
# File lib/particle/product.rb, line 101 def devices_path "/v1/products/#{id_or_slug}/devices" end
firmware(target)
click to toggle source
# File lib/particle/product.rb, line 57 def firmware(target) @client.product_firmware(self, target) end
firmware_path(version)
click to toggle source
# File lib/particle/product.rb, line 105 def firmware_path(version) "/v1/products/#{id_or_slug}/firmware/#{version}" end
firmware_upload_path()
click to toggle source
# File lib/particle/product.rb, line 109 def firmware_upload_path "/v1/products/#{id_or_slug}/firmware" end
get_attributes()
click to toggle source
# File lib/particle/product.rb, line 32 def get_attributes @loaded = @fully_loaded = true @attributes = @client.product_attributes(self) end
id()
click to toggle source
# File lib/particle/product.rb, line 66 def id get_attributes unless @attributes[:id] @attributes[:id] end
id_or_slug()
click to toggle source
# File lib/particle/product.rb, line 81 def id_or_slug @attributes[:id] || @attributes[:slug] end
organization()
click to toggle source
# File lib/particle/product.rb, line 76 def organization get_attributes unless @attributes[:organization] || @attributes[:org] @attributes[:organization] || @attributes[:org] end
path()
click to toggle source
# File lib/particle/product.rb, line 97 def path "/v1/products/#{id_or_slug}" end
remove_device(device_id)
click to toggle source
remove_device_path(device_id)
click to toggle source
# File lib/particle/product.rb, line 93 def remove_device_path(device_id) "/v1/products/#{id_or_slug}/devices/#{device_id}" end
slug()
click to toggle source
# File lib/particle/product.rb, line 71 def slug get_attributes unless @attributes[:slug] @attributes[:slug] end
upload_firmware(version, title, binary, desc = nil)
click to toggle source
# File lib/particle/product.rb, line 61 def upload_firmware(version, title, binary, desc = nil) params = { version: version, title: title, binary: binary, description: desc } @client.upload_product_firmware(self, params) end