Class: PleskKit::CustomerAccount

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/plesk_kit/customer_account.rb

Instance Method Summary collapse

Instance Method Details

#analyse(response_string, server_id) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/models/plesk_kit/customer_account.rb', line 70

def analyse response_string, server_id
  xml = REXML::Document.new(response_string)
  status = xml.root.elements['//status'].text if xml.root.elements['//status'].present?
  if status == "error"
    code = xml.root.elements['//errcode'].text
    message = xml.root.elements['//errtext'].text
    raise "#{code}: #{message}"
  else
    plesk_id = xml.root.elements['//id'].text if xml.root.elements['//id'].present?
    self.server_id = server_id
  end
  #self.save
  return self # TODO save plesk_id
end

#analyse_password_reset(response_string) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'app/models/plesk_kit/customer_account.rb', line 85

def analyse_password_reset response_string
  xml = REXML::Document.new(response_string)
  status = xml.root.elements['//status'].text if xml.root.elements['//status'].present?
  if status == "error"
    code = xml.root.elements['//errcode'].text
    message = xml.root.elements['//errtext'].text
    raise "#{code}: #{message}"
  else
    true
  end
end

#pack_this(shell) ⇒ Object

Creates Object & Packet



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/plesk_kit/customer_account.rb', line 24

def pack_this shell
  xml = shell
  xml.instruct!
  xml.packet(:version => '1.6.3.5') {
    xml.customer {
      xml.add{
        xml.gen_info{
          xml.cname(self.cname)
          xml.pname(self.pname)
          xml.(self.)
          xml.passwd(self.passwd)
          #xml.status(status ? 0 : 1)
          xml.phone('0000000000')
          #xml.fax(fax)
          #xml.address(address)
          #xml.city(city)
          #xml.state(state)
          #xml.pcode(pcode)
          xml.email('[email protected]')
          xml.country("AU")
        }
      }
    }
  }
  return xml.target!
end

#password_reset_pack(shell, new_password, account) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/models/plesk_kit/customer_account.rb', line 51

def password_reset_pack shell, new_password, 
  xml = shell
  xml.instruct!
  xml.packet(:version => '1.6.3.5') {
    xml.customer {
      xml.set{
        xml.filter{
          xml.(.)
        }
        xml.values{
          xml.gen_info{
            xml.passwd(new_password)
          }
        }
      }
    }
  }
end

#provision_in_pleskObject



9
10
11
12
# File 'app/models/plesk_kit/customer_account.rb', line 9

def provision_in_plesk
  PleskKit::Communicator.pack_and_play_with_customer_or_reseller self
  true
end

#reset_password(new_password) ⇒ Object



14
15
16
17
# File 'app/models/plesk_kit/customer_account.rb', line 14

def reset_password(new_password)
  PleskKit::Communicator.pack_and_reset_password self, new_password
  true
end