seven1m-campaign_monitor 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +35 -0
- data/lib/campaign_monitor.rb +24 -0
- metadata +54 -0
data/README.markdown
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Campaign Monitor API Wrapper
|
|
2
|
+
============================
|
|
3
|
+
|
|
4
|
+
Lightweight wrapper for Campaign Monitor API over REST
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
sudo gem install seven1m-campaign_monitor -s http://gems.github.com
|
|
10
|
+
|
|
11
|
+
Usage
|
|
12
|
+
-----
|
|
13
|
+
|
|
14
|
+
First, familiarize yourself with the API documentation here: http://www.campaignmonitor.com/api/
|
|
15
|
+
|
|
16
|
+
require 'rubygems'
|
|
17
|
+
require 'campaign_monitor'
|
|
18
|
+
|
|
19
|
+
API_KEY = '...'
|
|
20
|
+
|
|
21
|
+
cm = CampaignMonitor.new(API_KEY)
|
|
22
|
+
|
|
23
|
+
# The wrapper uses method_missing to accept any method supported by the API (now or in the future).
|
|
24
|
+
# For instance, the method "Subscriber.Add" is called with the code below.
|
|
25
|
+
|
|
26
|
+
cm.Subscriber.Add(
|
|
27
|
+
'ListID' => '...',
|
|
28
|
+
'Email' => 'tim@timmorgan.org',
|
|
29
|
+
'Name' => 'Tim Morgan'
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# 'ApiKey' is passed in automatically for each method call.
|
|
33
|
+
# Other arguments should be passed as a hash to the method.
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'httparty'
|
|
3
|
+
|
|
4
|
+
class CampaignMonitor
|
|
5
|
+
|
|
6
|
+
include HTTParty
|
|
7
|
+
format :xml
|
|
8
|
+
|
|
9
|
+
ENDPOINT = 'http://api.createsend.com/api/api.asmx/'
|
|
10
|
+
|
|
11
|
+
def initialize(api_key, endpoint=ENDPOINT)
|
|
12
|
+
@api_key = api_key
|
|
13
|
+
@endpoint = endpoint
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def method_missing(method_name, args={}, test=nil)
|
|
17
|
+
if args.any?
|
|
18
|
+
self.class.post(@endpoint + '.' + method_name.to_s, :body => args.merge('ApiKey' => @api_key))
|
|
19
|
+
else
|
|
20
|
+
self.class.new(@api_key, @endpoint + method_name.to_s)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: seven1m-campaign_monitor
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tim Morgan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description:
|
|
17
|
+
email: tim@timmorgan.org
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files: []
|
|
23
|
+
|
|
24
|
+
files:
|
|
25
|
+
- README.markdown
|
|
26
|
+
- lib/campaign_monitor.rb
|
|
27
|
+
has_rdoc: false
|
|
28
|
+
homepage: http://github.com/seven1m/campaign_monitor
|
|
29
|
+
post_install_message:
|
|
30
|
+
rdoc_options: []
|
|
31
|
+
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: "0"
|
|
39
|
+
version:
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: "0"
|
|
45
|
+
version:
|
|
46
|
+
requirements: []
|
|
47
|
+
|
|
48
|
+
rubyforge_project:
|
|
49
|
+
rubygems_version: 1.2.0
|
|
50
|
+
signing_key:
|
|
51
|
+
specification_version: 2
|
|
52
|
+
summary: Lightweight wrapper for Campaign Monitor API over REST
|
|
53
|
+
test_files: []
|
|
54
|
+
|