# 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] # 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