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.post_request(
    "#{base_uri}/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

#list_checkoutsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/stbaldricks/endpoints/deduplicator_match.rb', line 31

def list_checkouts
  response = SBF::Client::Api::Request.post_request(
    "#{base_uri}/list_checkouts"
  )
  parsed_response_body = JSON.parse(response.body).symbolize!

  if ok?(response)
    data = parsed_response_body
  else
    error = SBF::Client::ErrorEntity.new(parsed_response_body)
  end

  SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
end

#release_checkout(checkout_id) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/stbaldricks/endpoints/deduplicator_match.rb', line 46

def release_checkout(checkout_id)
  response = SBF::Client::Api::Request.post_request(
    "#{base_uri}/release_checkout", checkout_id: checkout_id
  )
  parsed_response_body = JSON.parse(response.body).symbolize!

  if ok?(response)
    data = parsed_response_body
  else
    error = SBF::Client::ErrorEntity.new(parsed_response_body)
  end

  SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error)
end