apidae 1.2.3 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/apidae/apidae_data_parser.rb +10 -3
- data/app/models/apidae/obj.rb +14 -7
- data/app/models/apidae/reference.rb +1 -1
- data/app/models/apidae/selection.rb +4 -2
- data/config/initializers/constants.rb +8 -4
- data/config/locales/apidae.fr.yml +1 -0
- data/lib/apidae/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60d30181c595dde4d2f63e3389cfab37de03ba14
|
4
|
+
data.tar.gz: c4f2dc5189846f3068537fa832735bdedee85cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 259771713e098dcfee2c5e20f1c42ec5209dc976a38177b43cb7580eb5a4bec5b6d6e3cdbc790a8ef1f1c37e4af2b55d3d1cc40401ad6da95f8cea60d9e05b20
|
7
|
+
data.tar.gz: 95a7109af9633d25cba07aaf58268905c51bcb9dc72387e0a13ab1b0a60868fa1e2cf32bfb1a1c38e00cf84b97a60ef8ad3582f4330c4aadce427cc877178a62
|
@@ -236,6 +236,7 @@ module Apidae
|
|
236
236
|
openings_desc: node_value(openings_hash, :periodeEnClair, *locales),
|
237
237
|
openings_desc_mode: openings_hash[:periodeEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
|
238
238
|
openings: build_openings(openings_hash, *locales),
|
239
|
+
all_year_long: openings_hash[:ouvertTouteLAnnee] == 'OUVERT_TOUTE_L_ANNEE' ? 'true' : 'false',
|
239
240
|
time_periods: lists_ids(openings_hash[:indicationsPeriode]),
|
240
241
|
openings_extra: lists_ids(openings_hash[:ouverturesComplementaires])
|
241
242
|
}
|
@@ -251,7 +252,8 @@ module Apidae
|
|
251
252
|
rates_desc: desc, rates: values, payment_methods: methods,
|
252
253
|
rates_desc_mode: rates_hash[:tarifsEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
|
253
254
|
includes: node_value(rates_hash, :leTarifComprend, *locales),
|
254
|
-
excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales)
|
255
|
+
excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales),
|
256
|
+
rates_extra: node_value(rates_hash, :complement, *locales)
|
255
257
|
}
|
256
258
|
end
|
257
259
|
end
|
@@ -334,10 +336,15 @@ module Apidae
|
|
334
336
|
end
|
335
337
|
end
|
336
338
|
|
337
|
-
def self.parse_entity_fields(information_hash, type_data_hash)
|
339
|
+
def self.parse_entity_fields(information_hash, type_data_hash, sp_hash)
|
340
|
+
entity_hash = {}
|
338
341
|
if information_hash && information_hash[:structureGestion]
|
339
|
-
{entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)}
|
342
|
+
entity_hash.merge!({entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)})
|
340
343
|
end
|
344
|
+
if sp_hash && sp_hash[:prestataireActivites]
|
345
|
+
entity_hash[:is_service_provider] = true
|
346
|
+
end
|
347
|
+
entity_hash
|
341
348
|
end
|
342
349
|
|
343
350
|
def self.node_id(node, key)
|
data/app/models/apidae/obj.rb
CHANGED
@@ -7,6 +7,7 @@ module Apidae
|
|
7
7
|
|
8
8
|
attr_accessor :locale
|
9
9
|
attr_accessor :obj_version
|
10
|
+
attr_accessor :obj_versions
|
10
11
|
|
11
12
|
store_accessor :title_data, :title
|
12
13
|
store_accessor :owner_data, :owner_name, :owner_id
|
@@ -15,12 +16,12 @@ module Apidae
|
|
15
16
|
store_accessor :attachments_data, :attachments
|
16
17
|
store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains, :area, :track,
|
17
18
|
:products, :audience, :animals, :animals_desc, :extra, :duration, :certifications, :business
|
18
|
-
store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id
|
19
|
+
store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id, :is_service_provider
|
19
20
|
store_accessor :contact_data, :telephone, :email, :website, :google, :facebook, :twitter, :yelp, :trip_advisor, :fax,
|
20
21
|
:mobile_website, :shorty_url, :contacts
|
21
22
|
store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments
|
22
23
|
store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods, :openings_extra
|
23
|
-
store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes
|
24
|
+
store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_extra
|
24
25
|
store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
|
25
26
|
store_accessor :booking_data, :booking_desc, :booking_entities
|
26
27
|
store_accessor :tags_data, :promo, :internal, :linked
|
@@ -100,6 +101,7 @@ module Apidae
|
|
100
101
|
after_initialize do
|
101
102
|
@locale = DEFAULT_LOCALE
|
102
103
|
@obj_version = DEFAULT_VERSION
|
104
|
+
@obj_versions = {}
|
103
105
|
end
|
104
106
|
|
105
107
|
def root_obj
|
@@ -111,11 +113,15 @@ module Apidae
|
|
111
113
|
end
|
112
114
|
|
113
115
|
def in_version(v)
|
114
|
-
|
115
|
-
|
116
|
-
|
116
|
+
if v == DEFAULT_VERSION && root_obj_id.nil?
|
117
|
+
@obj_version = DEFAULT_VERSION
|
118
|
+
self
|
119
|
+
else
|
120
|
+
if @obj_versions[v].nil?
|
121
|
+
@obj_versions[v] = versions.where(version: v).first
|
122
|
+
end
|
123
|
+
@obj_versions[v]
|
117
124
|
end
|
118
|
-
@cached_versions[v]
|
119
125
|
end
|
120
126
|
|
121
127
|
def in_locale(l)
|
@@ -164,6 +170,7 @@ module Apidae
|
|
164
170
|
apidae_obj
|
165
171
|
end
|
166
172
|
|
173
|
+
# Note : overrides existing fields (not a merge)
|
167
174
|
def self.populate_fields(apidae_obj, object_data, locales)
|
168
175
|
type_fields = TYPES_DATA[object_data[:type]]
|
169
176
|
apidae_obj.last_update = DateTime.parse(object_data[:gestion][:dateModification]) unless object_data[:gestion].blank?
|
@@ -183,7 +190,7 @@ module Apidae
|
|
183
190
|
object_data[:tourismeAffaires], *locales)
|
184
191
|
apidae_obj.pictures_data = ApidaeDataParser.parse_pictures_data(object_data[:illustrations], *locales)
|
185
192
|
apidae_obj.attachments_data = ApidaeDataParser.parse_attachments_data(object_data[:multimedias], *locales)
|
186
|
-
apidae_obj.entity_data = ApidaeDataParser.parse_entity_fields(object_data[:informations], object_data[type_fields[:node]])
|
193
|
+
apidae_obj.entity_data = ApidaeDataParser.parse_entity_fields(object_data[:informations], object_data[type_fields[:node]], object_data[:informationsPrestataireActivites])
|
187
194
|
apidae_obj.service_data = ApidaeDataParser.parse_service_data(object_data[:prestations], object_data[type_fields[:node]])
|
188
195
|
apidae_obj.tags_data = ApidaeDataParser.parse_tags_data(object_data[:presentation], object_data[:criteresInternes], object_data[:liens])
|
189
196
|
apidae_obj.meta_data = object_data[:metadonnees]
|
@@ -10,7 +10,7 @@ module Apidae
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.import(refs_json)
|
13
|
-
|
13
|
+
locales = Rails.application.config.respond_to?(:apidae_locales) ? Rails.application.config.apidae_locales : [DEFAULT_LOCALE]
|
14
14
|
locales_map = Hash[locales.map {|loc| ["libelle#{loc.camelize.gsub('-', '')}".to_sym, loc]}]
|
15
15
|
refs_hashes = JSON.parse(refs_json, symbolize_names: true)
|
16
16
|
if refs_hashes.length != where("apidae_type != ?", INTERNAL).count
|
@@ -92,9 +92,10 @@ module Apidae
|
|
92
92
|
query_api(query_args, true, false)
|
93
93
|
end
|
94
94
|
|
95
|
-
|
95
|
+
# Note : WARNING - updated obj will only contain the provided fields
|
96
|
+
def add_or_refresh_obj(apidae_obj_id, fields = ["@all"])
|
96
97
|
if valid_api?
|
97
|
-
res = api_object(apidae_obj_id)
|
98
|
+
res = api_object(apidae_obj_id, fields)
|
98
99
|
if res[:results] && res[:results].length == 1
|
99
100
|
obj_data = res[:results].first.deep_symbolize_keys
|
100
101
|
add_or_refresh(obj_data)
|
@@ -102,6 +103,7 @@ module Apidae
|
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
106
|
+
# Note : WARNING - updated objs will only contain the provided fields
|
105
107
|
def add_or_refresh_objs(fields = ["@all"])
|
106
108
|
if valid_api?
|
107
109
|
res = api_objects({fields: fields})
|
@@ -8,9 +8,10 @@ module Apidae
|
|
8
8
|
LOCALE_ZH = 'zh'
|
9
9
|
LOCALE_ES = 'es'
|
10
10
|
LOCALE_PT_BR = 'pt-BR'
|
11
|
+
LOCALE_JP = 'jp'
|
11
12
|
|
12
13
|
DEFAULT_LOCALE = LOCALE_FR
|
13
|
-
ALL_LOCALES = [LOCALE_FR, LOCALE_EN, LOCALE_IT, LOCALE_DE, LOCALE_NL, LOCALE_RU, LOCALE_ZH, LOCALE_ES, LOCALE_PT_BR]
|
14
|
+
ALL_LOCALES = [LOCALE_FR, LOCALE_EN, LOCALE_IT, LOCALE_DE, LOCALE_NL, LOCALE_RU, LOCALE_ZH, LOCALE_ES, LOCALE_PT_BR, LOCALE_JP]
|
14
15
|
|
15
16
|
STANDARD_VERSION = 'STANDARD'
|
16
17
|
WINTER_VERSION = 'HIVER'
|
@@ -24,8 +25,11 @@ module Apidae
|
|
24
25
|
ALL_VERSIONS = [STANDARD_VERSION, WINTER_VERSION, SUMMER_VERSION, CHALLENGED_VERSION, BUSINESS_VERSION,
|
25
26
|
GROUPS_VERSION, ACTIVITIES_VERSION]
|
26
27
|
|
27
|
-
LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments,
|
28
|
-
:includes, :excludes, :extra, :booking_desc]
|
29
|
-
ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website,
|
28
|
+
LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments,
|
29
|
+
:openings_desc, :rates_desc, :includes, :excludes, :extra, :booking_desc]
|
30
|
+
ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website,
|
31
|
+
:google, :facebook, :twitter, :yelp, :trip_advisor, :fax, :mobile_website, :shorty_url,
|
32
|
+
:openings, :rates, :services, :payment_methods, :categories, :themes, :labels, :chains,
|
33
|
+
:classification, :challenged, :environments, :languages, :products, :animals,
|
30
34
|
:equipments, :comfort, :activities, :promo, :internal, :linked]
|
31
35
|
end
|
data/lib/apidae/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apidae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Vilain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|