Class: Puree::Organisation
- Defined in:
- lib/puree/organisation.rb
Overview
Organisation resource
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#address ⇒ Array<Hash>
Address.
-
#email ⇒ Array<String>
Email.
-
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Organisation
constructor
A new instance of Organisation.
-
#metadata ⇒ Hash
All metadata.
-
#name ⇒ String
Name.
-
#organisation ⇒ Array<Hash>
Organisation.
-
#parent ⇒ Hash
Parent.
-
#phone ⇒ Array<String>
Phone.
-
#type ⇒ String
Type.
-
#url ⇒ Array<String>
URL.
Methods inherited from Resource
#content, #created, #get, #modified, #set_content, #uuid
Constructor Details
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Organisation
Returns a new instance of Organisation.
11 12 13 14 15 16 17 |
# File 'lib/puree/organisation.rb', line 11 def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) super(api: :organisation, endpoint: endpoint, username: username, password: password, basic_auth: basic_auth) end |
Instance Method Details
#address ⇒ Array<Hash>
Address
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puree/organisation.rb', line 24 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>
45 46 47 48 49 50 51 |
# File 'lib/puree/organisation.rb', line 45 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
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/puree/organisation.rb', line 106 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
56 57 58 59 |
# File 'lib/puree/organisation.rb', line 56 def name path = '/name/localizedString' xpath_query_for_single_value path end |
#organisation ⇒ Array<Hash>
Organisation
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/puree/organisation.rb', line 123 def organisation path = '/organisations/organisation' xpath_result = xpath_query path data = [] xpath_result.each do |d| o = {} o['uuid'] = d.xpath('@uuid').text.strip o['name'] = d.xpath('name/localizedString').text.strip o['type'] = d.xpath('typeClassification/term/localizedString').text.strip data << o end data.uniq end |
#parent ⇒ Hash
Parent
64 65 66 67 68 69 70 71 |
# File 'lib/puree/organisation.rb', line 64 def parent data = organisation o = {} if !data.empty? o = data.first end o end |
#phone ⇒ Array<String>
Phone
76 77 78 79 80 81 82 |
# File 'lib/puree/organisation.rb', line 76 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
87 88 89 90 |
# File 'lib/puree/organisation.rb', line 87 def type path = '/typeClassification/term/localizedString' xpath_query_for_single_value path end |
#url ⇒ Array<String>
URL
95 96 97 98 99 100 101 |
# File 'lib/puree/organisation.rb', line 95 def url path = '/webAddresses/classificationDefinedFieldExtension/value/localizedString' xpath_result = xpath_query path arr = [] xpath_result.each { |i| arr << i.text.strip } arr.uniq end |