Result Codes - Ruby Library

Can someone please tell me why this doesn't work:

require 'campaign_monitor'
list ='0123456789')
puts('','John Doe')).code)

Here is what I get:

/usr/lib/ruby/1.8/campaign_monitor/result.rb:7:in `initialize': undefined method `[]' for #<CampaignMonitor::Result:0xb7c4d5f8 @message="Success", @code=0> (NoMethodError)
    from ./test2:4:in `new'
    from ./test2:4

Thanks very much for any input.  I think this is about my last hurdle on this thing.

        ... doug

djolley, 7 years ago

I'll answer my own question just in case someone else has this problem.

The reason is that one doesn't do it that way.  To get at the result codes, do something like this:

list.add_subscriber('','John Doe').code

          ... doug

Mathew Mathew, 7 years ago

Well answered Doug!

Get in touch with us on Twitter:
We're also on Facebook:
jeremy, 7 years ago


I recommend stashing the result in a variable, and getting the code from the result object.

result = list.add_subscriber('','John Doe')

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free