lib/lexer/identity/api.rb in lexer-identity-0.2.0 vs lib/lexer/identity/api.rb in lexer-identity-0.2.1

- old
+ new

@@ -57,18 +57,19 @@ post_request body end private - def self.validate_attributes attributes - attributes.each { |k, v| + def self.validate_attributes(attributes) + attributes.each do |k, v| unless v.is_a? Hash fail Lexer::Identity::AttributePayloadError, "#{k} is not a hash" end - unless v.has_key?(:value) && v.has_key?(:confidence) + + unless [:value, :confidence].all? { |required_key| v.key?(required_key) || v.key?(required_key.to_s) } fail Lexer::Identity::AttributePayloadError, "#{k} has an invalid payload" end - } + end end def self.post_request(body) uri = URI(configuration.api_url) header = { 'Content-Type' => 'application/json' }