hominid 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ module Hominid
2
+ module Security
3
+
4
+ # SECURITY RELATED METHODS
5
+
6
+ def add_api_key(username, password)
7
+ # Add an API Key to your account. We will generate a new key for you and return it.
8
+ #
9
+ # Parameters:
10
+ # username (String) = Your Mailchimp account username.
11
+ # password (String) = Your Mailchimp account password.
12
+ #
13
+ # Returns:
14
+ # A new API Key that can be immediately used.
15
+ #
16
+ @chimpApi.call("apikeyAdd", username, password, @config[:api_key])
17
+ end
18
+
19
+ def api_keys(username, password, expired = false)
20
+ # Retrieve a list of all MailChimp API Keys for this User.
21
+ #
22
+ # Parameters:
23
+ # username (String) = Your Mailchimp account username.
24
+ # password (String) = Your Mailchimp account password.
25
+ # expired (Boolean) = Whether or not to include expired keys, defaults to false.
26
+ #
27
+ # Returns:
28
+ # An array of API keys including:
29
+ # apikey (String) = The api key that can be used.
30
+ # created_at (String) = The date the key was created.
31
+ # expired_at (String) = The date the key was expired.
32
+ #
33
+ @chimpApi.call("apikeys", username, password, @config[:api_key], expired)
34
+ end
35
+
36
+ def expire_api_key(username, password)
37
+ # Expire a Specific API Key.
38
+ #
39
+ # Returns:
40
+ # True if successful, error code if not.
41
+ #
42
+ @chimpApi.call("apikeyExpire", username, password, @config[:api_key])
43
+ end
44
+
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hominid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Getting
@@ -10,19 +10,10 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-11 00:00:00 -08:00
13
+ date: 2009-12-17 00:00:00 -08:00
14
14
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: shoulda
18
- type: :development
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
25
- version:
15
+ dependencies: []
16
+
26
17
  description: Hominid is a Ruby gem that provides a wrapper for interacting with the Mailchimp email marketing service API.
27
18
  email: brian@terra-firma-design.com
28
19
  executables: []
@@ -39,14 +30,12 @@ files:
39
30
  - Rakefile
40
31
  - VERSION
41
32
  - hominid.gemspec
42
- - hominid.yml.tpl
43
33
  - lib/hominid.rb
44
34
  - lib/hominid/base.rb
45
35
  - lib/hominid/campaign.rb
46
36
  - lib/hominid/helper.rb
47
37
  - lib/hominid/list.rb
48
- - lib/hominid/webhook.rb
49
- - tasks/rails/hominid.rake
38
+ - lib/hominid/security.rb
50
39
  - test/hominid_test.rb
51
40
  - test/test_helper.rb
52
41
  has_rdoc: true
@@ -1,25 +0,0 @@
1
- # Get your API key at http://admin.mailchimp.com/account/api/
2
-
3
- development:
4
- username:
5
- password:
6
- api_key:
7
- send_goodbye: false
8
- send_notify: false
9
- double_opt_in: false
10
-
11
- test:
12
- username:
13
- password:
14
- api_key:
15
- send_goodbye: false
16
- send_notify: false
17
- double_opt_in: false
18
-
19
- production:
20
- username:
21
- password:
22
- api_key:
23
- send_goodbye: false
24
- send_notify: false
25
- double_opt_in: false
@@ -1,131 +0,0 @@
1
- module Hominid
2
-
3
- class Webhook < Base
4
- # Expects a hash of POST data generated from Mailchimp:
5
- #
6
- # "type": "unsubscribe",
7
- # "fired_at": "2009-03-26 21:54:00",
8
- # "data[email]": "sample@emailaddress.com"
9
- #
10
- # Simple Usage:
11
- #
12
- # h = Hominid::Webhook.new(params)
13
- #
14
- # Sample params from Mailchimp webhook:
15
- # params => { "type" => "subscribe",
16
- # "fired_at" => "2009-03-26 21:35:57",
17
- # "data" => { "id" => "8a25ff1d98",
18
- # "list_id" => "8a25ff1d98",
19
- # "email" => "api@mailchimp.com",
20
- # "email_type" => "html",
21
- # "merges" => {"EMAIL" => "api@mailchimp.com",
22
- # "FNAME" => "Brian",
23
- # "LNAME" => "Getting",
24
- # "INTERESTS" => "Group1,Group2"},
25
- # "ip_opt" => "10.20.10.30",
26
- # "ip_signup" => "10.20.10.30" }}
27
- #
28
- # Returns an object with the following methods (NOTE: Not all methods are available
29
- # for all event types. Refer to http://www.mailchimp.com/api/webhooks/ for information
30
- # on what data will be available for each event):
31
- #
32
- # h.event <= (String) The event that fired the request. Possible events are:
33
- # "subscribe", "unsubscribe", "profile", "upemail", "cleaned"
34
- # h.fired_at <= (Datetime) When the webhook request was fired.
35
- # h.id <= (String) The ID of the webhook request.
36
- # h.list_id <= (String) The ID of the list that generated the request.
37
- # h.email <= (String) The email address of the subscriber that generated the request.
38
- # h.email_type <= (String) The email type of the subscriber that generated the request.
39
- # h.first_name <= (String) The first name of the subscriber (if available).
40
- # h.last_name <= (String) The first name of the subscriber (if available).
41
- # h.interests <= (Array) An array of the interest groups.
42
- # h.ip_opt <= (String) The opt in IP address.
43
- # h.ip_signup <= (String) The signup IP address.
44
- #
45
-
46
- attr_reader :request
47
-
48
- def initialize(*args)
49
- post_data = args.last
50
- raise HominidError.new('Please provide the POST data from a Mailchimp webhook request.') unless post_data.is_a?(Hash)
51
- post_data.merge!({"event" => "#{post_data.delete('type')}"})
52
- @request = hash_to_object(post_data)
53
- end
54
-
55
-
56
- def email
57
- self.request.data.email if self.request.data.email
58
- end
59
-
60
- def email_type
61
- self.request.data.email_type if self.request.data.email_type
62
- end
63
-
64
- def event
65
- self.request.event if self.request.event
66
- end
67
-
68
- def fired_at
69
- self.request.fired_at.to_datetime if self.request.fired_at
70
- end
71
-
72
- def first_name
73
- self.request.data.merges.fname if self.request.data.merges.fname
74
- end
75
-
76
- def last_name
77
- self.request.data.merges.lname if self.request.data.merges.lname
78
- end
79
-
80
- def id
81
- self.request.data.id if self.request.data.id
82
- end
83
-
84
- def interests
85
- self.request.data.merges.interests.split(',') if self.request.data.merges.interests
86
- end
87
-
88
- def ip_opt
89
- self.request.data.ip_opt if self.request.data.ip_opt
90
- end
91
-
92
- def ip_signup
93
- self.request.data.ip_signup if self.request.data.ip_signup
94
- end
95
-
96
- def list_id
97
- self.request.data.list_id if self.request.data.list_id
98
- end
99
-
100
- def new_email
101
- self.request.data.new_email if self.request.data.new_email
102
- end
103
-
104
- def old_email
105
- self.request.data.old_email if self.request.data.old_email
106
- end
107
-
108
- def reason
109
- self.request.data.reason if self.request.data.reason
110
- end
111
-
112
- private
113
-
114
- def hash_to_object(object)
115
- return case object
116
- when Hash
117
- object = object.clone
118
- object.each do |key, value|
119
- object[key.downcase] = hash_to_object(value)
120
- end
121
- OpenStruct.new(object)
122
- when Array
123
- object = object.clone
124
- object.map! { |i| hash_to_object(i) }
125
- else
126
- object
127
- end
128
- end
129
-
130
- end
131
- end
@@ -1,22 +0,0 @@
1
- require 'rake'
2
- namespace :hominid do
3
- # Task to create the config file
4
- desc "Generate a Hominid config file"
5
- task :config => :environment do |t|
6
- require 'fileutils'
7
- if defined?(Rails.root)
8
- config_file = File.join(Rails.root, 'config', 'hominid.yml')
9
- template_file = File.join(File.dirname(__FILE__), '..', '..', 'hominid.yml.tpl')
10
- unless File.exists? config_file
11
- FileUtils.cp(
12
- File.join(File.dirname(__FILE__), '..', '..', 'hominid.yml.tpl'),
13
- File.join(Rails.root, 'config', 'hominid.yml')
14
- )
15
- puts 'Please edit config/hominid.yml to your needs.'
16
- else
17
- puts 'We left your existing config/hominid.yml untouched.'
18
- end
19
- end
20
- end
21
- end
22
-