Class: SBF::Client::DeduplicatorMatchEndpoint

Inherits:
EntityEndpoint show all
Defined in:
lib/stbaldricks/endpoints/deduplicator_match.rb

Instance Attribute Summary

Attributes inherited from EntityEndpoint

#orig_target_class

Instance Method Summary collapse

Methods inherited from EntityEndpoint

#aggregate, #create, #delete, #find, #find_first, #get, #initialize, #save, #update

Constructor Details

This class inherits a constructor from SBF::Client::EntityEndpoint

Instance Method Details

#checkout(filter = [], order = {}, limit = 20, offset = 0, with = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/stbaldricks/endpoints/deduplicator_match.rb', line 6

def checkout(filter = [], order = {}, limit = 20, offset = 0, with = {})
  filter = filter.to_json unless filter.is_a? String
  order = order.to_json unless order.is_a? String
  with = normalize_with(with)

  response = SBF::Client::Api::Request.get_request(
    "/#{SBF::Client::Api::VERSION}/deduplicator_match/checkout",
    filter: filter, order: order, limit: limit, offset: offset, with: with
  )
  parsed_response_body = JSON.parse(response.body).symbolize!

  if ok?(response)
    parsed_response_body[:results].map! { |entity_data| target_class.new(entity_data, true) }
    SBF::Client::EntityCollection.new(parsed_response_body[:results], parsed_response_body[:total_count])
  else
    parsed_response_body = JSON.parse(response.body).symbolize!
    error = SBF::Client::ErrorEntity.new(parsed_response_body)
    SBF::Client::Api::Response.new(http_code: response.code, data: parsed_response_body[:data], error: error)
    collection = SBF::Client::EntityCollection.new
    collection.add_errors(error)
    collection.errors_http_code = response.code
    collection
  end
end