apidae 1.2.4 → 1.2.9
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.
- checksums.yaml +4 -4
- data/app/models/apidae/apidae_data_parser.rb +9 -2
- 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: 2be2cf907e5a637962c70ddfde7fb4c2fab3f898
|
|
4
|
+
data.tar.gz: f71204e522ad70932deb15a8c2dd0330ddbdefa0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4176569bfe745b9f7391435ccd898cb5b3cdd2560febbca15ecd8500cdf00a7d7a01642a2ff9aa36f12c405c3db6c8e451d4c3e4ac61aa7fb7dab2cde377f824
|
|
7
|
+
data.tar.gz: e6f83af4e0b1d8688ebf5dae737ded92335d41196ec48ab7205875f8d54e11cf4971afd7ebd91bf5491a48e033ca0bcfef3c0a93ae4febb091cd32083350f4c4
|
|
@@ -151,6 +151,7 @@ module Apidae
|
|
|
151
151
|
name: localized_value(att, :nom, locale),
|
|
152
152
|
url: att[:traductionFichiers][0][:url].gsub('http:', 'https:'),
|
|
153
153
|
type: att[:type],
|
|
154
|
+
link: att[:link],
|
|
154
155
|
description: localized_value(att, :legende, locale)
|
|
155
156
|
}
|
|
156
157
|
end
|
|
@@ -236,6 +237,7 @@ module Apidae
|
|
|
236
237
|
openings_desc: node_value(openings_hash, :periodeEnClair, *locales),
|
|
237
238
|
openings_desc_mode: openings_hash[:periodeEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
|
|
238
239
|
openings: build_openings(openings_hash, *locales),
|
|
240
|
+
all_year_long: openings_hash[:ouvertTouteLAnnee] == 'OUVERT_TOUTE_L_ANNEE' ? 'true' : 'false',
|
|
239
241
|
time_periods: lists_ids(openings_hash[:indicationsPeriode]),
|
|
240
242
|
openings_extra: lists_ids(openings_hash[:ouverturesComplementaires])
|
|
241
243
|
}
|
|
@@ -335,10 +337,15 @@ module Apidae
|
|
|
335
337
|
end
|
|
336
338
|
end
|
|
337
339
|
|
|
338
|
-
def self.parse_entity_fields(information_hash, type_data_hash)
|
|
340
|
+
def self.parse_entity_fields(information_hash, type_data_hash, sp_hash)
|
|
341
|
+
entity_hash = {}
|
|
339
342
|
if information_hash && information_hash[:structureGestion]
|
|
340
|
-
{entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)}
|
|
343
|
+
entity_hash.merge!({entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)})
|
|
341
344
|
end
|
|
345
|
+
if sp_hash && sp_hash[:prestataireActivites]
|
|
346
|
+
entity_hash[:is_service_provider] = true
|
|
347
|
+
end
|
|
348
|
+
entity_hash
|
|
342
349
|
end
|
|
343
350
|
|
|
344
351
|
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,7 +16,7 @@ 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
|
|
@@ -83,7 +84,7 @@ module Apidae
|
|
|
83
84
|
COS => {node: :informationsCommerceEtService, subtype: :commerceEtServiceType},
|
|
84
85
|
DEG => {node: :informationsDegustation, subtype: :degustationType},
|
|
85
86
|
DOS => {node: :informationsDomaineSkiable, subtype: :domaineSkiableType},
|
|
86
|
-
EQU => {node: :informationsEquipement, subtype: :
|
|
87
|
+
EQU => {node: :informationsEquipement, subtype: :rubrique},
|
|
87
88
|
FEM => {node: :informationsFeteEtManifestation, subtype: :feteEtManifestationType},
|
|
88
89
|
HCO => {node: :informationsHebergementCollectif, subtype: :hebergementCollectifType},
|
|
89
90
|
HLO => {node: :informationsHebergementLocatif, subtype: :hebergementLocatifType},
|
|
@@ -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.9
|
|
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-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|