{"action":"created","issue":{"url":"https://api.github.com/repos/intercom/intercom-ruby/issues/349","repository_url":"https://api.github.com/repos/intercom/intercom-ruby","labels_url":"https://api.github.com/repos/intercom/intercom-ruby/issues/349/labels{/name}","comments_url":"https://api.github.com/repos/intercom/intercom-ruby/issues/349/comments","events_url":"https://api.github.com/repos/intercom/intercom-ruby/issues/349/events","html_url":"https://github.com/intercom/intercom-ruby/issues/349","id":241717907,"number":349,"title":"Raise named exception when attemping mailing an unsubscribed user","user":{"login":"P9GIT","id":1391014,"avatar_url":"https://avatars0.githubusercontent.com/u/1391014?v=4","gravatar_id":"","url":"https://api.github.com/users/P9GIT","html_url":"https://github.com/P9GIT","followers_url":"https://api.github.com/users/P9GIT/followers","following_url":"https://api.github.com/users/P9GIT/following{/other_user}","gists_url":"https://api.github.com/users/P9GIT/gists{/gist_id}","starred_url":"https://api.github.com/users/P9GIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/P9GIT/subscriptions","organizations_url":"https://api.github.com/users/P9GIT/orgs","repos_url":"https://api.github.com/users/P9GIT/repos","events_url":"https://api.github.com/users/P9GIT/events{/privacy}","received_events_url":"https://api.github.com/users/P9GIT/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-07-10T13:47:24Z","updated_at":"2017-08-21T13:31:53Z","closed_at":null,"body":"Hi.\r\n\r\nSometimes we get this exception from the Intercom API where a user has unsubscribed from mails from our Intercom account when our app tries to send critical system mails. \r\nUnfortunately it is not possible in Intercom's unsubscribe feature to differentiate between e.g. news letters and critical system mail notifications to users. All mails are blocked. \r\nBeing able to block all mail is of course a good feature for the end user to protect himself, but some of our active customers simply wish to unsubscribe from our news letters and in the consequence this will also block important system mails (that they with all probability DO want to and SHOULD receive).\r\n\r\nIn any case, the current behavior makes it hard to catch the error when a mail is attempted to be sent to a user that has unsubscribed from emails. This involves a not so pretty reg-ex'ing the error text.\r\n\r\n## Version info\r\n  - intercom-ruby version:  3.5.16\r\n  - Ruby version: 2.2.5\r\n\r\n## Expected behavior\r\n\r\nEither:\r\nraise exception e.g. \"UnsubscribedMailError\" to fail graciously\r\nOR preferred:\r\nallow more fine grained unsubscription feature to allow some mails to be sent, e.g. critical system mails.\r\nWe use Intercom for sending important mails such as warnings about expiring credit cards and changes to user's account settings and subscriptions.\r\n\r\n## Actual behavior\r\n\r\nIntercom::UnexpectedError is raised.\r\n\r\n## Steps to reproduce\r\n 1. Unsubscribe a user from receiving emails\r\n 2. Attempt to send e.g. a admin initiated mail to the user\r\n 3. Observe Intercom::UnexpectedError is raised\r\n\r\n## Logs\r\n\r\nAn Intercom::UnexpectedError occurred in background at 2017-07-07 23:00:20 UTC :\r\n\r\n  The error of type '' is not recognized. It occurred with the message: This user is unsubscribed from emails and http_code: '403'. Please contact Intercom with these details.\r\n   /var/www/portal/vendor/bundle/ruby/2.2.0/gems/intercom-3.5.16/lib/intercom/request.rb:94:in `parse_body'\r\n  /var/www/portal/vendor/bundle/ruby/2.2.0/gems/intercom-3.5.16/lib/intercom/request.rb:70:in `block in execute'\r\n  /usr/local/rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/http.rb:853:in `start'\r\n  /var/www/portal/vendor/bundle/ruby/2.2.0/gems/intercom-3.5.16/lib/intercom/request.rb:65:in `execute'\r\n  /var/www/portal/vendor/bundle/ruby/2.2.0/gems/intercom-3.5.16/lib/intercom/client.rb:111:in `execute_request'\r\n  /var/www/portal/vendor/bundle/ruby/2.2.0/gems/intercom-3.5.16/lib/intercom/client.rb:92:in `post'\r\n  /var/www/portal/vendor/bundle/ruby/2.2.0/gems/intercom-3.5.16/lib/intercom/api_operations/save.rb:27:in `save'\r\n  /var/www/portal/vendor/bundle/ruby/2.2.0/gems/intercom-3.5.16/lib/intercom/api_operations/save.rb:19:in `create'\r\n"},"comment":{"url":"https://api.github.com/repos/intercom/intercom-ruby/issues/comments/323744708","html_url":"https://github.com/intercom/intercom-ruby/issues/349#issuecomment-323744708","issue_url":"https://api.github.com/repos/intercom/intercom-ruby/issues/349","id":323744708,"user":{"login":"P9GIT","id":1391014,"avatar_url":"https://avatars0.githubusercontent.com/u/1391014?v=4","gravatar_id":"","url":"https://api.github.com/users/P9GIT","html_url":"https://github.com/P9GIT","followers_url":"https://api.github.com/users/P9GIT/followers","following_url":"https://api.github.com/users/P9GIT/following{/other_user}","gists_url":"https://api.github.com/users/P9GIT/gists{/gist_id}","starred_url":"https://api.github.com/users/P9GIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/P9GIT/subscriptions","organizations_url":"https://api.github.com/users/P9GIT/orgs","repos_url":"https://api.github.com/users/P9GIT/repos","events_url":"https://api.github.com/users/P9GIT/events{/privacy}","received_events_url":"https://api.github.com/users/P9GIT/received_events","type":"User","site_admin":false},"created_at":"2017-08-21T13:31:53Z","updated_at":"2017-08-21T13:31:53Z","body":"Hi @choran \r\n\r\nI have asked CS about the unsubscribe feature scope.\r\n\r\nThank you for checking this out in the API!\r\n\r\nThomas."}}
{"actor":{"display_login":"P9GIT"}}