trophonius 1.2.6.4 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trophonius_config.rb +1 -0
- data/lib/trophonius_model.rb +10 -1
- data/lib/trophonius_request.rb +20 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a94743894d1780d9502732ea12d63065c0d45df4553d84dc37a766600a7dc4
|
4
|
+
data.tar.gz: d3aa3192857584c40fefe7596998039cf3c9497f88532985ee7d0b36cf4dc1db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7fefc47d7faaadc70d2dbe0ff406164eee1e8994dfaf8dd32991c35223ffe545d815585b42aeb6a121046dbc0ba472e4600ab84f62fa114ffd953f9c91d1598
|
7
|
+
data.tar.gz: 7623409b3827a3e5fee64302a593d232761ef3a84f6212371121e7100b8d3fa70bcacf12eaca95d4f85fd542da255a547c256b8fece821471061f9eba323a4d3
|
data/lib/trophonius_config.rb
CHANGED
@@ -13,6 +13,7 @@ module Trophonius
|
|
13
13
|
config_accessor(:username) { 'Admin' }
|
14
14
|
config_accessor(:password) { '' }
|
15
15
|
config_accessor(:ssl) { true }
|
16
|
+
config_accessor(:fm_18) { false }
|
16
17
|
config_accessor(:count_result_script) { '' }
|
17
18
|
config_accessor(:layout_name) { '' }
|
18
19
|
config_accessor(:non_modifiable_fields) { [] }
|
data/lib/trophonius_model.rb
CHANGED
@@ -112,7 +112,16 @@ module Trophonius
|
|
112
112
|
#
|
113
113
|
# @return [Hash] translations of the fields Rails -> FileMaker
|
114
114
|
def self.create_translations
|
115
|
-
|
115
|
+
if Trophonius.config.fm_18
|
116
|
+
field_names = Trophonius::Request.get_layout_field_names(layout_name)
|
117
|
+
field_names.each do |field|
|
118
|
+
@configuration.translations.merge!(
|
119
|
+
{ "#{ActiveSupport::Inflector.parameterize(ActiveSupport::Inflector.underscore(field.to_s), separator: '_').downcase}" => "#{field}" }
|
120
|
+
)
|
121
|
+
end
|
122
|
+
else
|
123
|
+
self.first
|
124
|
+
end
|
116
125
|
@configuration.translations
|
117
126
|
end
|
118
127
|
|
data/lib/trophonius_request.rb
CHANGED
@@ -37,7 +37,6 @@ module Trophonius
|
|
37
37
|
begin
|
38
38
|
JSON.parse(temp.response_body)
|
39
39
|
rescue Exception => e
|
40
|
-
puts "Error was #{e}"
|
41
40
|
Error.throw_error('1631')
|
42
41
|
end
|
43
42
|
end
|
@@ -95,6 +94,26 @@ module Trophonius
|
|
95
94
|
make_request(url, "Bearer #{get_token}", 'get', '{}')
|
96
95
|
end
|
97
96
|
|
97
|
+
##
|
98
|
+
# Retrieves the fieldnames of a layout
|
99
|
+
#
|
100
|
+
# @return [JSON] The fieldnames of a layout
|
101
|
+
def self.get_layout_field_names(layout_name)
|
102
|
+
url =
|
103
|
+
URI(
|
104
|
+
URI.escape(
|
105
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
106
|
+
Trophonius.config.database
|
107
|
+
}/layouts/#{layout_name}"
|
108
|
+
)
|
109
|
+
)
|
110
|
+
begin
|
111
|
+
make_request(url, "Bearer #{get_token}", 'get', '{}')['response']['fieldMetaData'].map { |field| field['name'] }
|
112
|
+
rescue Exception
|
113
|
+
Error.throw_error('1631')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
98
117
|
##
|
99
118
|
# Runs a FileMaker script
|
100
119
|
#
|