Sha256: 101644730f21dc4724a38a88fbcf2bde80d3b4a91f94d58326635b2bd0982dd0

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Alula
  class CameraGetInfoProc < Alula::RpcResource
    class Response < Alula::RpcResponse
      attr_accessor :result, :pagination

      def initialize(response)
        super(response)
        @result = response.data['data']
        pagination = response.data['metaData']

        @pagination = Alula::Pagination.new(
          {
            'total' => pagination['totalHits'],
            'number' => pagination['page'],
            'size' => pagination['size']
          }
        )
      end
    end

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

      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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alula-ruby-1.10.1 lib/alula/procedures/camera_get_info_proc.rb
alula-ruby-1.10.0 lib/alula/procedures/camera_get_info_proc.rb
alula-ruby-1.9.17 lib/alula/procedures/camera_get_info_proc.rb
alula-ruby-1.9.16 lib/alula/procedures/camera_get_info_proc.rb
alula-ruby-1.9.15 lib/alula/procedures/camera_get_info_proc.rb
alula-ruby-1.9.14 lib/alula/procedures/camera_get_info_proc.rb
alula-ruby-1.9.13 lib/alula/procedures/camera_get_info_proc.rb