-
Notifications
You must be signed in to change notification settings - Fork 4
Description
A request for an email with an apostrophe (') in it returned an error from Action Network
A lucky guess found that a two apostrophes ('') (as per mysql encapsulation) worked
Further reading on osdi found documentation that a single apostrophe in a search query needs to be escaped with another single apostrophe
My monkey patch
module ActionNetworkRest
class People < Base
def find_by_email(email)
# This works for parsing exactly 1 person's info out of the response.
# The response we get from Action Network is expected to have
#
# "_embedded": {
# "osdi:people": [{
# "identifiers": [
# "action_network:c947bcd0-929e-11e3-a2e9-12313d316c29"
# ....
# ]
# }]
# }
#
osdi_encoded_string = email.gsub("'","''")
url_encoded_filter_string = url_escape("email_address eq '#{osdi_encoded_string}'")
response = client.get_request "#{base_path}?filter=#{url_encoded_filter_string}"
person_object = response.body[:_embedded][osdi_key].first
set_action_network_id_on_object(person_object) if person_object.present?
end
end
end