mailchimpv3 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/LICENSE.txt +1 -1
- data/README.md +34 -8
- data/lib/mailchimpv3.rb +36 -29
- data/lib/mailchimpv3/list.rb +57 -0
- data/lib/mailchimpv3/lists.rb +13 -0
- data/mailchimpv3.gemspec +2 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ff580fae04ae93a4749c07dc00cf0608fdf6f6d
|
4
|
+
data.tar.gz: 2880621bee3ede7f86429327edb59202538d58b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824ba39d52f0feca37c5e4b6bec204c43b2041e67ccffc0b3c610262f16a8515f18e4d68ceba9853e24eef40726d869f24e1a339e993f890def7fc12ff008ad8
|
7
|
+
data.tar.gz: b9e42b561f464826cf573292c51f1da0aa3e7a0e5dc8a8825c95baf9472f61021487e43ca947142dd746ae0dec7b859bc4e7b59f6dac1fbefbf6568ffbf5ba41
|
data/.gitignore
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Mailchimpv3
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
A ruby library for Mailchimp API V3.0, you can manage your lists and add members to them.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,28 +20,56 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
Initialize the client with your API_KEY
|
26
24
|
|
27
25
|
```ruby
|
28
|
-
Mailchimpv3.
|
26
|
+
api_client = Mailchimpv3::API.new "API_KEY"
|
29
27
|
```
|
28
|
+
|
30
29
|
### Lists
|
30
|
+
|
31
|
+
#### All
|
31
32
|
You can now list all your lists
|
32
33
|
|
33
34
|
```ruby
|
34
|
-
Mailchimpv3.
|
35
|
+
api_client = Mailchimpv3::API.new "API_KEY"
|
36
|
+
api_client.lists().all()
|
37
|
+
```
|
38
|
+
|
39
|
+
#### Find
|
40
|
+
Find a list based on its id
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
api_client = Mailchimpv3::API.new "API_KEY"
|
44
|
+
api_client.lists().find("id")
|
35
45
|
```
|
36
46
|
|
37
|
-
|
47
|
+
You can also specify the params that you want to recieve
|
38
48
|
|
39
49
|
```ruby
|
40
|
-
Mailchimpv3.
|
50
|
+
api_client = Mailchimpv3::API.new "API_KEY"
|
51
|
+
api_client.lists().find("id", {fields: 'lists.id, lists.name, lists.contact,
|
52
|
+
lists.permission_reminder,lists.campaign_defaults,
|
53
|
+
lists.email_type_option,lists.stats.member_count'})
|
41
54
|
```
|
42
55
|
|
56
|
+
#### Add members
|
57
|
+
Add a new member with the email and status
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
api_client = Mailchimpv3::API.new "API_KEY"
|
61
|
+
list = api.list().find("f355f76299")
|
62
|
+
list.addmember("popolokm@mail.com","suscribed")
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
|
43
67
|
## Contributing
|
44
68
|
|
45
69
|
Bug reports and pull requests are welcome on GitHub at https://github.com/Xosmond/mailchimpv3.
|
46
70
|
|
71
|
+
NOTE: You must sign your commits.
|
72
|
+
|
47
73
|
|
48
74
|
## License
|
49
75
|
|
data/lib/mailchimpv3.rb
CHANGED
@@ -1,41 +1,48 @@
|
|
1
1
|
require "httparty"
|
2
|
+
require_relative "./mailchimpv3/lists"
|
3
|
+
require_relative "./mailchimpv3/list"
|
2
4
|
|
3
5
|
module Mailchimpv3
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
class API
|
7
|
+
include HTTParty
|
8
|
+
@auth = {}
|
9
|
+
@headers = {'content-type': 'application/json'}
|
10
|
+
@lists = nil
|
11
|
+
def initialize(api_key)
|
12
|
+
unless api_key =~ /\w+-\w{3}/
|
13
|
+
raise StandardError
|
14
|
+
end
|
15
|
+
server = api_key.split('-')[1]
|
16
|
+
self.class.base_uri "https://#{server}.api.mailchimp.com/3.0"
|
17
|
+
@auth = {username: 'apikey', password: api_key}
|
12
18
|
end
|
13
|
-
server = api_key.split('-')[1]
|
14
|
-
self.base_uri "https://#{server}.api.mailchimp.com/3.0"
|
15
|
-
@auth = {username: 'apikey', password: api_key}
|
16
|
-
true
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def account_details
|
21
|
+
self.class.get('/', :basic_auth => @auth).parsed_response
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
:query => {fields: 'lists.id,lists.name,lists.stats.member_count'}
|
27
|
-
).parsed_response["lists"]
|
24
|
+
def lists
|
25
|
+
Lists.new self
|
26
|
+
end
|
28
27
|
|
29
|
-
|
28
|
+
def list(name ="", contact={}, permission_reminder="",
|
29
|
+
campaign_defaults={},member_count=0, email_type_option=true)
|
30
|
+
List.new(self, name, contact, permission_reminder,
|
31
|
+
campaign_defaults,member_count, email_type_option=true)
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
def post(url, params={})
|
35
|
+
self.class.post(url,
|
33
36
|
:basic_auth => @auth,
|
34
37
|
:headers => @headers,
|
35
|
-
:body =>
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
:body => params.to_json
|
39
|
+
).parsed_response
|
40
|
+
end
|
41
|
+
def get(url, recieve_params="")
|
42
|
+
self.class.get(url,
|
43
|
+
:basic_auth => @auth,
|
44
|
+
:query => {fields: recieve_params}
|
45
|
+
).parsed_response
|
46
|
+
end
|
40
47
|
end
|
41
48
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Mailchimpv3
|
2
|
+
class List
|
3
|
+
attr_accessor :id, :contact, :name, :permission_reminder,
|
4
|
+
:campaign_defaults, :email_type_option, :master, :member_count, :saved
|
5
|
+
|
6
|
+
def initialize(master,id="", name="", contact={}, permission_reminder="",
|
7
|
+
campaign_defaults={},member_count=0, email_type_option=true)
|
8
|
+
@master = master
|
9
|
+
@id = id
|
10
|
+
@name = name
|
11
|
+
@contact = contact
|
12
|
+
@permission_reminder = permission_reminder
|
13
|
+
@campaign_defaults = campaign_defaults
|
14
|
+
@email_type_option = email_type_option
|
15
|
+
@member_count = member_count
|
16
|
+
@saved = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def find(id, params={fields: 'lists.id, lists.name, lists.contact,
|
20
|
+
lists.permission_reminder,lists.campaign_defaults,
|
21
|
+
lists.email_type_option,lists.stats.member_count'})
|
22
|
+
|
23
|
+
response = @master.get("/lists/#{id}", params)
|
24
|
+
@id = response["id"]
|
25
|
+
@name = response["name"]
|
26
|
+
@contact = response["contact"]
|
27
|
+
@permission_reminder = response["permission_reminder"]
|
28
|
+
@campaign_defaults = response["campaign_defaults"],
|
29
|
+
@member_count = response["member_count"].to_i
|
30
|
+
@email_type_option = ["email_type_option"]
|
31
|
+
@saved = true
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
def save()
|
36
|
+
response = @master.post("/lists", {
|
37
|
+
:name => @name,
|
38
|
+
:contact => @contact,
|
39
|
+
:permission_reminder => @permission_reminder,
|
40
|
+
:campaign_defaults => @campaign_defaults,
|
41
|
+
:email_type_option => @email_type_option
|
42
|
+
})
|
43
|
+
@saved = true
|
44
|
+
@id = response["id"]
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
def addmember(email_address, status)
|
49
|
+
response = @master.post("/lists/#{@id}/members", {
|
50
|
+
:email_address => email_address,
|
51
|
+
:status => status
|
52
|
+
})
|
53
|
+
@member_count = @member_count + 1
|
54
|
+
response
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/mailchimpv3.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "mailchimpv3"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.2"
|
8
8
|
spec.authors = ["Jordano Moscoso"]
|
9
9
|
spec.email = ["jor_notes@outlook.com"]
|
10
10
|
|
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.11"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "dotenv", "~> 2.1"
|
24
25
|
spec.add_dependency "httparty", "~> 0.13.7"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailchimpv3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordano Moscoso
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dotenv
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: httparty
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,6 +97,8 @@ files:
|
|
83
97
|
- bin/console
|
84
98
|
- bin/setup
|
85
99
|
- lib/mailchimpv3.rb
|
100
|
+
- lib/mailchimpv3/list.rb
|
101
|
+
- lib/mailchimpv3/lists.rb
|
86
102
|
- mailchimpv3.gemspec
|
87
103
|
homepage: https://github.com/Xosmond/mailchimpv3
|
88
104
|
licenses:
|