Class: Puree::Organisation

Inherits:
Resource show all
Defined in:
lib/puree/organisation.rb

Overview

Organisation resource

Instance Attribute Summary

Attributes inherited from Resource

#response

Instance Method Summary collapse

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.

Parameters:

  • endpoint (String) (defaults to: nil)
  • optional

    username [String]

  • optional

    password [String]

  • optional

    basic_auth [Boolean]



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

#addressArray<Hash>

Address

Returns:

  • (Array<Hash>)


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

#emailArray<String>

Email

Returns:

  • (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

#metadataHash

All metadata

Returns:

  • (Hash)


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

#nameString

Name

Returns:

  • (String)


56
57
58
59
# File 'lib/puree/organisation.rb', line 56

def name
  path = '/name/localizedString'
  xpath_query_for_single_value path
end

#organisationArray<Hash>

Organisation

Returns:

  • (Array<Hash>)


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

#parentHash

Parent

Returns:

  • (Hash)


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

#phoneArray<String>

Phone

Returns:

  • (Array<String>)


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

#typeString

Type

Returns:

  • (String)


87
88
89
90
# File 'lib/puree/organisation.rb', line 87

def type
  path = '/typeClassification/term/localizedString'
  xpath_query_for_single_value path
end

#urlArray<String>

URL

Returns:

  • (Array<String>)


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