Sha256: ed94392f85adb1c45b0c5f24f7df10e5012151884bbb5028d0f52ef01b918341

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'helper'

describe Acoustic::Client::Contact do
  before do
    @client = Acoustic::Client.new({access_token: "abc123",url: 'https://api-campaign-us-1.goacoustic.com'})
  end

  describe "#add_recipient" do
    it "should add a recipient to an existing database" do
      stub_post("/XMLAPI").
        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", 'Authorization' => 'Bearer abc123'})

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

    it "should add a recipient to an existing database with options" do
      stub_post("/XMLAPI").
        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", 'Authorization' => 'Bearer abc123'})

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
goacoustic-0.1.0 spec/client/contact_spec.rb