rosette_api 1.37.0 → 1.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 648715b05a66f8b54708e36ae3a6548d8a07c0e06f5c225060a1a7c02fea6208
4
- data.tar.gz: 15a9eb85d4df30ee6b6de01fb2f0b4ca48863b3da492c95793784b46a514c58d
3
+ metadata.gz: b42de9a42f1c759a302a9a3b0f294043af5497ca008beae9fe65c4237c0296f7
4
+ data.tar.gz: 1bdd902d3e79abc9e3ccaac62db43b545ac5c97e254b0e8b54811355adb1ecd4
5
5
  SHA512:
6
- metadata.gz: d9f43d9d0333720b3ad08e7460ea92fbeffbd22b3e4f445b21b51f50a74b14ee3b5eb7677a0af8a444f0aa3f718d0e7ca8ad59ff3f3187ae665b2f81f0a83adf
7
- data.tar.gz: 5b404dd299bc6e06964d19cbe51c71b3f1efa266d631ac462d31be85f058dfbdba130964092572df5596988b97367f605377f0ab31a17da689ead9ba04e34fe0
6
+ metadata.gz: cb81f982495d805b8cb049966bac828cb6afe29a0c5636b046db51c3966fc2faa23bdcdc2a899b9ca0e68454b561d25be0214c6fab47f1b7c306fd0dd2cb51e8
7
+ data.tar.gz: bd02c52aed880614d08eb347de9a952d028d450c1b870fe05a18b10a5d8ba50d1aa276640183f9e9dd5a97e710dbab8b4d3fba0052146b88f352d21c96718b67
@@ -14,14 +14,35 @@ class RecordSimilarityParameters
14
14
  # Optional properties map sent to the API (optional, should be a hash)
15
15
  attr_accessor :properties
16
16
 
17
- def initialize(fields, records, properties = nil) # :notnew:
17
+ # Comparison method (one_to_one, one_to_n, n_to_m) (optional)
18
+ attr_accessor :comparison_method
19
+
20
+ VALID_COMPARISON_METHODS = %w[one_to_one one_to_n n_to_m].freeze
21
+
22
+ def initialize(fields, records, properties = nil, comparison_method: nil, **property_keywords) # :notnew:
23
+ properties_msg = 'properties must be passed either positionally or as keywords, not both'
24
+ raise ArgumentError.new(properties_msg) unless properties.nil? || property_keywords.empty?
25
+
18
26
  @fields = fields
19
27
  @records = records
20
- @properties = properties
28
+ # Preserve legacy calls such as new(fields, records, threshold: 0.7).
29
+ @properties = property_keywords.empty? ? properties : property_keywords
30
+ @comparison_method = comparison_method
31
+
32
+ validate_comparison_method
33
+ end
34
+
35
+ def validate_comparison_method
36
+ return if @comparison_method.nil?
37
+
38
+ normalized = @comparison_method.to_s.downcase
39
+ return if VALID_COMPARISON_METHODS.include?(normalized)
40
+
41
+ raise ArgumentError.new("comparison_method must be one of: #{VALID_COMPARISON_METHODS.join(', ')}")
21
42
  end
22
43
 
23
44
  # Validates the parameters by checking if required fields are present and
24
- # optional properties is a Hash if provided.
45
+ # optional properties is a Hash and comparison method is valid if provided.
25
46
  def validate_params
26
47
  f_msg = 'fields option is required'
27
48
  raise BadRequestError.new(f_msg) if @fields.nil?
@@ -43,6 +64,8 @@ class RecordSimilarityParameters
43
64
 
44
65
  p_msg = 'properties can only be an instance of a Hash'
45
66
  raise BadRequestError.new(p_msg) if @properties && !(@properties.is_a? Hash)
67
+
68
+ validate_comparison_method
46
69
  end
47
70
 
48
71
  # Converts this class to Hash with its keys in lower CamelCase.
@@ -62,7 +85,8 @@ class RecordSimilarityParameters
62
85
  {
63
86
  fields: @fields,
64
87
  records: @records,
65
- properties: @properties
88
+ properties: @properties,
89
+ comparison_method: @comparison_method&.to_s&.downcase
66
90
  }
67
91
  end
68
92
  end
data/lib/rosette_api.rb CHANGED
@@ -15,7 +15,7 @@ require 'logger'
15
15
  # This class allows you to access all Analytics API endpoints.
16
16
  class RosetteAPI
17
17
  # Version of Ruby binding
18
- BINDING_VERSION = '1.37.0'
18
+ BINDING_VERSION = '1.39.0'
19
19
  # API address-similarity endpoint
20
20
  ADDRESS_SIMILARITY_ENDPOINT = '/address-similarity'
21
21
  # API categories endpoint
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosette_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.37.0
4
+ version: 1.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Analytics by Babel Street
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubygems_version: 4.0.6
92
+ rubygems_version: 4.0.20
93
93
  specification_version: 4
94
94
  summary: A Ruby interface for Babel Street Analytics Server and Hosted Services
95
95
  test_files: []