Skip to content

find_by_email method does not follow osdi encapsulation rules exactly #24

@matthewbretherton

Description

@matthewbretherton

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions