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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f64c4285e902e34390d654a1766180aebae9a4c3bb483286d442b02284813390
4
- data.tar.gz: c85fc16b8bd2179865d3d75709be1b44a15d17aded4ae5ee6a2820bbf16e0488
3
+ metadata.gz: 36a94743894d1780d9502732ea12d63065c0d45df4553d84dc37a766600a7dc4
4
+ data.tar.gz: d3aa3192857584c40fefe7596998039cf3c9497f88532985ee7d0b36cf4dc1db
5
5
  SHA512:
6
- metadata.gz: 59ba939131882022370de145757b09fc5c3b03775314ee08e298d383d0cf6a2d7796ae98706cf98b806dcd58ed7df5d6fd07656ec811df3b0d136775f5abf926
7
- data.tar.gz: 2df0e98f4da6fc84658faf26632b65e52574efea36dea08b11131dfd5234b43f3612693efbf5d741e11c7c2fe0f924989ea7496db57e39c01a89c8d57756292a
6
+ metadata.gz: c7fefc47d7faaadc70d2dbe0ff406164eee1e8994dfaf8dd32991c35223ffe545d815585b42aeb6a121046dbc0ba472e4600ab84f62fa114ffd953f9c91d1598
7
+ data.tar.gz: 7623409b3827a3e5fee64302a593d232761ef3a84f6212371121e7100b8d3fa70bcacf12eaca95d4f85fd542da255a547c256b8fece821471061f9eba323a4d3
@@ -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) { [] }
@@ -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
- self.first
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
 
@@ -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
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trophonius
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6.4
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kempen Automatisering