mhenrixon / active_campaign

A simple ruby wrapper for the ActiveCampaign API

Home Page:http://www.activecampaign.com/api/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

undefined method `each_with_object' for "400":String

arthurnobrega opened this issue · comments

When running ActiveCampaign.show_contact(403) returns the following error:

Traceback (most recent call last):
        2: from (irb):4
        1: from (irb):4:in `rescue in irb_binding'
NoMethodError (undefined method `each_with_object' for "400":String)

Investigating it, I discovered that it happens only when the user is in a list, because of this method:

    # active_campaign/lib/active_campaign/transform_hash.rb:48
    def transform_value(value, *new_case)
      case value
      when Hash
        transform_keys(value, *new_case)
      when Array
        value.map { |item| transform_key(item, *new_case) }
      else
        value
      end
    end

This specific user has a contactsList field returned as:

        "contactLists": [
            "400"
        ],

Then, when trying to deal with a string as an object, it returns that error.