oohira / intercom-java

[DEPRECATED] A Java client library for Intercom web service
https://oohira.github.io/intercom-java/
MIT License
6 stars 5 forks source link

Company custom data is incorrectly passed to Intercom API #2

Closed olmeras closed 10 years ago

olmeras commented 10 years ago

The json the library generates for Company's custom properties is not working properly with Intercom API.

If your add email custom property the json generated is:

{
  "custom_data" : {
    "team_mates" : 7,
    "app_name" : "Genesis",
    "monthly_spend" : 155.5
  },
  "created_at" : 1270000000,
  "last_seen_user_agent" : "ie6",
  "email" : "john.doe@example.com",
  "user_id" : "abc123",
  "last_impression_at" : 1300000000,
  "last_seen_ip" : "1.2.3.4",
  "name" : "John Doe",
  "companies" : [
    {
      "id" : "6",
      "name" : "Intercom",
      "custom_data" : {
         "email" : "jhon@doe.com"
      }
    }
  ]
}

when it should be

{
  "custom_data" : {
    "team_mates" : 7,
    "app_name" : "Genesis",
    "monthly_spend" : 155.5
  },
  "created_at" : 1270000000,
  "last_seen_user_agent" : "ie6",
  "email" : "john.doe@example.com",
  "user_id" : "abc123",
  "last_impression_at" : 1300000000,
  "last_seen_ip" : "1.2.3.4",
  "name" : "John Doe",
  "companies" : [
    {
      "id" : "6",
      "name" : "Intercom",
      "email" : "jhon@doe.com"
    }
  ]
}
oohira commented 10 years ago

Thanks for your bug report & pull request! I'm sorry that such a fundamental bug is embedded. Please give me some time to check it out.

oohira commented 10 years ago

I fixed this bug in 18df587be66525616ac5272429b9d71ab7204d38 merging some of your code with additional test code. Thanks for your great contribution, and I'm sorry that I did not wait your code modification.