{"action":"created","issue":{"url":"https://api.github.com/repos/adimichele/hubspot-ruby/issues/108","repository_url":"https://api.github.com/repos/adimichele/hubspot-ruby","labels_url":"https://api.github.com/repos/adimichele/hubspot-ruby/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/adimichele/hubspot-ruby/issues/108/comments","events_url":"https://api.github.com/repos/adimichele/hubspot-ruby/issues/108/events","html_url":"https://github.com/adimichele/hubspot-ruby/issues/108","id":308689997,"number":108,"title":"Cannot use create_or_update! without passing email in properties","user":{"login":"Nicholas-Horton","id":6063473,"avatar_url":"https://avatars2.githubusercontent.com/u/6063473?v=4","gravatar_id":"","url":"https://api.github.com/users/Nicholas-Horton","html_url":"https://github.com/Nicholas-Horton","followers_url":"https://api.github.com/users/Nicholas-Horton/followers","following_url":"https://api.github.com/users/Nicholas-Horton/following{/other_user}","gists_url":"https://api.github.com/users/Nicholas-Horton/gists{/gist_id}","starred_url":"https://api.github.com/users/Nicholas-Horton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nicholas-Horton/subscriptions","organizations_url":"https://api.github.com/users/Nicholas-Horton/orgs","repos_url":"https://api.github.com/users/Nicholas-Horton/repos","events_url":"https://api.github.com/users/Nicholas-Horton/events{/privacy}","received_events_url":"https://api.github.com/users/Nicholas-Horton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-26T18:43:49Z","updated_at":"2018-04-03T14:43:21Z","closed_at":null,"author_association":"NONE","body":"...specifically for a set of contacts who do not have a `:vid` or the `:vid` is not known.\r\n\r\nThe [create_or_update!](https://github.com/adimichele/hubspot-ruby/blob/master/lib/hubspot/contact.rb#L73) function does not remove the`:email` from the `contact_hash`, before converting the `hash_to_properties`.\r\n\r\nI am seeing some activity logged on \"merged contacts\" (whose email has become a comma-separated list of emails), indicating the email is being changed through the API. For some reason, the email never actually changes, despite activity being logged.\r\n\r\nI'm not intending to update the `:email` field. Though, I'm not sure how to use `create_or_update!`, keeping the `:email` field as the identifier, without inadvertently modifying contacts where the email does not match up exactly. \r\n\r\nIs the email being intentionally passed in `properties:`, even when the `:email` is being used as the identifier? Any thoughts on whether or not this is an issue? \r\n\r\nI'd be happy to write up a PR. :)"},"comment":{"url":"https://api.github.com/repos/adimichele/hubspot-ruby/issues/comments/378275103","html_url":"https://github.com/adimichele/hubspot-ruby/issues/108#issuecomment-378275103","issue_url":"https://api.github.com/repos/adimichele/hubspot-ruby/issues/108","id":378275103,"user":{"login":"cbisnett","id":1154398,"avatar_url":"https://avatars0.githubusercontent.com/u/1154398?v=4","gravatar_id":"","url":"https://api.github.com/users/cbisnett","html_url":"https://github.com/cbisnett","followers_url":"https://api.github.com/users/cbisnett/followers","following_url":"https://api.github.com/users/cbisnett/following{/other_user}","gists_url":"https://api.github.com/users/cbisnett/gists{/gist_id}","starred_url":"https://api.github.com/users/cbisnett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbisnett/subscriptions","organizations_url":"https://api.github.com/users/cbisnett/orgs","repos_url":"https://api.github.com/users/cbisnett/repos","events_url":"https://api.github.com/users/cbisnett/events{/privacy}","received_events_url":"https://api.github.com/users/cbisnett/received_events","type":"User","site_admin":false},"created_at":"2018-04-03T14:43:21Z","updated_at":"2018-04-03T14:43:21Z","author_association":"COLLABORATOR","body":"I suspect what you're seeing is a bug and is related to building the properties hash where we're only excluding the `vid` and not also the `email` ([contact.rb:73](https://github.com/adimichele/hubspot-ruby/blob/master/lib/hubspot/contact.rb#L73)).\r\n\r\nMy first though was that we should add `:email` to the except call and that would solve this problem but it would also mean that it wasn't possible to use bulk update to update email addresses when the `vid` is known. I'm not sure if updating the email address of a contact is supported when the identifier used is also an email address. This might explain the strange merging behavior you're seeing with email addresses.\r\n\r\nBeing able to change the email when using a `vid` seems like functionality we should maintain. We could change the `except()` call to exclude both `:vid` and `:email` and only merge the email into the properties hash when the identifier used is a `vid`. This way when creating or updating a contact using the email as the identifier, it won't try to also change the email address."}}
{"actor":{"display_login":"cbisnett"}}