sitra_client 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,25 @@ class TouristicObject
|
|
5
5
|
|
6
6
|
include AttributeHelper
|
7
7
|
|
8
|
+
SPECIFIC_INFOS = {
|
9
|
+
'ACTIVITE' => '@informationsActivite',
|
10
|
+
'COMMERCE_ET_SERVICE' => '@informationsCommerceEtService',
|
11
|
+
'DEGUSTATION' => '@informationsDegustation',
|
12
|
+
'DOMAINE_SKIABLE' => '@informationsDomaineSkiable',
|
13
|
+
'EQUIPEMENT' => '@informationsEquipement',
|
14
|
+
'FETE_ET_MANIFESTATION' => '@informationsFeteEtManifestation',
|
15
|
+
'HEBERGEMENT_COLLECTIF' => '@informationsHebergementCollectif',
|
16
|
+
'HEBERGEMENT_LOCATIF' => '@informationsHebergementLocatif',
|
17
|
+
'HOTELLERIE' => '@informationsHotellerie',
|
18
|
+
'HOTELLERIE_PLEIN_AIR' => '@informationsHotelleriePleinAir',
|
19
|
+
'PATRIMOINE_CULTUREL' => '@informationsPatrimoineCulturel',
|
20
|
+
'PATRIMOINE_NATUREL' => '@informationsPatrimoineNaturel',
|
21
|
+
'RESTAURATION' => '@informationsRestauration',
|
22
|
+
'SEJOUR_PACKAGE' => '@informationsSejourPackage',
|
23
|
+
'STRUCTURE' => '@informationsStructure',
|
24
|
+
'TERRITOIRE' => '@informationsTerritoire'
|
25
|
+
}
|
26
|
+
|
8
27
|
def initialize(hash)
|
9
28
|
self.attributes = hash
|
10
29
|
end
|
@@ -13,6 +32,10 @@ class TouristicObject
|
|
13
32
|
@id.to_s
|
14
33
|
end
|
15
34
|
|
35
|
+
def type
|
36
|
+
@type
|
37
|
+
end
|
38
|
+
|
16
39
|
def title
|
17
40
|
@nom[:libelleFr]
|
18
41
|
end
|
@@ -25,16 +48,26 @@ class TouristicObject
|
|
25
48
|
@presentation[:descriptifDetaille][:libelleFr] unless @presentation[:descriptifDetaille].nil?
|
26
49
|
end
|
27
50
|
|
28
|
-
def contact
|
51
|
+
def contact(fields = [])
|
29
52
|
contact_details = {}
|
30
53
|
contact_entries = @informations[:moyensCommunication].nil? ? [] : @informations[:moyensCommunication]
|
31
54
|
contact_entries.each do |c|
|
32
55
|
label = c[:type][:libelleFr]
|
33
|
-
|
56
|
+
if fields.include?(label)
|
57
|
+
contact_details[c[:type][:libelleFr]] = c[:coordonnee] unless label.downcase.include?('fax')
|
58
|
+
end
|
34
59
|
end
|
35
60
|
contact_details
|
36
61
|
end
|
37
62
|
|
63
|
+
def information
|
64
|
+
specific_information = {}
|
65
|
+
unless @type.nil?
|
66
|
+
specific_information = instance_variable_get(SPECIFIC_INFOS[@type])
|
67
|
+
end
|
68
|
+
@informations.merge(specific_information)
|
69
|
+
end
|
70
|
+
|
38
71
|
def picture_url(default_url)
|
39
72
|
@imagePrincipale.nil? ? default_url : @imagePrincipale[:traductionFichiers][0][:url]
|
40
73
|
end
|
data/lib/sitra_client/version.rb
CHANGED
@@ -28,18 +28,19 @@ class TouristicObjectTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal 'my_detailed_description', touristic_object.details
|
29
29
|
end
|
30
30
|
|
31
|
-
should 'populate contact details' do
|
31
|
+
should 'populate contact details for provided fields' do
|
32
32
|
hash_result = {
|
33
33
|
:informations => {
|
34
34
|
:moyensCommunication => [
|
35
35
|
{:type => {:libelleFr => "Téléphone"}, :coordonnee => "0123456789"},
|
36
|
+
{:type => {:libelleFr => "Mél"}, :coordonnee => "my@email.fr"},
|
36
37
|
{:type => {:libelleFr => "Fax"}, :coordonnee => "9876543201"}
|
37
38
|
]
|
38
39
|
}
|
39
40
|
}
|
40
41
|
touristic_object = TouristicObject.new(hash_result)
|
41
42
|
|
42
|
-
assert_equal({'Téléphone' => '0123456789'}, touristic_object.contact)
|
43
|
+
assert_equal({'Téléphone' => '0123456789', 'Mél' => 'my@email.fr'}, touristic_object.contact(['Téléphone', 'Mél']))
|
43
44
|
end
|
44
45
|
|
45
46
|
should 'populate image details' do
|
@@ -131,4 +132,25 @@ class TouristicObjectTest < Test::Unit::TestCase
|
|
131
132
|
assert_true touristic_object.adapted_tourism.include?('Accessible en fauteuil roulant en autonomie')
|
132
133
|
end
|
133
134
|
|
135
|
+
should 'retrieve merged general and specific information' do
|
136
|
+
hash_result = {
|
137
|
+
:type => 'ACTIVITE',
|
138
|
+
:informations => {
|
139
|
+
:moyensCommunication => [
|
140
|
+
{:type => {:libelleFr => "Téléphone"}, :coordonnee => "0123456789"}
|
141
|
+
]
|
142
|
+
},
|
143
|
+
:informationsActivite => {
|
144
|
+
:commerceEtServicePrestataire => {
|
145
|
+
:nom => {:libelleFr => "my_service"}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
touristic_object = TouristicObject.new(hash_result)
|
151
|
+
|
152
|
+
assert_equal "0123456789", touristic_object.information[:moyensCommunication][0][:coordonnee]
|
153
|
+
assert_equal "my_service", touristic_object.information[:commerceEtServicePrestataire][:nom][:libelleFr]
|
154
|
+
end
|
155
|
+
|
134
156
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitra_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|