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"] = account_id.to_s if account_id
params["account_name"] = account_name unless account_name.to_s.strip.empty?
params["account_title"] = account_title unless account_title.to_s.strip.empty?
account = self.new.send(:get_request, params, "/api/get_account_details_dict")
if account
Abiraj.log(message: "Account data fetched successfully")
return account
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
|