Module: Mastercontrol::Accounts

Defined in:
lib/mastercontrol/accounts.rb

Defined Under Namespace

Classes: WhmAccount

Class Method Summary collapse

Class Method Details

.listObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mastercontrol/accounts.rb', line 13

def self.list
  url = "#{Mastercontrol.base_url}/listaccts?api.version=1"
  response = RestClient.get url, {authorization: Mastercontrol.auth_header}

  # parse the json
  json_response = JSON.parse(response)
  return_array = []
  # build and return the ServerLoad Object
  json_response['data']['acct'].each do ||

    return_array << ()
  end
  return_array
end

.parse_account(whm_account) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/mastercontrol/accounts.rb', line 72

def self.()
   = WhmAccount.new
  .max_addons = ["maxaddons"]
  .ip = ["ip"]
  .ipv6 = ["ipv6"]
  .outgoing_mail_suspended = Integer(["outgoing_mail_suspended"])
  .outgoing_mail_hold = Integer(["outgoing_mail_hold"])
  .min_defer_fail_to_trigger_protection = Integer(["min_defer_fail_to_trigger_protection"])
  .legacy_backup = Integer(["legacy_backup"])
  .disk_used = ["diskused"]
  .max_ftp = ["maxftp"]
  .start_date = ["startdate"]
  .max_defer_fail_percentage = Integer(["max_defer_fail_percentage"])
  .disk_limit = ["disklimit"]
  .is_locked = Integer(["is_locked"])
  .suspend_time = ["suspendtime"]
  .email = ["email"]
  .domain = ["domain"]
  .unix_startdate = ["unix_startdate"]
  .user = ["user"]
  .plan = ["plan"]
  .shell = ["shell"]
  .max_pop = ["maxpop"]
  .backup = Integer(["backup"])
  .theme = ["theme"]
  .owner = ["owner"]
  .max_email_per_hour = ["max_email_per_hour"]
  .suspend_reason = ["suspendreason"]
  .max_list = ["maxlst"]
  .suspended = Integer(["suspended"])
  .max_sql = ["maxsql"]
  .max_parked = ["maxparked"]
  .partition = ["partition"]
  .max_sub = ["maxsub"]
  
end

.retrieve(username) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mastercontrol/accounts.rb', line 28

def self.retrieve(username)
  url = "#{Mastercontrol.base_url}/accountsummary?api.version=1&user=#{username}"
  response = RestClient.get url, {authorization: Mastercontrol.auth_header}

  # parse the json
  json_response = JSON.parse(response)

  if json_response["data"]["acct"].nil?
    return nil
  end

   = json_response["data"]["acct"][0]

  ()
end

.suspend(username, reason) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mastercontrol/accounts.rb', line 44

def self.suspend(username, reason)
  url = "#{Mastercontrol.base_url}/suspendacct?api.version=1&user=#{username}&reason=#{reason}"
  response = RestClient.get url, {authorization: Mastercontrol.auth_header}

  # parse the json
  json_response = JSON.parse(response)

  if json_response["metadata"]["result"].to_i == 1
    return true
  else
    return false
  end
end

.unsuspend(username) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/mastercontrol/accounts.rb', line 58

def self.unsuspend(username)
  url = "#{Mastercontrol.base_url}/unsuspendacct?api.version=1&user=#{username}"
  response = RestClient.get url, {authorization: Mastercontrol.auth_header}

  # parse the json
  json_response = JSON.parse(response)

  if json_response["metadata"]["result"].to_i == 1
    return true
  else
    return false
  end
end