Module: Particle::Client::ProductFirmwares
- Included in:
- Particle::Client
- Defined in:
- lib/particle/client/product_firmwares.rb
Overview
Client methods for the Particle product firmware API
Instance Method Summary collapse
-
#product_firmware(product, target) ⇒ ProductFirmware
Create a domain model for a Particle product firmware object.
-
#product_firmware_attributes(target) ⇒ Hash
Get information about a specific firmware version of a Particle Product.
- #product_firmware_file_upload_params(file_path, options) ⇒ Object
-
#upload_product_firmware(product, params) ⇒ ProductFirmware
Create a domain model for a Particle product firmware object.
Instance Method Details
#product_firmware(product, target) ⇒ ProductFirmware
Create a domain model for a Particle product firmware object
14 15 16 17 18 19 20 |
# File 'lib/particle/client/product_firmwares.rb', line 14 def product_firmware(product, target) if target.is_a? ProductFirmware target else ProductFirmware.new(self, product, target) end end |
#product_firmware_attributes(target) ⇒ Hash
Get information about a specific firmware version of a Particle Product
50 51 52 53 |
# File 'lib/particle/client/product_firmwares.rb', line 50 def product_firmware_attributes(target) the_product = target.product get(the_product.firmware_path(target.version)) end |
#product_firmware_file_upload_params(file_path, options) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/particle/client/product_firmwares.rb', line 37 def product_firmware_file_upload_params(file_path, ) params = {} params[:binary] = Faraday::UploadIO.new(file_path, "application/octet-stream") params[:file_type] = "binary" params.merge! params end |
#upload_product_firmware(product, params) ⇒ ProductFirmware
Create a domain model for a Particle product firmware object
28 29 30 31 32 33 34 35 |
# File 'lib/particle/client/product_firmwares.rb', line 28 def upload_product_firmware(product, params) file_path = params.delete(:binary) || params.delete(:file) params = product_firmware_file_upload_params(file_path, params) res = post(product.firmware_upload_path, params) product.firmware(res) end |