webhookr-mailchimp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ Gemfile.local
8
+ Guardfile.local
9
+ README.html
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem "rake", "~> 10.0"
6
+ gem "minitest"
7
+ gem "minitest-reporters"
8
+ gem "em-websocket"
9
+ gem "guard"
10
+ gem "guard-minitest"
11
+ gem "guard-markdown"
12
+ gem "guard-livereload"
13
+ gem "simplecov", :require => false
14
+
15
+ if RbConfig::CONFIG['host_os'] =~ /^darwin/
16
+ gem "rb-fsevent"
17
+ gem "growl"
18
+ end
19
+
20
+ if File.exists?('Gemfile.local')
21
+ instance_eval File.read('Gemfile.local')
22
+ end
23
+
data/Guardfile ADDED
@@ -0,0 +1,22 @@
1
+
2
+ guard 'minitest', :test_folders => 'test', :test_file_patterns => '*_tests.rb' do
3
+ watch(%r|^test/(.+)_test\.rb|)
4
+ watch(%r|^test/(.+)_tests\.rb|)
5
+
6
+ watch(%r|^lib/(.*)([^/]+)\.rb|) do |m|
7
+ "test/#{m[1]}#{m[2]}_tests.rb"
8
+ end
9
+
10
+ watch(%r|^test/test_helper\.rb|) do
11
+ "test"
12
+ end
13
+ end
14
+
15
+ guard 'markdown', :convert_on_start => true do
16
+ watch ('README.md') { "./README.md|./README.html" }
17
+ end
18
+
19
+ if File.exists?('Guardfile.local')
20
+ instance_eval File.read('Guardfile.local')
21
+ end
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Gerry Power
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 2167961 Ontario Inc., Zoocasa <code@zoocasa.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,158 @@
1
+ # Webhookr::Mailchimp
2
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/zoocasa/webhookr-mailchimp)
3
+
4
+ This gem is a plugin for [Webhookr](https://github.com/zoocasa/webhookr) that enables
5
+ your application to accept [webhooks from Mailchimp](http://apidocs.mailchimp.com/webhooks/).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'webhookr-mailchimp'
12
+
13
+ Or install it yourself:
14
+
15
+ $ gem install webhookr-mailchimp
16
+
17
+ ## Usage
18
+
19
+ Once you have the gem installed run the generator to add the code to your initializer.
20
+ An initializer will be created if you do not have one.
21
+
22
+ ```console
23
+ rails g webhookr:mailchimp:init *initializer_name* -s
24
+ ```
25
+
26
+ Run the generator to create an example file to handle MailChimp webhooks.
27
+
28
+ ```console
29
+ rails g webhookr:mailchimp:example_hooks
30
+ ```
31
+
32
+ Or create a MailChimp handler class for any event that you want to handle. For example
33
+ to handle unsubscribes you would create a class as follows:
34
+
35
+ ```ruby
36
+ class MailChimpHooks
37
+ def on_unsubscribe(incoming)
38
+ # Your custom logic goes here.
39
+ User.unsubscribe_newletter(incoming.payload.data.email)
40
+ end
41
+ end
42
+ ```
43
+
44
+ For a complete list of events, and the payload format, see below.
45
+
46
+ Edit config/initializers/*initializer_name* and change the commented line to point to
47
+ your custom Mailchimp event handling class. If your class was called *MailChimpHooks*
48
+ the configuration line would look like this:
49
+
50
+ ```ruby
51
+ Webhookr::Mailchimp::Adapter.config.callback = MailChimpHooks
52
+ ```
53
+
54
+ To see the list of MailChimp URLs for your application can use when you [configure
55
+ MailChimp](http://apidocs.mailchimp.com/webhooks/#configuring-webhooks) webhooks,
56
+ run the provided webhookr rake task:
57
+
58
+ ```console
59
+ rake webhookr:services
60
+ ```
61
+
62
+ Example output:
63
+
64
+ ```console
65
+ mailchimp:
66
+ GET /webhookr/events/mailchimp/19xl64emxvn
67
+ POST /webhookr/events/mailchimp/19xl64emxvn
68
+ ```
69
+
70
+ ## MailChimp Events & Payload
71
+
72
+ ### Events
73
+
74
+ All webhook events are supported. For further information on these events, see the
75
+ [MailChimp documentation](http://apidocs.mailchimp.com/webhooks/#event-data).
76
+
77
+ <table>
78
+ <tr>
79
+ <th>MailChimp Event</th>
80
+ <th>Event Handler</th>
81
+ </tr>
82
+ <tr>
83
+ <td>subscribe</td>
84
+ <td>on_subscribe(incoming)</td>
85
+ </tr>
86
+ <tr>
87
+ <td>unsubscribe</td>
88
+ <td>on_unsubscribe(incoming)</td>
89
+ </tr>
90
+ <tr>
91
+ <td>profile</td>
92
+ <td>on_profile(incoming)</td>
93
+ </tr>
94
+ <tr>
95
+ <td>upemail</td>
96
+ <td>on_upemail(incoming)</td>
97
+ </tr>
98
+ <tr>
99
+ <td>cleaned</td>
100
+ <td>on_cleaned(incoming)</td>
101
+ </tr>
102
+ <tr>
103
+ <td>campaign</td>
104
+ <td>on_campaign(incoming)</td>
105
+ </tr>
106
+ </table>
107
+
108
+ ### Payload
109
+
110
+ The payload is the full payload data from as per the
111
+ [MailChimp documentation](http://apidocs.mailchimp.com/webhooks/#event-data), converted to an OpenStruct
112
+ for ease of access. Examples for the method call unsubscribe:
113
+
114
+ ```ruby
115
+ incoming.payload.fired_at
116
+ incoming.payload.data.action
117
+ incoming.payload.data.reason
118
+ incoming.payload.data.id
119
+ incoming.payload.data.list_id
120
+ incoming.payload.data.email
121
+ incoming.payload.data.email_type
122
+ incoming.payload.data.merges.EMAIL
123
+ incoming.payload.data.merges.FNAME
124
+ incoming.payload.data.merges.LNAME
125
+ incoming.payload.data.merges.INTERESTS
126
+ incoming.payload.data.ip_opt
127
+ incoming.payload.data.campaign_id
128
+ incoming.payload.data.reason
129
+
130
+ ```
131
+
132
+ ### <a name="supported_services"></a>Supported Service - MailChimp
133
+
134
+ * [http://apidocs.mailchimp.com/webhooks/](MailChimp - v1.3)
135
+
136
+ ## <a name="works_with"></a>Works with:
137
+
138
+ webhookr-mailchimp works with Rails 3.1 and 3.2, and has been tested on the following Ruby
139
+ implementations:
140
+
141
+ * JRuby 1.7.1
142
+ * MRI 1.8.7
143
+ * MRI 1.9.2
144
+ * MRI 1.9.3
145
+ * Rubinius 1.2.4
146
+ * Ruby EE 1.8.7
147
+
148
+ Pending:
149
+
150
+ * MRI 2.0
151
+
152
+ ## License
153
+
154
+ webhookr-mailchimp is released under the [MIT license](http://www.opensource.org/licenses/MIT).
155
+
156
+ ## Author
157
+
158
+ * [Gerry Power](https://github.com/gerrypower)
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+
2
+ # -*- ruby -*-
3
+
4
+ require 'rubygems'
5
+ require 'rubygems/package_task'
6
+ require 'rake/testtask'
7
+ require 'rdoc/task'
8
+ require 'bundler/gem_tasks'
9
+
10
+ $:.push File.expand_path(File.dirname(__FILE__), 'lib')
11
+
12
+ version = Webhookr::Mailchimp::VERSION
13
+
14
+ desc 'Test Webhookr Mailchimp'
15
+ Rake::TestTask.new(:test) do |t|
16
+ t.test_files = FileList['test/**/*_tests.rb']
17
+ t.verbose = !!ENV['VERBOSE_TESTS']
18
+ t.warning = !!ENV['WARNINGS']
19
+ end
20
+
21
+ desc 'Build docs'
22
+ Rake::RDocTask.new do |t|
23
+ t.main = 'README.md'
24
+ t.title = "Webhookr Mailchimp #{version}"
25
+ t.rdoc_dir = 'doc'
26
+ t.rdoc_files.include('README.md', 'MIT-LICENSE', 'lib/**/*.rb')
27
+ end
28
+
29
+ namespace :webhookr do
30
+ namespace:test do
31
+ desc 'Install gems in all Rubies'
32
+ task :install do
33
+ sh %{rbenv each -v bundle install}
34
+ end
35
+
36
+ desc 'Test with all Rubies'
37
+ task :test_versions do
38
+ sh %{rbenv each -v bundle exec rake test}
39
+ end
40
+
41
+ desc 'Update rails'
42
+ task :update_rails do
43
+ sh %{rbenv each -v bundle update rails}
44
+ end
45
+
46
+ desc 'Install and test all'
47
+ task :all => [:install, :test_versions]
48
+ end
49
+ end
50
+
51
+ task :default => :test
@@ -0,0 +1,16 @@
1
+ module Webhookr
2
+ module Mailchimp
3
+ module Generators
4
+
5
+ class ExampleHooksGenerator < Rails::Generators::Base
6
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
7
+
8
+ desc "Creates an example Mailchimp hook file: 'app/models/mail_chimp_hooks.rb'"
9
+ def example_hooks
10
+ copy_file( "mail_chimp_hooks.rb", "app/models/mail_chimp_hooks.rb")
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ require 'generators/webhookr/init_generator'
2
+
3
+ module Webhookr
4
+ module Mailchimp
5
+ module Generators
6
+ class InitGenerator < Webhookr::Generators::InitGenerator
7
+
8
+ desc "This generator updates the named initializer with Mailchimp options"
9
+ def init
10
+ super
11
+ append_to_file "config/initializers/#{file_name}.rb" do
12
+ plugin_initializer_text
13
+ end
14
+ end
15
+
16
+ def plugin_initializer_text
17
+ "\nWebhookr::Mailchimp::Adapter.config.security_token = '#{generate_security_token}'" +
18
+ "\n# Uncomment the next line to include your custom Mailchimp handler\n" +
19
+ "# <-- Webhookr::Mailchimp::Adapter.config.callback = your_custom_class --> \n"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,80 @@
1
+ class MailChimpHooks
2
+
3
+ # All 'on_' handlers are optional. Omit any you do not require.
4
+
5
+ def on_subscribe(incoming)
6
+ payload = payload
7
+ puts payload.fired_at
8
+ puts payload.data.id
9
+ puts payload.data.list_id
10
+ puts payload.data.email
11
+ puts payload.data.email_type
12
+ puts payload.data.merges.EMAIL
13
+ puts payload.data.merges.FNAME
14
+ puts payload.data.merges.LNAME
15
+ puts payload.data.merges.INTERESTS
16
+ puts payload.data.ip_opt
17
+ puts payload.data.ip_signup
18
+ end
19
+
20
+ def on_unsubscribe(incoming)
21
+ payload = payload
22
+ puts payload.fired_at
23
+ puts payload.data.action
24
+ puts payload.data.reason
25
+ puts payload.data.id
26
+ puts payload.data.list_id
27
+ puts payload.data.email
28
+ puts payload.data.email_type
29
+ puts payload.data.merges.EMAIL
30
+ puts payload.data.merges.FNAME
31
+ puts payload.data.merges.LNAME
32
+ puts payload.data.merges.INTERESTS
33
+ puts payload.data.ip_opt
34
+ puts payload.data.campaign_id
35
+ puts payload.data.reason
36
+ end
37
+
38
+ def on_profile(incoming)
39
+ payload = payload
40
+ puts payload.fired_at
41
+ puts payload.data.id
42
+ puts payload.data.list_id
43
+ puts payload.data.email
44
+ puts payload.data.email_type
45
+ puts payload.data.merges.EMAIL
46
+ puts payload.data.merges.FNAME
47
+ puts payload.data.merges.LNAME
48
+ puts payload.data.merges.INTERESTS
49
+ puts payload.data.ip_opt
50
+ end
51
+
52
+ def on_upemail(incoming)
53
+ payload = payload
54
+ puts payload.fired_at
55
+ puts payload.data.list_id
56
+ puts payload.data.new_id
57
+ puts payload.data.new_email
58
+ puts payload.data.old_email
59
+ end
60
+
61
+ def on_cleaned(incoming)
62
+ payload = payload
63
+ puts payload.fired_at
64
+ puts payload.data.list_id
65
+ puts payload.data.campaign_id
66
+ puts payload.data.reason
67
+ puts payload.data.email
68
+ end
69
+
70
+ def on_campaign(incoming)
71
+ payload = payload
72
+ puts payload.fired_at
73
+ puts payload.data.id
74
+ puts payload.data.subject
75
+ puts payload.data.status
76
+ puts payload.data.reason
77
+ puts payload.data.list_id
78
+ end
79
+
80
+ end
@@ -0,0 +1,5 @@
1
+ module Webhookr
2
+ module Mailchimp
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,61 @@
1
+ require "webhookr"
2
+ require "webhookr-mailchimp/version"
3
+ require "active_support/core_ext/module/attribute_accessors"
4
+ require "webhookr/ostruct_utils"
5
+
6
+ module Webhookr
7
+ module Mailchimp
8
+ class Adapter
9
+ SERVICE_NAME = 'mailchimp'
10
+ EVENT_KEY = "type"
11
+ RENAMED_EVENT_KEY = "event_key"
12
+ PAYLOAD_KEY = "data"
13
+
14
+ include Webhookr::Services::Adapter::Base
15
+
16
+ def self.process(raw_response)
17
+ new.process(raw_response)
18
+ end
19
+
20
+ def process(raw_response)
21
+ Array.wrap(parse(raw_response)).collect do |p|
22
+ Webhookr::AdapterResponse.new(
23
+ SERVICE_NAME,
24
+ p.fetch(RENAMED_EVENT_KEY),
25
+ OstructUtils.to_ostruct(p)
26
+ )
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def parse(raw_response)
33
+ convert_event_key_to_ruby_friendly_name(
34
+ assert_valid_packet(
35
+ Rack::Utils.parse_nested_query(raw_response)
36
+ )
37
+ )
38
+ end
39
+
40
+ def convert_event_key_to_ruby_friendly_name(packet)
41
+ # Ruby 1.8.7 fix for key 'type'
42
+ rename = { EVENT_KEY => RENAMED_EVENT_KEY }
43
+ Hash[packet.map {|k, v| [rename[k] || k, v] }]
44
+ end
45
+
46
+ def assert_valid_packet(parsed_response)
47
+ raise(Webhookr::InvalidPayloadError,
48
+ "Missing event key '#{EVENT_KEY}' in packet"
49
+ ) unless parsed_response[EVENT_KEY].present?
50
+
51
+ raise(Webhookr::InvalidPayloadError,
52
+ "No data key '#{PAYLOAD_KEY}' in the response"
53
+ ) unless parsed_response[PAYLOAD_KEY].present?
54
+
55
+ parsed_response
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,24 @@
1
+
2
+ $: << File.join(File.dirname(__FILE__), %w{ .. .. .. })
3
+ require 'test_helper'
4
+ require 'generators/webhookr/mailchimp/example_hooks_generator'
5
+
6
+ class ExampleHooksGeneratorTests < Rails::Generators::TestCase
7
+ tests Webhookr::Mailchimp::Generators::ExampleHooksGenerator
8
+ destination File.expand_path("../../../tmp", File.dirname(__FILE__))
9
+ setup :prepare_destination
10
+
11
+ def setup
12
+ run_generator
13
+ end
14
+
15
+ test "it should create the example hook file" do
16
+ assert_file "app/models/mail_chimp_hooks.rb"
17
+ end
18
+
19
+ test "it should on handlers" do
20
+ assert_file "app/models/mail_chimp_hooks.rb" do |content|
21
+ assert_match(%r{on_subscribe.*on_unsubscribe.*on_profile.*on_upemail.*on_cleaned.*on_campaign}m, content)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+
2
+ $: << File.join(File.dirname(__FILE__), %w{ .. .. .. })
3
+ require 'test_helper'
4
+ require 'generators/webhookr/mailchimp/init_generator'
5
+
6
+ class InitGeneratorTests < Rails::Generators::TestCase
7
+ tests Webhookr::Mailchimp::Generators::InitGenerator
8
+ destination File.expand_path("../../../tmp", File.dirname(__FILE__))
9
+ setup :prepare_destination
10
+
11
+ def setup
12
+ @name = "test_initializer"
13
+ @initializer = "config/initializers/#{@name}.rb"
14
+ run_generator Array.wrap(@name)
15
+ end
16
+
17
+ test "it should create the initializer" do
18
+ assert_file @initializer
19
+ end
20
+
21
+ test "it should have authorization information" do
22
+ assert_file @initializer do |content|
23
+ assert_match(%r{Webhookr::Mailchimp::Adapter\.config\.security_token}, content)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'minitest/autorun'
5
+ require 'minitest/reporters'
6
+ require 'rails'
7
+ require "rails/generators/test_case"
8
+ require File.expand_path('../../lib/webhookr-mailchimp.rb', __FILE__)
9
+
10
+ if RUBY_VERSION >= "1.9"
11
+ MiniTest::Reporters.use!(MiniTest::Reporters::SpecReporter.new)
12
+ end
@@ -0,0 +1,8 @@
1
+ $: << File.join(File.dirname(__FILE__), %w{ .. .. })
2
+ require 'test_helper'
3
+
4
+ describe Webhookr::Mailchimp do
5
+ it "must be defined" do
6
+ Webhookr::Mailchimp::VERSION.wont_be_nil
7
+ end
8
+ end
@@ -0,0 +1,97 @@
1
+
2
+ $: << File.join(File.dirname(__FILE__), "..")
3
+ require 'test_helper'
4
+
5
+ describe Webhookr::Mailchimp::Adapter do
6
+
7
+ before do
8
+ @event_type = "unsubscribe"
9
+ @fired_at = "2009-03-26 22:01:00"
10
+ @valid_response = "type=#{@event_type}&fired_at=#{@fired_at}&data[email]=gerry%2Bagent2@zoocasa.com"
11
+ end
12
+
13
+ describe "the class" do
14
+
15
+ subject { Webhookr::Mailchimp::Adapter }
16
+
17
+ it "must support process" do
18
+ subject.must_respond_to(:process)
19
+ end
20
+
21
+ it "should not return an error for a valid packet" do
22
+ lambda {
23
+ subject.process(@valid_response)
24
+ }.must_be_silent
25
+ end
26
+
27
+ end
28
+
29
+ describe "the instance" do
30
+
31
+ subject { Webhookr::Mailchimp::Adapter.new }
32
+
33
+ it "should not return an error for a valid packet" do
34
+ lambda {
35
+ subject.process(@valid_response)
36
+ }.must_be_silent
37
+ end
38
+
39
+ it "should raise Webhookr::InvalidPayloadError for no packet" do
40
+ lambda {
41
+ subject.process("")
42
+ }.must_raise(Webhookr::InvalidPayloadError)
43
+ end
44
+
45
+ it "should raise Webhookr::InvalidPayloadError for a missing event type" do
46
+ lambda {
47
+ subject.process("data[email]=gerry%2Bagent2@zoocasa.com")
48
+ }.must_raise(Webhookr::InvalidPayloadError)
49
+ end
50
+
51
+ it "should raise Webhookr::InvalidPayloadError for a missing data packet" do
52
+ lambda {
53
+ subject.process("type=unsubscribe")
54
+ }.must_raise(Webhookr::InvalidPayloadError)
55
+ end
56
+
57
+ end
58
+
59
+ describe "it's response" do
60
+ before do
61
+ @event_type = "unsubscribe"
62
+ @adapter = Webhookr::Mailchimp::Adapter.new
63
+ end
64
+
65
+ subject { @adapter.process(@valid_response).first }
66
+
67
+ it "must respond to service_name" do
68
+ subject.must_respond_to(:service_name)
69
+ end
70
+
71
+ it "should return the correct service name" do
72
+ assert_equal(Webhookr::Mailchimp::Adapter::SERVICE_NAME, subject.service_name)
73
+ end
74
+
75
+ it "must respond to event_type" do
76
+ subject.must_respond_to(:event_type)
77
+ end
78
+
79
+ it "should return the correct event type" do
80
+ assert_equal(@event_type, subject.event_type)
81
+ end
82
+
83
+ it "must respond to payload" do
84
+ subject.must_respond_to(:payload)
85
+ end
86
+
87
+ it "must respond to payload.data" do
88
+ subject.payload.must_respond_to(:data)
89
+ end
90
+
91
+ it "should return the correct data packet" do
92
+ assert_equal("gerry+agent2@zoocasa.com", subject.payload.data.email)
93
+ end
94
+
95
+ end
96
+
97
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'webhookr-mailchimp/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "webhookr-mailchimp"
8
+ gem.version = Webhookr::Mailchimp::VERSION
9
+ gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
10
+ gem.authors = ["Gerry Power"]
11
+ gem.email = ["code@zoocasa.com"]
12
+ gem.description = "A webhookr extension to support Mailchimp webhooks."
13
+ gem.summary = gem.description
14
+
15
+ gem.files = `git ls-files`.split($\)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.homepage = "http://github.com/zoocasa/webhookr-mailchimp"
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency("webhookr")
22
+ gem.add_dependency("activesupport", ["~> 3.1"])
23
+ end
24
+
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webhookr-mailchimp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Gerry Power
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: webhookr
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.1'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.1'
46
+ description: A webhookr extension to support Mailchimp webhooks.
47
+ email:
48
+ - code@zoocasa.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - Guardfile
56
+ - LICENSE.txt
57
+ - MIT-LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/generators/webhookr/mailchimp/example_hooks_generator.rb
61
+ - lib/generators/webhookr/mailchimp/init_generator.rb
62
+ - lib/generators/webhookr/mailchimp/templates/mail_chimp_hooks.rb
63
+ - lib/webhookr-mailchimp.rb
64
+ - lib/webhookr-mailchimp/version.rb
65
+ - test/generators/webhookr/mailchimp/example_hooks_generator_tests.rb
66
+ - test/generators/webhookr/mailchimp/init_generator_tests.rb
67
+ - test/test_helper.rb
68
+ - test/unit/webhookr-mailchimp/version_tests.rb
69
+ - test/unit/webhookr-mailchimp_tests.rb
70
+ - webhookr-mailchimp.gemspec
71
+ homepage: http://github.com/zoocasa/webhookr-mailchimp
72
+ licenses: []
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 1.8.23
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: A webhookr extension to support Mailchimp webhooks.
95
+ test_files:
96
+ - test/generators/webhookr/mailchimp/example_hooks_generator_tests.rb
97
+ - test/generators/webhookr/mailchimp/init_generator_tests.rb
98
+ - test/test_helper.rb
99
+ - test/unit/webhookr-mailchimp/version_tests.rb
100
+ - test/unit/webhookr-mailchimp_tests.rb