Class: PleskLib::Actions::ListServicePlans
- Defined in:
- lib/plesk_lib/actions/list_service_plans.rb
Constant Summary collapse
- MAPPING =
{ 'cr_date' => 'created_at', 'cname' => 'company_name', 'pname' => 'person_name', 'login' => 'login', 'status' => 'status', 'phone' => 'phone', 'fax' => 'fax', 'email' => 'email', 'address' => 'address', 'city' => 'city', 'state' => 'state', 'pcode' => 'postal_code', 'country' => 'country', 'locale' => 'locale', 'guid' => 'guid', 'owner-id' => 'owner_id', 'vendor-guid' => 'vendor_guid', 'external-id' => 'external_id', 'password' => 'password', 'password_type' => 'password_type' }
Instance Attribute Summary collapse
-
#service_plans ⇒ Object
readonly
Returns the value of attribute service_plans.
Instance Method Summary collapse
- #analyse(xml_document) ⇒ Object
- #build_xml ⇒ Object
-
#initialize(owner_id = nil) ⇒ ListServicePlans
constructor
A new instance of ListServicePlans.
Methods inherited from Base
Constructor Details
#initialize(owner_id = nil) ⇒ ListServicePlans
Returns a new instance of ListServicePlans.
4 5 6 |
# File 'lib/plesk_lib/actions/list_service_plans.rb', line 4 def initialize(owner_id = nil) @owner_id = owner_id end |
Instance Attribute Details
#service_plans ⇒ Object (readonly)
Returns the value of attribute service_plans.
2 3 4 |
# File 'lib/plesk_lib/actions/list_service_plans.rb', line 2 def service_plans @service_plans end |
Instance Method Details
#analyse(xml_document) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/plesk_lib/actions/list_service_plans.rb', line 36 def analyse(xml_document) @service_plans = [] xml_document.root.send('service-plan').get.nodes.each do |plan_el| service_plan = PleskLib::ServicePlan.new(plan_el.locate('name').first.text) # binding.pry service_plan.id = plan_el.send('id').text.to_i service_plan.external_id = plan_el.send('external-id').text service_plan.guid = plan_el.send('guid').text owner_id_nodes = plan_el.locate('owner-id') if owner_id_nodes.first.present? service_plan.owner_id = owner_id_nodes.first.text.to_i end # plan_el.elements['data//gen_info'].each_element do |attribute| # service_plan_attribute = MAPPING[attribute.name] # next if service_plan_attribute.blank? || !service_plan.respond_to?(service_plan_attribute) || # attribute.text.blank? # service_plan.send("#{service_plan_attribute}=", attribute.text) # end # service_plan.status = service_plan.status.to_i @service_plans << service_plan end end |
#build_xml ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/plesk_lib/actions/list_service_plans.rb', line 18 def build_xml xml = Builder::XmlMarkup.new xml.instruct! xml.packet(:version => '1.6.3.5') { xml.tag!('service-plan') { xml.get { xml.filter if @owner_id.present? xml.tag!('owner-id', @owner_id) else xml.tag!('owner-all') end } } } return xml.target! end |