belong-inc / go-hubspot

HubSpot API Go client
Apache License 2.0
35 stars 26 forks source link

Fix company property types #25

Closed joidegn closed 11 months ago

joidegn commented 11 months ago

What to do

The property types for the company model seems to be incorrect. This fixes them.

Background

For unclear reasons Hubspot uses strings for basically everything.

Here is an example for a response from them to confirm this:

"{\"id\":\"15278289572\",\"properties\":{\"about_us\":null,\"address\":\"Am Mainufer\",\"address2\":null,\"annualrevenue\":null,\"city\":\"Frankfurt\",\"closedate\":null,\"country\":null,\"createdate\":\"2023-03-24T09:21:14.582Z\",\"days_to_close\":null,\"description\":null,\"domain\":\"piedpiper.finn.com\",\"engagements_last_meeting_booked\":null,\"engagements_last_meeting_booked_campaign\":null,\"engagements_last_meeting_booked_medium\":null,\"engagements_last_meeting_booked_source\":null,\"facebook_company_page\":null,\"facebookfans\":null,\"first_contact_createdate\":\"2020-10-17T15:04:23.187Z\",\"first_conversion_date\":\"2022-02-21T17:34:56.897Z\",\"first_conversion_event_name\":\"b2b: B2B Form\",\"first_deal_created_date\":\"2023-03-24T09:35:15.784Z\",\"founded_year\":null,\"googleplus_page\":null,\"hs_analytics_first_timestamp\":\"2020-10-17T15:04:23.176Z\",\"hs_analytics_first_touch_converting_campaign\":null,\"hs_analytics_first_visit_timestamp\":\"2022-02-22T13:39:05.891Z\",\"hs_analytics_last_timestamp\":\"2023-11-30T15:58:37.552Z\",\"hs_analytics_last_touch_converting_campaign\":null,\"hs_analytics_last_visit_timestamp\":\"2023-11-30T15:58:37.552Z\",\"hs_analytics_latest_source\":\"DIRECT_TRAFFIC\",\"hs_analytics_latest_source_data_1\":\"www.finn.com/de-de\",\"hs_analytics_latest_source_data_2\":\"\",\"hs_analytics_latest_source_timestamp\":\"2023-11-30T15:58:37.552Z\",\"hs_analytics_num_page_views\":\"4803\",\"hs_analytics_num_visits\":\"615\",\"hs_analytics_source\":\"OFFLINE\",\"hs_analytics_source_data_1\":\"SALES\",\"hs_analytics_source_data_2\":\"EMAIL_INTEGRATION\",\"hs_created_by_user_id\":\"25543598\",\"hs_createdate\":null,\"hs_ideal_customer_profile\":null,\"hs_is_target_account\":null,\"hs_last_booked_meeting_date\":\"2022-09-12T08:30:00Z\",\"hs_last_logged_call_date\":null,\"hs_last_open_task_date\":\"2023-04-13T06:00:00Z\",\"hs_last_sales_activity_timestamp\":null,\"hs_lastmodifieddate\":\"2023-12-07T15:36:30.343Z\",\"hs_lead_status\":null,\"hs_merged_object_ids\":null,\"hs_num_blockers\":\"0\",\"hs_num_child_companies\":\"0\",\"hs_num_contacts_with_buying_roles\":\"0\",\"hs_num_decision_makers\":\"0\",\"hs_num_open_deals\":\"2\",\"hs_object_id\":\"15278289572\",\"hs_parent_company_id\":\"\",\"hs_total_deal_value\":\"\",\"hubspot_owner_assigneddate\":\"2023-12-01T10:03:04.047Z\",\"hubspot_owner_id\":\"107981110\",\"hubspot_team_id\":\"586140\",\"industry\":null,\"is_public\":null,\"lifecyclestage\":\"lead\",\"linkedin_company_page\":null,\"linkedinbio\":null,\"name\":\"Pied Piper\",\"notes_last_contacted\":\"2023-10-10T11:44:00.592Z\",\"notes_last_updated\":\"2023-10-10T11:44:00.592Z\",\"notes_next_activity_date\":\"\",\"num_associated_contacts\":\"49\",\"num_associated_deals\":\"8\",\"num_contacted_notes\":\"27\",\"num_conversion_events\":\"53\",\"numberofemployees\":null,\"phone\":\"+4917634194402\",\"recent_conversion_date\":\"2023-10-16T13:29:33.228Z\",\"recent_conversion_event_name\":\"PDP: Coming Soon: Deal Creation Form\",\"recent_deal_amount\":null,\"recent_deal_close_date\":\"\",\"state\":null,\"timezone\":null,\"total_money_raised\":null,\"total_revenue\":\"\",\"twitterbio\":null,\"twitterfollowers\":null,\"twitterhandle\":null,\"type\":null,\"web_technologies\":null,\"website\":\"piedpiper.finn.com\",\"zip\":\"60321\"},\"createdAt\":\"2023-03-24T09:21:14.582Z\",\"updatedAt\":\"2023-12-07T15:36:30.343Z\",\"archived\":false}"

Acceptance criteria

It's possible to request Companies data from the CRM endpoints.

joidegn commented 11 months ago

Im very sorry, I got confused with the github UI. I meant to open a separate PR for commit 6f6b2450a4c970ea168bbfeb6015bb49e5cc3678 but I somehow added it to this PR. Im not really sure how I can fix that. I attempted to rebase and force push to this PR but failed.

Shall I close and reopen two separate PRs?

joidegn commented 11 months ago

Oh man! I also only noticed now that company_model.go was generated 🤦

Looking at the generator code it seems that it expects a CSV as input. Not sure where the discrepancy comes from but I seem to be getting a different type from the API (see response above) than was in the CSV used for the generator.

joidegn commented 11 months ago

Digging some more I realise that the CSV that is exported "lies" about the data type because e.g. HubspotObjectID is clearly returned as a string by the API. My guess is that number in Hubspot is some number type that gets converted to string when encoded as json.

Screenshot 2023-12-13 at 15 19 37
kk-no commented 11 months ago

Hi, @joidegn ! Thank you for reporting. Please give us some time as we investigate and decide on a policy. When generating the model, you may need to make changes such as using HsStr even for Number fields. There is no problem with creating a new pull request, so I will leave it up to you :)