Class: Alula::CameraGetInfoProc

Inherits:
RpcResource show all
Defined in:
lib/alula/procedures/camera_get_info_proc.rb

Defined Under Namespace

Classes: Response

Class Method Summary collapse

Methods inherited from RpcResource

ok?, request, wrap_payload

Class Method Details

.call(device_id:, filter_online_offline:, page_size: 20, page_number: 1, filter: {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/alula/procedures/camera_get_info_proc.rb', line 23

def self.call(device_id:, filter_online_offline:, page_size: 20, page_number: 1, filter: {})
  query_params = {
    'sort' => '-date',
    'page[size]' => page_size,
    'page[number]' => page_number
  }

  query_params.merge!(filter)

  if filter_online_offline
    query_params.merge!(
      'filter[data.online.value][$not][0]' => 0,
      'filter[data.online.value][$not][1]' => 1
    )
  end

  query_string = URI.encode_www_form(query_params)
  formatted_path = "/video/v1/device/#{device_id}/info?#{query_string}"

  request(
    http_method: :get,
    path: formatted_path,
    handler: Response,
    payload: {}
  )
end