Grails Gchimp Plugin
Dependency:
compile "org.grails.plugins:gchimp-plugin:0.2.6"
Summary
Installation
grails install-plugin gchimp-plugin
grails install-plugin /path/to/download-folder/grails-gchimp-plugin-0.2.1.zip
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'
class GchimpController { def gchimpService }
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 [:] } }