campaign_monitor_party 0.2.1

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.
@@ -0,0 +1,42 @@
1
+ Campaign Monitor Party
2
+ ======================
3
+
4
+ Lightweight wrapper for Campaign Monitor API over HTTP using HTTParty.
5
+
6
+ About
7
+ -----
8
+
9
+ This is a very simple class that utilizes HTTParty -- a wonderful gem for
10
+ consuming REST APIs. The code here is only about 20 lines or so; HTTParty
11
+ does all the hard work.
12
+
13
+ Installation
14
+ ------------
15
+
16
+ sudo gem install campaign_monitor_party -s http://gemcutter.org
17
+
18
+ Usage
19
+ -----
20
+
21
+ First, familiarize yourself with the API documentation here: http://www.campaignmonitor.com/api/
22
+
23
+ require 'rubygems'
24
+ require 'campaign_monitor_party'
25
+
26
+ API_KEY = '...'
27
+
28
+ cm = CampaignMonitorParty.new(API_KEY)
29
+
30
+ # The wrapper uses method_missing to accept any method supported by the HTTP API (now or in the future).
31
+ # For instance, the method "Subscriber.Add" is called with the code below.
32
+
33
+ cm.Subscriber.Add(
34
+ 'ListID' => '...',
35
+ 'Email' => 'tim@timmorgan.org',
36
+ 'Name' => 'Tim Morgan'
37
+ )
38
+
39
+ # 'ApiKey' is passed in automatically for each method call.
40
+ # Other arguments should be passed as a hash to the method.
41
+
42
+
@@ -0,0 +1,23 @@
1
+ require 'httparty'
2
+
3
+ class CampaignMonitorParty
4
+
5
+ include HTTParty
6
+ format :xml
7
+
8
+ ENDPOINT = 'http://api.createsend.com/api/api.asmx/'
9
+
10
+ def initialize(api_key, endpoint=ENDPOINT)
11
+ @api_key = api_key
12
+ @endpoint = endpoint
13
+ end
14
+
15
+ def method_missing(method_name, args={}, test=nil)
16
+ if @endpoint !~ /\/$/
17
+ self.class.post(@endpoint + '.' + method_name.to_s, :body => args.merge('ApiKey' => @api_key))
18
+ else
19
+ self.class.new(@api_key, @endpoint + method_name.to_s)
20
+ end
21
+ end
22
+
23
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: campaign_monitor_party
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Tim Morgan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-20 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description:
26
+ email: tim@timmorgan.org
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - README.markdown
35
+ - lib/campaign_monitor_party.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/seven1m/campaign_monitor_party
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.5
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Lightweight wrapper for Campaign Monitor API over HTTP using HTTParty
64
+ test_files: []
65
+