sitra_client 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ class SitraQuery
7
7
 
8
8
  def initialize(api_key, site_identifier, criteria = {})
9
9
  @apiKey = api_key
10
- @siteWebExportIdV1 = site_identifier
10
+ @projetId = site_identifier
11
11
  self.attributes = criteria
12
12
  end
13
13
 
@@ -76,7 +76,7 @@ class TouristicObject
76
76
  contact_entries.each do |c|
77
77
  if types_ids.include?(c[:type][:id])
78
78
  label = c[:type][@libelle]
79
- contact_details[label] = c[:coordonnee]
79
+ contact_details[label] = c[:coordonnees][:fr]
80
80
  end
81
81
  end
82
82
  contact_details
@@ -91,12 +91,12 @@ class TouristicObject
91
91
  end
92
92
 
93
93
  def picture_url(default_url)
94
- @imagePrincipale.nil? ? default_url : @imagePrincipale[:traductionFichiers][0][:url]
94
+ (@illustrations.nil? || @illustrations.empty?) ? default_url : @illustrations[0][:traductionFichiers][0][:url]
95
95
  end
96
96
 
97
97
  def service_provider
98
- if @informationsActivite && @informationsActivite[:commerceEtServicePrestataire]
99
- @informationsActivite[:commerceEtServicePrestataire][:nom][@libelle]
98
+ if @informationsActivite && @informationsActivite[:prestataireActivites]
99
+ @informationsActivite[:prestataireActivites][:nom][@libelle]
100
100
  elsif @informationsFeteEtManifestation
101
101
  @informationsFeteEtManifestation[:nomLieu]
102
102
  else
@@ -105,8 +105,8 @@ class TouristicObject
105
105
  end
106
106
 
107
107
  def address_details
108
- if @informationsActivite && @informationsActivite[:commerceEtServicePrestataire]
109
- @informationsActivite[:commerceEtServicePrestataire][:adresse]
108
+ if @informationsActivite && @informationsActivite[:prestataireActivites]
109
+ @informationsActivite[:prestataireActivites][:adresse]
110
110
  else
111
111
  @localisation[:adresse]
112
112
  end
@@ -284,10 +284,10 @@ class TouristicObject
284
284
  end
285
285
 
286
286
  def parse_geoloc_details
287
- if @informationsActivite.nil? || @informationsActivite[:commerceEtServicePrestataire].nil?
287
+ if @informationsActivite.nil? || @informationsActivite[:prestataireActivites].nil?
288
288
  geoloc_details = @localisation[:geolocalisation]
289
289
  else
290
- geoloc_details = @informationsActivite[:commerceEtServicePrestataire][:geolocalisation]
290
+ geoloc_details = @informationsActivite[:prestataireActivites][:geolocalisation]
291
291
  end
292
292
  geoloc_details
293
293
  end
@@ -1,3 +1,3 @@
1
1
  module SitraClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/sitra_client.rb CHANGED
@@ -13,7 +13,7 @@ module SitraClient
13
13
 
14
14
  # Configuration defaults
15
15
  @config = {
16
- :base_url => 'http://api.sitra-tourisme.com/api/v001',
16
+ :base_url => 'http://api.sitra-tourisme.com/api/v002',
17
17
  :api_key => '',
18
18
  :site_identifier => ''
19
19
  }
@@ -10,7 +10,7 @@ class SitraQueryTest < Test::Unit::TestCase
10
10
 
11
11
  query = SitraQuery.new('dummy_key', 'dummy_identifier', {:first_key => 'first_value', :second_key => 'second_value'})
12
12
 
13
- assert_equal '{"apiKey":"dummy_key","siteWebExportIdV1":"dummy_identifier","first_key":"first_value","second_key":"second_value"}', query.to_params
13
+ assert_equal '{"apiKey":"dummy_key","projetId":"dummy_identifier","first_key":"first_value","second_key":"second_value"}', query.to_params
14
14
  end
15
15
 
16
16
  end
@@ -32,9 +32,9 @@ class TouristicObjectTest < Test::Unit::TestCase
32
32
  hash_result = {
33
33
  :informations => {
34
34
  :moyensCommunication => [
35
- {:type => {:libelleFr => "Téléphone", :id => 201}, :coordonnee => "0123456789"},
36
- {:type => {:libelleFr => "Mél", :id => 204}, :coordonnee => "my@email.fr"},
37
- {:type => {:libelleFr => "Fax", :id => 202}, :coordonnee => "9876543201"}
35
+ {:type => {:libelleFr => "Téléphone", :id => 201}, :coordonnees => {:fr => "0123456789"}},
36
+ {:type => {:libelleFr => "Mél", :id => 204}, :coordonnees => {:fr => "my@email.fr"}},
37
+ {:type => {:libelleFr => "Fax", :id => 202}, :coordonnees => {:fr => "9876543201"}}
38
38
  ]
39
39
  }
40
40
  }
@@ -44,7 +44,11 @@ class TouristicObjectTest < Test::Unit::TestCase
44
44
  end
45
45
 
46
46
  should 'populate image details' do
47
- hash_result = {:imagePrincipale => {:traductionFichiers => [{:url => "my/image/url"}]}}
47
+ hash_result = {
48
+ :illustrations => [
49
+ {:type => "IMAGE", :traductionFichiers => [:url => "my/image/url"]}
50
+ ]
51
+ }
48
52
  touristic_object = TouristicObject.new(hash_result)
49
53
 
50
54
  assert_equal 'my/image/url', touristic_object.picture_url('default.png')
@@ -53,7 +57,7 @@ class TouristicObjectTest < Test::Unit::TestCase
53
57
  should 'populate address details' do
54
58
  hash_result = {
55
59
  :informationsActivite => {
56
- :commerceEtServicePrestataire => {
60
+ :prestataireActivites => {
57
61
  :nom => {:libelleFr => "my_service"},
58
62
  :adresse => {:adresse1 => "my_address", :codePostal => "1234", :commune => {:nom => "my_city"}},
59
63
  :geolocalisation => {:valide => true, :geoJson => {:coordinates => [0.1, 0.2]}}
@@ -137,11 +141,11 @@ class TouristicObjectTest < Test::Unit::TestCase
137
141
  :type => 'ACTIVITE',
138
142
  :informations => {
139
143
  :moyensCommunication => [
140
- {:type => {:libelleFr => "Téléphone"}, :coordonnee => "0123456789"}
144
+ {:type => {:libelleFr => "Téléphone"}, :coordonnees => {:fr => "0123456789"}}
141
145
  ]
142
146
  },
143
147
  :informationsActivite => {
144
- :commerceEtServicePrestataire => {
148
+ :prestataireActivites => {
145
149
  :nom => {:libelleFr => "my_service"}
146
150
  }
147
151
  }
@@ -149,8 +153,8 @@ class TouristicObjectTest < Test::Unit::TestCase
149
153
 
150
154
  touristic_object = TouristicObject.new(hash_result)
151
155
 
152
- assert_equal "0123456789", touristic_object.information[:moyensCommunication][0][:coordonnee]
153
- assert_equal "my_service", touristic_object.information[:commerceEtServicePrestataire][:nom][:libelleFr]
156
+ assert_equal "0123456789", touristic_object.information[:moyensCommunication][0][:coordonnees][:fr]
157
+ assert_equal "my_service", touristic_object.information[:prestataireActivites][:nom][:libelleFr]
154
158
  end
155
159
 
156
160
  should 'default to fr locale' do
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.1.0
4
+ version: 0.2.0
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: 2015-02-14 00:00:00.000000000 Z
12
+ date: 2015-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler