Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#to_i called on Hash in Crm::Lists::CollectionResponseLong #324

Open
WillRogers727 opened this issue May 31, 2024 · 1 comment
Open

#to_i called on Hash in Crm::Lists::CollectionResponseLong #324

WillRogers727 opened this issue May 31, 2024 · 1 comment

Comments

@WillRogers727
Copy link

I'm getting an error using the gem when trying to use the lists membership API.

The specific call I'm using when I get this error is api_client.crm.lists.memberships_api.get_page(list_id: list_id)
(The ID points to a list of companies)

This returns the error:

NoMethodError: undefined method 'to_i' for an instance of Hash

which comes from lib/hubspot/codegen/crm/lists/models/collection_response_long.rb:161

It looks like it's passing the _deserialize method the type :Integer for the values in the results array, when in fact these are hashes:

{:results=>
  [{:recordId=>"8408223219", :membershipTimestamp=>"2024-01-23T14:25:53.413Z"},
   {:recordId=>"9761188042", :membershipTimestamp=>"2024-01-25T15:09:03.463Z"},
   {:recordId=>"9761188073", :membershipTimestamp=>"2024-01-25T15:10:34.354Z"},
   {:recordId=>"9761188282", :membershipTimestamp=>"2024-01-25T15:11:04.134Z"},
   {:recordId=>"9761188298", :membershipTimestamp=>"2024-01-25T15:11:28.765Z"},
   {:recordId=>"9762715614", :membershipTimestamp=>"2024-01-25T15:09:17.499Z"}],
 :total=>6}

More specifically, the method is called on the line lib/hubspot/codegen/crm/lists/models/collection_response_long.rb:137

self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })

where $1 is Integer

This has ultimately come from the Hubspot::Crm::Lists::CollectionResponseLong#openapi_types method:

  def self.openapi_types
      {
        :'paging' => :'Paging',
        :'results' => :'Array<Integer>'
      }
  end

Updating this method like this seems to fix the issue:

def self.openapi_types
      {
        :'paging' => :'Paging',
        :'results' => :'Array<Hash<String, String>>',
      }
end

Though I'm not sure if there are any edge cases this might break.

Let me know if you need any other info to replicate this.

Thanks!

WillRogers727 added a commit to CharlieHR/hubspot-api-ruby that referenced this issue Jul 8, 2024
Fetching companies from a paginated list is currently broken.

The issue is described here in more detail: HubSpot#324

This commit implements the fix suggested there while we await a fix on the official gem.

The other strategy i considered here was switching to use the V1 API as we already do that for a contacts list in Charlie, as that would bypass the broken code. However according to

https://legacydocs.hubspot.com/docs/methods/lists/get_list_contacts

there is no v1 API for company based lists...
WillRogers727 added a commit to CharlieHR/hubspot-api-ruby that referenced this issue Jul 9, 2024
Fetching companies from a paginated list is currently broken.

The issue is described here in more detail: HubSpot#324

This commit implements the fix suggested there which updates the attribute type mapping in CollectionResponseLong to expect an array of hashes.
@michaelscruz
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants