Grails Gchimp Plugin

  • Tags : mailchimp, email, newsletter
  • Latest : 0.2.6
  • Last Updated: 31 December 2009
  • Grails version : 1.3.6
  • Authors : null
0 vote
Dependency :
compile ":gchimp-plugin:0.2.6"

Documentation

Summary

Installation

grails install-plugin gchimp-plugin

or...

Download it manually and...

grails install-plugin /path/to/download-folder/grails-gchimp-plugin-0.2.1.zip

New releases:

I'll post new releases of this plugin on twitter: http://twitter.com/malte_huebner

Description

Welcome to the Grails Gchimp Plugin!

This plugin currently supports only some basic MailChimp API 1.2-Methods like subscribe, unsubscribe, lists, memberInfo...

How to use this plugin:

First, install it as described under "Installation".

Next, just add some configuration vars to your Config.groovy. These are:

gchimp.apiUrl = 'https://api.mailchimp.com:443/1.2/'
gchimp.apiKey = 'YOUR_API_KEY'
gchimp.defaultListId = 'YOUR_LIST_ID'
gchimp.encoding = 'UTF-8'

After these are set, just wire the gChimpService into your Controller like this:

class GchimpController {

def gchimpService }

Now you are ready to use methods of GchimpService. Just check it out, it's really simple.

Have fun with this plugin!

Sample controller

This is just a rudimental sample to demonstrate the simplicity of this plugin. Do not use it in production mode!

import com.nwire.mailchimp.IMailChimpServices;

/** * @author Malte Hübner, innobox web engineering * */

class GchimpController {

def gchimpService

def afterInterceptor = { model -> def apiKey = gchimpService.apiKey def keySize = apiKey.size() def maskSize = keySize - 8

model.apiKey = '*' * maskSize + apiKey[maskSize..keySize-1] model.defaultListId = gchimpService.defaultListId }

def index = { def ping = gchimpService.ping()

if (IMailChimpServices.PING_SUCCESS.equals(ping)) { flash.message = "MailChimp connection pinged successfully" } else { flash.message = "Failed to ping MailChimp, response: " + ping } }

def lists = { def lists = gchimpService.lists();

return [lists:lists] }

def memberInfo = { if(!params.email) { throw new IllegalArgumentException("Param email is missing") }

def memberInfo = gchimpService.listMemberInfo(params.email);

return [memberInfo:memberInfo]

}

def subscribe = { if(!params.email) { throw new IllegalArgumentException("Param email is missing") }

def res = gchimpService.listSubscribe(params.email);

if(res) { flash.message = 'subscription successful' } else { flash.message = 'subscription not successful' }

return [:]

}

def unsubscribe = { if(!params.email) { throw new IllegalArgumentException("Param email is missing") }

def res = gchimpService.listUnsubscribe(params.email);

if(res) { flash.message = 'unsubscription successful' } else { flash.message = 'unsubscription not successful' }

return [:]

} }