Class: Puree::Organisation
- Defined in:
- lib/puree/organisation.rb
Overview
Organisation resource
Instance Method Summary collapse
-
#address ⇒ Array<Hash>
Address.
-
#email ⇒ Array<String>
Email.
-
#initialize(endpoint: nil, username: nil, password: nil) ⇒ Organisation
constructor
A new instance of Organisation.
-
#metadata ⇒ Hash
All metadata.
-
#name ⇒ String
Name.
-
#parent ⇒ Hash
Parent.
-
#phone ⇒ Array<String>
Phone.
-
#type ⇒ String
Type.
-
#url ⇒ Array<String>
URL.
Methods inherited from Resource
#content, #created, #get, #modified, #response, #set_content, #uuid
Constructor Details
#initialize(endpoint: nil, username: nil, password: nil) ⇒ Organisation
Returns a new instance of Organisation.
10 11 12 13 14 15 |
# File 'lib/puree/organisation.rb', line 10 def initialize(endpoint: nil, username: nil, password: nil) super(api: :organisation, endpoint: endpoint, username: username, password: password) end |
Instance Method Details
#address ⇒ Array<Hash>
Address
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puree/organisation.rb', line 20 def address path = '//addresses/classifiedAddress' xpath_result = xpath_query path data = [] xpath_result.each do |d| o = {} o['street'] = d.xpath('street').text.strip o['building'] = d.xpath('building').text.strip o['postcode'] = d.xpath('postalCode').text.strip o['city'] = d.xpath('city').text.strip o['country'] = d.xpath('country/term/localizedString').text.strip data << o end data.uniq end |
#email ⇒ Array<String>
41 42 43 44 45 46 47 |
# File 'lib/puree/organisation.rb', line 41 def email path = '//emails/classificationDefinedStringFieldExtension/value' xpath_result = xpath_query path arr = [] xpath_result.each { |i| arr << i.text.strip } arr.uniq end |
#metadata ⇒ Hash
All metadata
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/puree/organisation.rb', line 103 def o = super o['address'] = address o['email'] = email o['name'] = name o['parent'] = parent o['phone'] = phone o['type'] = type o['url'] = url o end |
#name ⇒ String
Name
52 53 54 55 |
# File 'lib/puree/organisation.rb', line 52 def name data = node 'name' !data.nil? && !data.empty? ? data['localizedString']['__content__'].strip : '' end |
#parent ⇒ Hash
Parent
60 61 62 63 64 65 66 67 |
# File 'lib/puree/organisation.rb', line 60 def parent data = organisation o = {} if !data.empty? o = data.first end o end |
#phone ⇒ Array<String>
Phone
72 73 74 75 76 77 78 |
# File 'lib/puree/organisation.rb', line 72 def phone path = '//phoneNumbers/classificationDefinedStringFieldExtension/value' xpath_result = xpath_query path arr = [] xpath_result.each { |i| arr << i.text.strip } arr.uniq end |
#type ⇒ String
Type
83 84 85 86 87 |
# File 'lib/puree/organisation.rb', line 83 def type path = '//content/typeClassification/term/localizedString' xpath_result = xpath_query path xpath_result ? xpath_result.text.strip : '' end |
#url ⇒ Array<String>
URL
92 93 94 95 96 97 98 |
# File 'lib/puree/organisation.rb', line 92 def url path = '//content/webAddresses/classificationDefinedFieldExtension/value/localizedString' xpath_result = xpath_query path arr = [] xpath_result.each { |i| arr << i.text.strip } arr.uniq end |