module Evercam::Cameras
Public Instance Methods
This method changes the owner of a camera. You must be the owner of the camera to call this method and all artifacts relating to the camera transfer ownership when the camera does.
Parameters¶ ↑
- camera_id
-
The unique identifier of the camera to be transferred.
user_id: The Evercam
user name or email address of the new owner for
the camera.
# File lib/evercam/cameras.rb, line 106 def change_camera_owner(camera_id, user_id) data = handle_response(call("/cameras/#{camera_id}", :put, {user_id: user_id})) if !data.include?("cameras") || data["cameras"].empty? message = "Invalid response received from server." @logger.error message raise EvercamError.new(message) end data["cameras"].first end
This method creates a new camera in the system.
Parameters¶ ↑
- camera_id
-
The unique identifier to be assigned to the new camera.
- name
-
The name for the new camera.
- is_public
-
A boolean to indicate whether the new camera is public.
- values
-
A Hash of additional settings for the camera. The following keys are recognised :external_host, internal_host, :external_http_port, :internal_http_port, :external_rtsp_port, :internal_rtsp_port, :jpg_url, :cam_username and :cam_password.
# File lib/evercam/cameras.rb, line 85 def create_camera(camera_id, name, is_public, values={}) parameters = {id: camera_id, name: name, is_public: is_public}.merge(values) data = handle_response(call("/cameras", :post, parameters)) if !data.include?("cameras") || data["cameras"].size == 0 message = "Invalid response received from server." @logger.error message raise EvercamError.new(message) end data["cameras"][0] end
This method attempts to retrieve the details for a specific camera.
Parameters¶ ↑
- camera_id
-
The unique identifier for the camera to query.
# File lib/evercam/cameras.rb, line 24 def get_camera(camera_id) data = handle_response(call("/cameras/#{camera_id}")) if !data.include?("cameras") || data["cameras"].size == 0 message = "Invalid response received from server." @logger.error message raise EvercamError.new(message) end data["cameras"][0] end
This method fetches details for a set of cameras based on their unique identifiers.
Parameters¶ ↑
- camera_ids
-
A collection of 1 or more camera ids for the cameras to fetch details for.
# File lib/evercam/cameras.rb, line 64 def get_cameras(*camera_ids) data = handle_response(call("", :get, {ids: camera_ids.join(",")})) if !camera_ids.empty? if !data.include?("cameras") message = "Invalid response received from server." @logger.error message raise EvercamError.new(message) end data["cameras"] end
Test whether a given set of camera parameters are correct.
Parameters¶ ↑
- external_url
-
The external URL of the camera to be tested.
- jpg_url
-
The JPEG URL of the camera to be tested.
- user_name
-
The camera user name to be used in the test.
- password
-
The camera password to be used in the test.
# File lib/evercam/cameras.rb, line 12 def test_camera(external_url, jpg_url, user_name, password) parameters = {external_url: external_url, jpg_url: jpg_url, cam_username: user_name, cam_password: password} handle_response(call("/cameras/test", :get, parameters)) end
This method attempts to update the details associated with a camera.
Parameters¶ ↑
- camera_id
-
The unique identifier of the camera to be updated.
- values
-
A Hash of the values to be set. Keys recognosed in this parameter include :name, :is_public, :external_host, :internal_host, :external_http_port, :internal_http_port, :external_rtsp_port, :internal_rtsp_port, :jpg_url, :cam_username and :cam_password - all other parameters will be ignored.
# File lib/evercam/cameras.rb, line 44 def update_camera(camera_id, values={}) handle_response(call("/cameras/#{camera_id}", :patch, values)) if !values.empty? self end