mailchimp-rest-api 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e12dd5f9138dd42df18a44d79b07a9d7d280a8c09694a64e5c9e7963dd6d992
4
- data.tar.gz: 7fd21428cd4d12c5881e2eea7bc4c3a045742bfd9120b01cf1a62704e834b814
3
+ metadata.gz: cd8e4ac41f0ff072d449fab1c0466bed09d533def2a97db463a0dd76e47aaef2
4
+ data.tar.gz: 24fccb0d0eb4175d77055bdd5ce4e935789cbd5b6ed700d17f7d98ab86ada034
5
5
  SHA512:
6
- metadata.gz: 4fdebf9fbf90a37a171ec67d64c3ff8c53361cf4bc0d90a22649ddb14f962e76f4f4742ef7ac16b6bdbcc8be49677557f3debe8a2f6dd229101d58641ec9a993
7
- data.tar.gz: 948ee7442f8a69395c4d1743cb4b91140f32820f96d4bf4709e4c625699bc551092cc2648700540c5e26418f5f05a0523957b90baa8e5d1d45daeec138544906
6
+ metadata.gz: 8cc1fa18308afd486cb4418317f8809d9e2758df9a1ea4087aaea57ba66db3570ae91fc99faccd8472a4663f22800151519b5c4c350f750f275a484c147544fe
7
+ data.tar.gz: 0df6d93f8742d35b73372a5b7ce139723102261f046243e77bcb30f90937fa519a93e0c1fd4e267bc67bb5a38c9932907d5a2373a0f27ac49f81d763bd4465f5
data/README.md CHANGED
@@ -60,6 +60,52 @@ MailchimpAPI.audience_members.create(audience_id, body: body)
60
60
  - `response.success?` - checks HTTP status code is 2xx
61
61
  - `response.failed?` - checks HTTP status code is not 2xx
62
62
 
63
+ ## Errors
64
+
65
+ All error classes inherit from `MailchimpAPI::Error` and provide:
66
+
67
+ - `error_type` - Error type returned by Mailchimp
68
+ - `error_title` - Error title or response error class name
69
+ - `error_status` - Error status or HTTP status
70
+ - `error_detail` - Error description from Mailchimp
71
+ - `error_fields` - Field-specific errors
72
+ - `error_instance` - Error ID from Mailchimp
73
+ - `response` - Response object
74
+ - `request` - Request object
75
+
76
+ MailchimpAPI provides specific error classes for different types of errors:
77
+
78
+ ### Network Errors
79
+
80
+ - `MailchimpAPI::Errors::NetworkError` - Raised when a network error occurs
81
+ during request execution
82
+
83
+ ### HTTP Status Code Errors
84
+
85
+ - `MailchimpAPI::Errors::BadRequest` (400) - Invalid request parameters
86
+ - `MailchimpAPI::Errors::Unauthorized` (401) - Invalid API key
87
+ - `MailchimpAPI::Errors::Forbidden` (403) - Insufficient permissions
88
+ - `MailchimpAPI::Errors::NotFound` (404) - Resource not found
89
+ - `MailchimpAPI::Errors::MethodNotAllowed` (405) - HTTP method not allowed
90
+ - `MailchimpAPI::Errors::RequestURITooLong` (414) - Request URI too long
91
+ - `MailchimpAPI::Errors::UnprocessableEntity` (422) - Request validation failed
92
+ - `MailchimpAPI::Errors::UpgradeRequired` (426) - API version upgrade required
93
+ - `MailchimpAPI::Errors::TooManyRequests` (429) - Rate limit exceeded
94
+ - `MailchimpAPI::Errors::ServerError` (5xx) - Mailchimp server error
95
+
96
+ Example:
97
+
98
+ ```ruby
99
+ begin
100
+ MailchimpAPI.audience_members.create(audience_id, body: body)
101
+ rescue MailchimpAPI::Errors::UnprocessableEntity => e
102
+ puts "Validation failed: #{e.error_detail}"
103
+ puts "Field errors: #{e.error_fields}"
104
+ rescue MailchimpAPI::Errors::NetworkError => e
105
+ puts "Network error: #{e.error_detail}"
106
+ end
107
+ ```
108
+
63
109
  ## Configuration options
64
110
 
65
111
  MailchimpAPI client accepts this additional options:
@@ -128,13 +174,46 @@ end
128
174
 
129
175
  ...
130
176
 
131
- ## Errors
177
+ ## APIs
132
178
 
133
- ...
179
+ ### Audience Members
134
180
 
135
- ## APIs
181
+ - List `MailchimpAPI.audience_members.get(audience_id)`
182
+ - Create `MailchimpAPI.audience_members.create(audience_id, body: body)`
183
+ - Show `MailchimpAPI.audience_members.show(audience_id, email)`
184
+ - Update `MailchimpAPI.audience_members.update(audience_id, email, body: body)`
185
+ - Add or Update `MailchimpAPI.audience_members.add_or_update(audience_id, email, body: body)`
186
+ - Archive `MailchimpAPI.audience_members.delete(audience_id, email)`
187
+ - Delete Permanently `MailchimpAPI.audience_members.delete(audience_id, email)`
136
188
 
137
- ...
189
+ ### Audience Member Tags
190
+
191
+ - List `MailchimpAPI.audience_member_tags.get(audience_id, email)`
192
+ - Create `MailchimpAPI.audience_member_tags.create(audience_id, email, body: body)`
193
+
194
+ ### Audience Webhooks
195
+
196
+ - List `MailchimpAPI.audience_webhooks.get(audience_id)`
197
+ - Create `MailchimpAPI.audience_webhooks.create(audience_id, body: body)`
198
+ - Show `MailchimpAPI.audience_webhooks.show(audience_id, webhook_id)`
199
+ - Update `MailchimpAPI.audience_webhooks.update(audience_id, webhook_id, body: body)`
200
+ - Delete `MailchimpAPI.audience_webhooks.delete(audience_id, webhook_id)`
201
+
202
+ ### Audience Interest Categories
203
+
204
+ - List `MailchimpAPI.audience_interest_categories.get(audience_id)`
205
+ - Create `MailchimpAPI.audience_interest_categories.create(audience_id, body: body)`
206
+ - Show `MailchimpAPI.audience_interest_categories.show(audience_id, webhook_id)`
207
+ - Update `MailchimpAPI.audience_interest_categories.update(audience_id, webhook_id, body: body)`
208
+ - Delete `MailchimpAPI.audience_interest_categories.delete(audience_id, webhook_id)`
209
+
210
+ ### Audience Interests
211
+
212
+ - List `MailchimpAPI.audience_interests.get(audience_id)`
213
+ - Create `MailchimpAPI.audience_interests.create(audience_id, body: body)`
214
+ - Show `MailchimpAPI.audience_interests.show(audience_id, webhook_id)`
215
+ - Update `MailchimpAPI.audience_interests.update(audience_id, webhook_id, body: body)`
216
+ - Delete `MailchimpAPI.audience_interests.delete(audience_id, webhook_id)`
138
217
 
139
218
  ## Development
140
219
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -6,13 +6,25 @@ module MailchimpAPI
6
6
  # Methods to access API resources
7
7
  #
8
8
  module APIMethods
9
- def audience_members
10
- Audience::Members.new(self)
9
+ def audience_interest_categories
10
+ Audience::InterestCategories.new(self)
11
+ end
12
+
13
+ def audience_interests
14
+ Audience::Interests.new(self)
11
15
  end
12
16
 
13
17
  def audience_member_tags
14
18
  Audience::MemberTags.new(self)
15
19
  end
20
+
21
+ def audience_members
22
+ Audience::Members.new(self)
23
+ end
24
+
25
+ def audience_webhooks
26
+ Audience::Webhooks.new(self)
27
+ end
16
28
  end
17
29
  end
18
30
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MailchimpAPI
4
+ module Audience
5
+ class InterestCategories < Resource
6
+ module APIs
7
+ def list(list_id, query: nil, body: nil, headers: nil)
8
+ path = "/lists/#{list_id}/interest-categories"
9
+ client.get(path, query: query, body: body, headers: headers)
10
+ end
11
+
12
+ def create(list_id, query: nil, body: nil, headers: nil)
13
+ path = "/lists/#{list_id}/interest-categories"
14
+ client.post(path, query: query, body: body, headers: headers)
15
+ end
16
+
17
+ def show(list_id, interest_category_id, query: nil, body: nil, headers: nil)
18
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}"
19
+ client.get(path, query: query, body: body, headers: headers)
20
+ end
21
+
22
+ def delete(list_id, interest_category_id, query: nil, body: nil, headers: nil)
23
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}"
24
+ client.delete(path, query: query, body: body, headers: headers)
25
+ end
26
+
27
+ def update(list_id, interest_category_id, query: nil, body: nil, headers: nil)
28
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}"
29
+ client.patch(path, query: query, body: body, headers: headers)
30
+ end
31
+ end
32
+
33
+ include APIs
34
+ extend APIs
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MailchimpAPI
4
+ module Audience
5
+ class Interests < Resource
6
+ module APIs
7
+ def list(list_id, interest_category_id, query: nil, body: nil, headers: nil)
8
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}/interests"
9
+ client.get(path, query: query, body: body, headers: headers)
10
+ end
11
+
12
+ def create(list_id, interest_category_id, query: nil, body: nil, headers: nil)
13
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}/interests"
14
+ client.post(path, query: query, body: body, headers: headers)
15
+ end
16
+
17
+ def show(list_id, interest_category_id, interest_id, query: nil, body: nil, headers: nil)
18
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}/interests/#{interest_id}"
19
+ client.get(path, query: query, body: body, headers: headers)
20
+ end
21
+
22
+ def delete(list_id, interest_category_id, interest_id, query: nil, body: nil, headers: nil)
23
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}/interests/#{interest_id}"
24
+ client.delete(path, query: query, body: body, headers: headers)
25
+ end
26
+
27
+ def update(list_id, interest_category_id, interest_id, query: nil, body: nil, headers: nil)
28
+ path = "/lists/#{list_id}/interest-categories/#{interest_category_id}/interests/#{interest_id}"
29
+ client.patch(path, query: query, body: body, headers: headers)
30
+ end
31
+ end
32
+
33
+ include APIs
34
+ extend APIs
35
+ end
36
+ end
37
+ end
@@ -4,13 +4,13 @@ module MailchimpAPI
4
4
  module Audience
5
5
  class MemberTags < Resource
6
6
  module APIs
7
- def list(audience_id, email, query: nil, body: nil, headers: nil)
8
- path = "/lists/#{audience_id}/members/#{subscriber_hash(email)}/tags"
7
+ def list(list_id, email, query: nil, body: nil, headers: nil)
8
+ path = "/lists/#{list_id}/members/#{subscriber_hash(email)}/tags"
9
9
  client.get(path, query: query, body: body, headers: headers)
10
10
  end
11
11
 
12
- def create(audience_id, email, query: nil, body: nil, headers: nil)
13
- path = "/lists/#{audience_id}/members/#{subscriber_hash(email)}/tags"
12
+ def create(list_id, email, query: nil, body: nil, headers: nil)
13
+ path = "/lists/#{list_id}/members/#{subscriber_hash(email)}/tags"
14
14
  client.post(path, query: query, body: body, headers: headers)
15
15
  end
16
16
  end
@@ -4,38 +4,38 @@ module MailchimpAPI
4
4
  module Audience
5
5
  class Members < Resource
6
6
  module APIs
7
- def list(audience_id, query: nil, body: nil, headers: nil)
8
- path = "/lists/#{audience_id}/members"
7
+ def list(list_id, query: nil, body: nil, headers: nil)
8
+ path = "/lists/#{list_id}/members"
9
9
  client.get(path, query: query, body: body, headers: headers)
10
10
  end
11
11
 
12
- def create(audience_id, query: nil, body: nil, headers: nil)
13
- path = "/lists/#{audience_id}/members"
12
+ def create(list_id, query: nil, body: nil, headers: nil)
13
+ path = "/lists/#{list_id}/members"
14
14
  client.post(path, query: query, body: body, headers: headers)
15
15
  end
16
16
 
17
- def show(audience_id, email, query: nil, body: nil, headers: nil)
18
- path = "/lists/#{audience_id}/members/#{subscriber_hash(email)}"
17
+ def show(list_id, email, query: nil, body: nil, headers: nil)
18
+ path = "/lists/#{list_id}/members/#{subscriber_hash(email)}"
19
19
  client.get(path, query: query, body: body, headers: headers)
20
20
  end
21
21
 
22
- def archive(audience_id, email, query: nil, body: nil, headers: nil)
23
- path = "/lists/#{audience_id}/members/#{subscriber_hash(email)}"
22
+ def archive(list_id, email, query: nil, body: nil, headers: nil)
23
+ path = "/lists/#{list_id}/members/#{subscriber_hash(email)}"
24
24
  client.delete(path, query: query, body: body, headers: headers)
25
25
  end
26
26
 
27
- def update(audience_id, email, query: nil, body: nil, headers: nil)
28
- path = "/lists/#{audience_id}/members/#{subscriber_hash(email)}"
27
+ def update(list_id, email, query: nil, body: nil, headers: nil)
28
+ path = "/lists/#{list_id}/members/#{subscriber_hash(email)}"
29
29
  client.patch(path, query: query, body: body, headers: headers)
30
30
  end
31
31
 
32
- def add_or_update(audience_id, email, query: nil, body: nil, headers: nil)
33
- path = "/lists/#{audience_id}/members/#{subscriber_hash(email)}"
32
+ def add_or_update(list_id, email, query: nil, body: nil, headers: nil)
33
+ path = "/lists/#{list_id}/members/#{subscriber_hash(email)}"
34
34
  client.put(path, query: query, body: body, headers: headers)
35
35
  end
36
36
 
37
- def delete_permanent(audience_id, email, query: nil, body: nil, headers: nil)
38
- path = "/lists/#{audience_id}/members/#{subscriber_hash(email)}/actions/delete-permanent"
37
+ def delete_permanent(list_id, email, query: nil, body: nil, headers: nil)
38
+ path = "/lists/#{list_id}/members/#{subscriber_hash(email)}/actions/delete-permanent"
39
39
  client.post(path, query: query, body: body, headers: headers)
40
40
  end
41
41
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MailchimpAPI
4
+ module Audience
5
+ class Webhooks < Resource
6
+ module APIs
7
+ def list(list_id, query: nil, body: nil, headers: nil)
8
+ path = "/lists/#{list_id}/webhooks"
9
+ client.get(path, query: query, body: body, headers: headers)
10
+ end
11
+
12
+ def create(list_id, query: nil, body: nil, headers: nil)
13
+ path = "/lists/#{list_id}/webhooks"
14
+ client.post(path, query: query, body: body, headers: headers)
15
+ end
16
+
17
+ def show(list_id, webhook_id, query: nil, body: nil, headers: nil)
18
+ path = "/lists/#{list_id}/webhooks/#{webhook_id}"
19
+ client.get(path, query: query, body: body, headers: headers)
20
+ end
21
+
22
+ def delete(list_id, webhook_id, query: nil, body: nil, headers: nil)
23
+ path = "/lists/#{list_id}/webhooks/#{webhook_id}"
24
+ client.delete(path, query: query, body: body, headers: headers)
25
+ end
26
+
27
+ def update(list_id, webhook_id, query: nil, body: nil, headers: nil)
28
+ path = "/lists/#{list_id}/webhooks/#{webhook_id}"
29
+ client.patch(path, query: query, body: body, headers: headers)
30
+ end
31
+ end
32
+
33
+ include APIs
34
+ extend APIs
35
+ end
36
+ end
37
+ end
data/lib/mailchimp-api.rb CHANGED
@@ -35,8 +35,11 @@ module MailchimpAPI
35
35
 
36
36
  # Resources
37
37
  def_delegators :@client,
38
+ :audience_interest_categories,
39
+ :audience_interests,
40
+ :audience_member_tags,
38
41
  :audience_members,
39
- :audience_member_tags
42
+ :audience_webhooks
40
43
 
41
44
  def client
42
45
  raise "#{name}.client must be set" unless @client
@@ -48,8 +51,11 @@ end
48
51
 
49
52
  require_relative "mailchimp-api/resource"
50
53
  require_relative "mailchimp-api/resources/audience/utils/subscriber_hash"
54
+ require_relative "mailchimp-api/resources/audience/interest_categories"
55
+ require_relative "mailchimp-api/resources/audience/interests"
51
56
  require_relative "mailchimp-api/resources/audience/member_tags"
52
57
  require_relative "mailchimp-api/resources/audience/members"
58
+ require_relative "mailchimp-api/resources/audience/webhooks"
53
59
  require_relative "mailchimp-api/batch_request"
54
60
  require_relative "mailchimp-api/client/api_methods"
55
61
  require_relative "mailchimp-api/client/batch_methods"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailchimp-rest-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Glushkov
@@ -31,9 +31,12 @@ files:
31
31
  - lib/mailchimp-api/request.rb
32
32
  - lib/mailchimp-api/request_executor.rb
33
33
  - lib/mailchimp-api/resource.rb
34
+ - lib/mailchimp-api/resources/audience/interest_categories.rb
35
+ - lib/mailchimp-api/resources/audience/interests.rb
34
36
  - lib/mailchimp-api/resources/audience/member_tags.rb
35
37
  - lib/mailchimp-api/resources/audience/members.rb
36
38
  - lib/mailchimp-api/resources/audience/utils/subscriber_hash.rb
39
+ - lib/mailchimp-api/resources/audience/webhooks.rb
37
40
  - lib/mailchimp-api/response.rb
38
41
  - lib/mailchimp-api/uri_builder.rb
39
42
  - lib/mailchimp-api/version.rb