Sha256: 30db180b3f07d982d789ad950b8123d3af50d128e7f455b41a281b6837f5b1c9

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

if !ENV['MAILCHIMP_API_KEY'].blank?
  ActiveAdmin.register_page "Campaigns" do
    menu parent: "Newsletter"

    content do
      @c = {}
      gb = Gibbon::Request.new(api_key: ENV['MAILCHIMP_API_KEY'])
      if params[:list_id]
        @c = gb.campaigns.retrieve( params: {list_id: params[:list_id]}  )
      elsif params[:campaign_id]
        @c = gb.campaigns.retrieve( params: {campaign_id: params[:campaign_id]}  )
      else
        @c = gb.campaigns.retrieve
      end

      table_for @c['campaigns'] do
        column( "subject" ) { |d| d['settings']['subject_line'] }
        column( "title" ) { |d| d['settings']['title'] }
        column( "created" ) { |d| d['create_time'] }
        column( "sent" ) { |d| d['send_time'] }
        column( "emails sent") { |d| d['emails_sent'] }
        column( "opens" ) { |d| d['report_summary'] && d['report_summary']['opens'] }
        column( "clicks" ) { |d|  d['report_summary'] && d['report_summary']['clicks'] }
        column( "unique_opens" ) { |d| d['report_summary'] && d['report_summary']['unique_opens'] }
      end
    end

    action_item do
      link_to "Go to Mailchimp", "https://login.mailchimp.com/"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
happy_seed-0.0.21 lib/generators/happy_seed/admin/templates/app/admin/campaigns.rb