Sha256: 602e71f22d7fcae8468b252832689d2cf899eab131977105eb4ab6bf3fa5f5c0

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

require 'helper'

describe SilverPop::Client::Contact do
  before do
    @client = SilverPop::Client.new({access_token: "abc123",url: 'https://api1.silverpop.com'})
  end

  describe "#add_recipient" do
    it "should add a recipient to an existing database" do
      stub_post("/XMLAPI?access_token=abc123").
        with(:body => "<Envelope><Body><AddRecipient><LIST_ID>123</LIST_ID><CREATED_FROM>1</CREATED_FROM><CONTACT_LISTS><CONTACT_LIST_ID>456</CONTACT_LIST_ID></CONTACT_LISTS><COLUMN><NAME>email</NAME><VALUE>test@example.com</VALUE></COLUMN></AddRecipient></Body></Envelope>").
          to_return(:status => 200, :body => fixture("contact.xml"), :headers => {'Content-type' => "text/xml"})

      resp = @client.add_recipient({email:"test@example.com"}, 123, [456])
      resp.Envelope.Body.RESULT.SUCCESS.should eql "TRUE"
    end

    it "should add a recipient to an existing database with options" do
      stub_post("/XMLAPI?access_token=abc123").
        with(:body => "<Envelope><Body><AddRecipient><LIST_ID>123</LIST_ID><CREATED_FROM>1</CREATED_FROM><CONTACT_LISTS><CONTACT_LIST_ID>456</CONTACT_LIST_ID></CONTACT_LISTS><UPDATE_IF_FOUND>true</UPDATE_IF_FOUND><COLUMN><NAME>email</NAME><VALUE>test@example.com</VALUE></COLUMN></AddRecipient></Body></Envelope>").
          to_return(:status => 200, :body => fixture("contact.xml"), :headers => {'Content-type' => "text/xml"})

      resp = @client.add_recipient({email:"test@example.com"}, 123, [456], 1, {UPDATE_IF_FOUND: "true"})
      resp.Envelope.Body.RESULT.SUCCESS.should eql "TRUE"
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
silverpop-0.0.9 spec/client/contact_spec.rb
silverpop-0.0.8 spec/client/contact_spec.rb
silverpop-0.0.7 spec/client/contact_spec.rb
silverpop-0.0.6 spec/client/contact_spec.rb
silverpop-0.0.5 spec/client/contact_spec.rb
silverpop-0.0.4 spec/client/contact_spec.rb
silverpop-0.0.3 spec/client/contact_spec.rb
silverpop-0.0.2 spec/client/contact_spec.rb