From c6e39b5c417a40d6fcdfd398e05bd9575fa6a73d Mon Sep 17 00:00:00 2001 From: Andy Shen Date: Wed, 30 Jul 2008 23:26:02 +1000 Subject: [PATCH] need to remove d1p1:type since campaign monitor will not be processing it and it confuses the the api method to think there are actual data to process --- lib/campaign_monitor.rb | 7 ++++--- pivot_clents.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100755 pivot_clents.rb diff --git a/lib/campaign_monitor.rb b/lib/campaign_monitor.rb index 9cd5ec7..3bc1ebc 100644 --- a/lib/campaign_monitor.rb +++ b/lib/campaign_monitor.rb @@ -71,9 +71,10 @@ def initialize(api_key=CAMPAIGN_MONITOR_API_KEY) # Takes a CampaignMonitor API method name and set of parameters; # returns an XmlSimple object with the response def request(method, *params) - response = XmlSimple.xml_in(http_get(request_url(method, params)), { 'KeepRoot' => false, - 'ForceArray' => %w[List Campaign Subscriber Client SubscriberOpen SubscriberUnsubscribe SubscriberClick SubscriberBounce], - 'NoAttr' => true }) + response = XmlSimple.xml_in(http_get(request_url(method, params)), { 'keeproot' => false, + 'forcearray' => %w[List Campaign Subscriber Client SubscriberOpen SubscriberUnsubscribe SubscriberClick SubscriberBounce], + 'noattr' => true }) + response.delete('d1p1:type') response end diff --git a/pivot_clents.rb b/pivot_clents.rb new file mode 100755 index 0000000..4f43e78 --- /dev/null +++ b/pivot_clents.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +require 'rubygems' +require 'xmlsimple' +require "pp" +require "date" +# require 'aws/s3' + +require 'lib/campaign_monitor.rb' + +CAMPAIGN_MONITOR_API_KEY = '37c8763721d8e2d4805a1fd6d8260d3830eaffe5' +current_date = Time.now + +cm = CampaignMonitor.new +pivot = cm.clients.find { |c| c.name == 'Pivot' } +lists = pivot.lists + +# lists.each { |l| pp l.active_subscribers(Date.today) } + + +# pivot's [{"ClientID"=>87554}] + +# pivot_cm = pivot.cm_client +# lists = pivot.lists +# pp lists +# +l = lists.first +# +pp l.active_subscribers(current_date)