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, 8 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, 8 years ago

Well answered Doug!

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


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

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

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free