Module: SilverPop::Client::Reporting

Included in:
SilverPop::Client
Defined in:
lib/client/reporting.rb

Instance Method Summary collapse

Instance Method Details

#get_job_status(job_id) ⇒ Mash

GetJobStatus - After initiating a data job, you can monitor the status of the job using this operation.

Examples:

Get Job Status for JOB_ID 1234

s = SilverPop.new({access_token: "abc123", url: "https://api1.silverpop.com"})
s.get_job_status(1234)

Parameters:

  • job_id (Integer)

    The Job ID of the data job

Returns:

  • (Mash)

    Mashify body from the API call



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/client/reporting.rb', line 84

def get_job_status(job_id)
  builder = Builder::XmlMarkup.new
  xml = builder.Envelope {
    builder.Body {
      builder.GetJobStatus {
        builder.JOB_ID job_id
        }
      }
    }
  post(xml)
end

#get_sent_mailings_for_org(date_start, date_end, options = {}) ⇒ Mash

GetSentMailingsForOrg - This interface extracts a listing of mailings sent for an organization for a specified date range.

Examples:

Get sent mailing for organization for 1/1/2014 to 1/2/2014

s = SilverPop.new({access_token: "abc123", url: "https://api1.silverpop.com"})
s.get_sent_mailings_for_org("1/1/2014", "1/2/2014)

Parameters:

  • date_start (String)

    Starting Date in the format “mm/dd/yyyy hh:mm:ss”

  • date_end (String)

    Required Ending Date in the format “mm/dd/yyyy hh:mm:ss”

  • options (Hash) (defaults to: {})

    Optional parameters to send

Returns:

  • (Mash)

    Mashify body from the API call



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/client/reporting.rb', line 14

def get_sent_mailings_for_org(date_start, date_end, options={})
  builder = Builder::XmlMarkup.new
  xml = builder.Envelope {
    builder.Body {
      builder.GetSentMailingsForOrg {
        unless options.empty?
          options.each do |o|
              builder.tag! o[0], o[1]
          end
        end
        builder.DATE_START date_start
        builder.DATE_END date_end
        }
      }
    }
  post(xml)
end

#raw_recipient_data_export(query_params = {}, options = {}, columns = []) ⇒ Mash

RawRecipientDataExport - Allows exporting unique contact-level events and creates a .zip file containing a single flat file with all metrics

Examples:

Export raw data events for mailing id

s = SilverPop.new({access_token: "abc123", url: "https://api1.silverpop.com"})
s.raw_recipient_data_export({MAILING_ID: 1234},{MOVE_TO_FTP: nil})

Parameters:

  • query_params (Hash) (defaults to: {})

    The list of fields to run the query against MAILING_ID, REPORT_ID, etc.

  • options (Hash) (defaults to: {})

    The various options on how to export the data EXPORT_FORMAT, FILE_ENCODING, etc.

  • columns (Array) (defaults to: [])

    Optional list of columns to limit the flat file.

Returns:

  • (Mash)

    Mashify body from the API call



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/client/reporting.rb', line 41

def raw_recipient_data_export(query_params={}, options={}, columns=[])
  builder = Builder::XmlMarkup.new
  xml = builder.Envelope {
    builder.Body {
      builder.RawRecipientDataExport {
        unless query_params.empty?
          query_params.each do |q|
            if q[0] == :MAILING_ID || q[0] == :REPORT_ID
              builder.MAILING {
                builder.tag! q[0], q[1]
              }
            else
              builder.tag! q[0], q[1]
            end
          end
        end
        unless options.empty?
          options.each do |opt|
            builder.tag! opt[0], opt[1]
          end
        end
        unless columns.empty?
          builder.COLUMNS {
            columns.each do |column|
              builder.COLUMN {
                builder.NAME column
              }
            end
          }
        end
        }
      }
    }
  post(xml)
end