Class: Trophonius::Single
- Inherits:
-
Object
- Object
- Trophonius::Single
- Defined in:
- lib/trophonius_single.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
-
#initialize(config:) ⇒ Single
constructor
A new instance of Single.
- #where(fieldData) ⇒ Object
Constructor Details
#initialize(config:) ⇒ Single
Returns a new instance of Single.
10 11 12 13 14 15 |
# File 'lib/trophonius_single.rb', line 10 def initialize(config:) @config = config @query = {} @translations = {} @all_fields = {} end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
9 10 11 |
# File 'lib/trophonius_single.rb', line 9 def query @query end |
Instance Method Details
#where(fieldData) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/trophonius_single.rb', line 17 def where(fieldData) url = URI( URI.escape( "http#{@config[:ssl] == true ? 's' : ''}://#{@config[:host]}/fmi/data/v1/databases/#{@config[:database]}/layouts/#{ @config[:layout_name] }/_find" ) ) @query.merge!(query: [fieldData]) @query.merge!(limit: '10000000') token = setup_connection response = make_request(url, token, 'post', @query.to_json) r_results = response['response']['data'] if response['messages'][0]['code'] != '0' && response['messages'][0]['code'] != '401' Error.throw_error(response['messages'][0]['code']) elsif response['messages'][0]['code'] == '401' return RecordSet.new(@config[:layout_name], @config[:non_modifiable_fields]) else ret_val = RecordSet.new(@config[:layout_name], @config[:non_modifiable_fields]) r_results.each do |r| hash = build_result(r) ret_val << hash end end @query = {} close_connection(token) return ret_val end |