Class: Abiraj::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/abiraj.rb

Class Method Summary collapse

Class Method Details

.get(account_id: nil, account_name: nil, account_title: nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/abiraj.rb', line 48

def self.get(account_id: nil, account_name: nil, account_title: nil)
  begin
    unless Abiraj.server_url && Abiraj.authtoken
      Abiraj.log(message: "Abiraj is not initialized. Please initialize before using.", level: "error")
      return nil
    end

    Abiraj.log(message: "Fetching account data")
    params = {}
    params["account_id"] = .to_s if 
    params["account_name"] =  unless .to_s.strip.empty?
    params["account_title"] =  unless .to_s.strip.empty?
     = self.new.send(:get_request, params, "/api/get_account_details_dict")
    if 
      Abiraj.log(message: "Account data fetched successfully")
      return 
    else
      Abiraj.log(message: "Unable to fetch account data.", level: "error")
      return nil
    end

  rescue StandardError => e
    Abiraj.log(message: "Failed to fetch account data: #{e.message}", level: "error")
    return nil
  end
end