Sha256: ef78ce9ba9a11113b0a25a7db55853a878f223bdfccd9b8d1098077670a5cc00

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

# encoding: utf-8

module Nimbu
  module Endpoints
    class Devices < Endpoint
      def list(*args)
        arguments(args)

        response = get_request("/devices", arguments.params)
        return response unless block_given?
        response.each { |el| yield el }
      end
      alias :all :list

      def count(*args)
        arguments(args)

        get_request("/devices/count", arguments.params)
      end

      def get(*args)
        arguments(args, :required => [:device_id])

        get_request("/devices/#{device_id}", arguments.params)
      end
      alias :find :get

      def create(*args)
        arguments(args)

        post_request("/devices", arguments.params)
      end

      def update(*args)
        arguments(args, :required => [:device_id])

        patch_request("/devices/#{device_id}", arguments.params)
      end
      alias :edit :update

      def delete(*args)
        arguments(args, :required => [:device_id])

        delete_request("/devices/#{device_id}", arguments.params)
      end
      alias :remove :delete

      def push(*args)
        arguments(args)

        query_params = arguments.params.delete("query")
        data = arguments.params

        post_request("/devices/push", data, params: query_params)
      end
      alias :message :push

    end # Devices
  end # Endpoints
end # Nimbu

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nimbu-api-0.4.4 lib/nimbu-api/endpoints/devices.rb
nimbu-api-0.4.3 lib/nimbu-api/endpoints/devices.rb
nimbu-api-0.4.2 lib/nimbu-api/endpoints/devices.rb
nimbu-api-0.4.1 lib/nimbu-api/endpoints/devices.rb
nimbu-api-0.4.0 lib/nimbu-api/endpoints/devices.rb