Sha256: ef322ee9f33607aeeb5f0aaddb1c3c77cfca60abb69ef4e01932e92c8701e86e

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Qismo
  module Resources
    module AgentResource
      #
      # List agents
      #
      # @param options [Hash]
      # @option options [Integer] :page Page number
      # @option options [Integer] :limit Data offset per page
      # @option options [String] :search Filter agent by query
      # @option options [String] :scope Scoping search attribute. Can be `division`, `name`, or `email`
      #
      # @return [Array<Agent>]
      #
      def list(options = {})
        resp = Qismo.client.get("/api/v2/admin/agents", options)
        body = resp.http_body
        agents = body.dig("data", "agents")
        agents.dig("data", "agents").map { |agent| Agent.new(agent) }
      end

      #
      # Get agent by id
      #
      # @param id [Integer] Agent's id
      #
      # @return [Agent]
      #
      def get(id)
        resp = Qismo.client.call(:get, "/api/v2/admin/agent/#{id}")
        body = resp.http_body
        agent = body.dig("data", "agent")
        Agent.new(agent)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
qismo-0.1.8 lib/qismo/resources/agent_resource.rb
qismo-0.1.5 lib/qismo/resources/agent_resource.rb
qismo-0.1.4 lib/qismo/resources/agent_resource.rb
qismo-0.1.2 lib/qismo/resources/agent_resource.rb
qismo-0.1.1 lib/qismo/resources/agent_resource.rb
qismo-0.1.0 lib/qismo/resources/agent_resource.rb