Skip to content

get_all_chats issue #1

@ksob

Description

@ksob

I am trying to use get_all_chats method like this:

begin
result = api_instance.get_all_chats(page: 1, limit: 10)
puts result.resources[0].text
rescue TextMagic::ApiError => e
puts "Exception when calling TextMagicApi->get_all_outbound_messages: #{e}"
end

Unfortunately it is throwing an error:
*** NoMethodError Exception: undefined method `build_from_hash' for []:Array

Here I am trying to debug it with byebug:

[209, 218] in /home/p/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/bundler/gems/textmagic-rest-ruby-v2-fb82680f0cf8/lib/textmagic_rest_client/api_client.rb
209: data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
210: end
211: else
212: # models, e.g. Pet
213: TextMagic.const_get(return_type).new.tap do |model|
=> 214: model.build_from_hash data
215: end
216: end
217: end
218:
(byebug) data
{:page=>1, :limit=>10, :pageCount=>1, :resources=>[{:id=>13921468, :originalId=>nil, :phone=>"1111111111", :contact=>nil, :unsubscribedContactId=>nil, :unread=>0, :updatedAt=>"2020-11-18T18:17:29+0000", :status=>"a", :mute=>0, :lastMessage=>......................
(byebug) model.class
TextMagic::GetAllChatsPaginatedResponse
(byebug) model
#TextMagic::GetAllChatsPaginatedResponse:0x007f81a415f540
(byebug) model.build_from_hash data
*** NoMethodError Exception: undefined method `build_from_hash' for []:Array

nil

I am using:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
gem in version:
revision: fb82680f0cf8d62dd7898e16433ea06b7223acc8
tag: v2.0.1588

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions