File Coverage

blib/lib/Mail/Chimp3.pm
Criterion Covered Total %
statement 23 39 58.9
branch 0 10 0.0
condition 1 2 50.0
subroutine 7 9 77.7
pod 2 2 100.0
total 33 62 53.2


line stmt bran cond sub pod time code
1             package Mail::Chimp3;
2              
3 2     2   107082 use 5.010001;
  2         13  
4 2     2   1154 use Moo;
  2         25250  
  2         9  
5 2     2   3918 use strictures 2;
  2         2945  
  2         67  
6 2     2   1338 use namespace::autoclean 0.16;
  2         28104  
  2         8  
7 2     2   1447 use Types::Standard qw/ Num Str /;
  2         158437  
  2         18  
8              
9             with 'Web::API';
10              
11             # ABSTRACT: An interface to mailchimp.com's RESTful Web API v3 using WEB::API
12              
13             our $VERSION = '0.08'; # VERSION: generated by DZP::OurPkgVersion
14              
15              
16             has endpoints => (
17             is => 'rw',
18             default => sub {
19             {
20             root => { path => '/' },
21              
22             # authorized apps
23             authorized_apps => { path => 'authorized-apps' },
24             authorized_app => { path => 'authorized-apps/:app_id' },
25             add_authorized_app => {
26             method => 'POST',
27             path => 'authorized-apps',
28             mandatory => [ 'client_id', 'client_secret', ],
29             },
30              
31             # automations
32             automations => { path => 'automations' },
33             automation => { path => 'automations/:workflow_id' },
34             pause_automation => {
35             method => 'POST',
36             path => 'automations/:workflow_id/actions/pause-all-emails',
37             },
38             start_automation => {
39             method => 'POST',
40             path => 'automations/:workflow_id/actions/start-all-emails',
41             },
42              
43             # automation emails
44             automation_emails => { path => 'automations/:workflow_id/emails' },
45             automation_email => { path => 'automations/:workflow_id/emails/:workflow_email_id' },
46             pause_automation_email => {
47             method => 'POST',
48             path => 'automations/:workflow_id/emails/:workflow_email_id/actions/pause',
49             },
50             start_automation_email => {
51             method => 'POST',
52             path => 'automations/:workflow_id/emails/:workflow_email_id/actions/start',
53             },
54             add_automation_subscriber => {
55             method => 'POST',
56             path => 'automations/:workflow_id/emails/:workflow_email_id/queue',
57             mandatory => ['email_address'],
58             },
59             automation_subscribers => {
60             path => 'automations/:workflow_id/emails/:workflow_email_id/queue',
61             },
62             automation_subscriber => {
63             path => 'automations/:workflow_id/emails/:workflow_email_id/queue/:subscriber_hash',
64             },
65             remove_automation_subscriber => {
66             method => 'POST',
67             path => 'automations/:workflow_id/removed-subscribers',
68             mandatory => ['email_address'],
69             },
70             removed_automation_subscribers => { path => 'automations/:workflow_id/removed-subscribers' },
71              
72             # batch
73             batches => { path => 'batches' },
74             batch => { path => 'batches/:batch_id' },
75             add_batch => {
76             method => 'POST',
77             path => 'batches',
78             mandatory => ['operations'],
79             },
80             delete_batch => {
81             method => 'DELETE',
82             path => 'batches/:batch_id',
83             },
84              
85             # batch webhooks
86             batch_webhooks => { path => 'batch-webhooks' },
87             batch_webhook => { path => 'batch-webhooks/:batch_webhook_id' },
88             add_batch_webhook => {
89             method => 'POST',
90             path => 'batch-webhooks',
91             mandatory => ['url'],
92             },
93             update_batch_webhook => {
94             method => 'PATCH',
95             path => 'batch-webhooks/:batch_webhook_id',
96             mandatory => ['url'],
97             },
98             delete_batch_webhook => {
99             method => 'DELETE',
100             path => 'batch-webhooks/:batch_webhook_id',
101             },
102              
103             # campaign folders
104             campaign_folders => { path => 'campaign-folders' },
105             campaign_folder => { path => 'campaign-folders/:folder_id' },
106             add_campaign_folder => {
107             method => 'POST',
108             path => 'campaign-folders',
109             mandatory => ['name'],
110             },
111             update_campaign_folder => {
112             method => 'PATCH',
113             path => 'campaign-folders/:folder_id',
114             mandatory => ['name'],
115             },
116             delete_campaign_folder => {
117             method => 'DELETE',
118             path => 'campaign-folders/:folder_id',
119             },
120              
121             # campaigns
122             campaigns => { path => 'campaigns' },
123             campaign => { path => 'campaigns/:campaign_id' },
124             add_campaign => {
125             method => 'POST',
126             path => 'campaigns',
127             mandatory => [ 'type', 'settings' ],
128             },
129             update_campaign => {
130             method => 'PATCH',
131             path => 'campaigns/:campaign_id',
132             mandatory => [ 'type', 'settings' ],
133             },
134             delete_campaign => {
135             method => 'DELETE',
136             path => 'campaigns/:campaign_id',
137             },
138             cancel_campaign => {
139             method => 'POST',
140             path => 'campaigns/:campaign_id/actions/cancel-send',
141             },
142             pause_campaign => {
143             method => 'POST',
144             path => 'campaigns/:campaign_id/actions/pause',
145             },
146             replicate_campaign => {
147             method => 'POST',
148             path => 'campaigns/:campaign_id/actions/replicate',
149             },
150             resume_campaign => {
151             method => 'POST',
152             path => 'campaigns/:campaign_id/actions/resume',
153             },
154             schedule_campaign => {
155             method => 'POST',
156             path => 'campaigns/:campaign_id/actions/schedule',
157             mandatory => ['schedule_time'],
158             },
159             send_campaign => {
160             method => 'POST',
161             path => 'campaigns/:campaign_id/actions/send',
162             },
163             test_campaign => {
164             method => 'POST',
165             path => 'campaigns/:campaign_id/actions/test',
166             mandatory => [ 'test_emails', 'send_type' ],
167             },
168             unschedule_campaign => {
169             method => 'POST',
170             path => 'campaigns/:campaign_id/actions/unschedule',
171             },
172             campaign_content => { path => 'campaigns/:campaign_id/content' },
173             set_campaign_content => {
174             method => 'PUT',
175             path => 'campaigns/:campaign_id/content',
176             },
177             campaign_feedbacks => { path => 'campaigns/:campaign_id/feedback' },
178             campaign_feedback => { path => 'campaigns/:campaign_id/feedback/:feedback_id' },
179             add_campaign_feedback => {
180             method => 'POST',
181             path => 'campaigns/:campaign_id/feedback',
182             mandatory => ['message'],
183             },
184             update_campaign_feedback => {
185             method => 'PATCH',
186             path => 'campaigns/:campaign_id/feedback/:feedback_id',
187             mandatory => ['message'],
188             },
189             delete_campaign_feedback => {
190             method => 'DELETE',
191             path => 'campaigns/:campaign_id/feedback/:feedback_id',
192             },
193             campaign_send_checklist => { path => 'campaigns/:campaign_id/send-checklist' },
194              
195             # connected sites
196             connected_sites => { path => 'connected-sites' },
197             connected_site => { path => 'connected-sites/:connected_site_id' },
198             add_connected_site => {
199             method => 'POST',
200             path => 'connected-sites',
201             mandatory => [
202             qw/
203             foreign_id
204             domain
205             /
206             ],
207             },
208             delete_connected_site => {
209             method => 'DELETE',
210             path => 'connected-sites/:connected_site_id',
211             },
212             verify_connected_site => {
213             method => 'POST',
214             path => 'connected-sites/:connected_site_id/actions/verify-script-installation',
215             },
216              
217             # conversations
218             conversations => { path => 'conversations' },
219             conversation => { path => 'conversations/:conversation_id' },
220             add_conversation_message => {
221             method => 'POST',
222             path => 'conversations/:conversation_id/messages',
223             mandatory => [ 'from_email', 'read' ],
224             },
225             conversation_messages => { path => 'conversation/:conversation_id/messages' },
226             conversation_message => { path => 'conversation/:conversation_id/messages/:message_id' },
227              
228             # ecommerce stores
229             stores => { path => 'ecommerce/stores' },
230             store => { path => 'ecommerce/stores/:store_id' },
231             add_store => {
232             method => 'POST',
233             path => 'ecommerce/stores',
234             mandatory => [ 'id', 'list_id', 'name', 'currency_code', ],
235             },
236             update_store => {
237             method => 'PATCH',
238             path => 'ecommerce/stores/:store_id',
239             },
240             delete_store => {
241             method => 'DELETE',
242             path => 'ecommerce/stores/:store_id',
243             },
244              
245             # ecommerce carts
246             carts => { path => 'ecommerce/stores/:store_id/carts' },
247             cart => { path => 'ecommerce/stores/:store_id/carts/:cart_id' },
248             add_cart => {
249             method => 'POST',
250             path => 'ecommerce/stores/:store_id/carts',
251             mandatory => ['customer'],
252             },
253             update_cart => {
254             method => 'PATCH',
255             path => 'ecommerce/stores/:store_id/carts/:cart_id',
256             },
257             delete_cart => {
258             method => 'DELETE',
259             path => 'ecommerce/stores/:store_id/carts/:cart_id',
260             },
261              
262             # ecommerce cart lines
263             cart_lines => { path => 'ecommerce/stores/:store_id/carts/:cart_id/lines' },
264             cart_line => { path => 'ecommerce/stores/:store_id/carts/:cart_id/lines/:line_id' },
265             add_cart_line => {
266             method => 'POST',
267             path => 'ecommerce/stores/:store_id/carts/:cart_id/lines',
268             mandatory => [
269             qw/
270             id
271             product_id
272             product_variant_id
273             quantity
274             price
275             /
276             ],
277             },
278             update_cart_line => {
279             method => 'PATCH',
280             path => 'ecommerce/stores/:store_id/carts/:cart_id/lines/:line_id',
281             },
282             delete_cart_line => {
283             method => 'DELETE',
284             path => 'ecommerce/stores/:store_id/carts/:cart_id/lines/:line_id',
285             },
286              
287             # ecommerce customers
288             customers => { path => 'ecommerce/stores/:store_id/customers' },
289             customer => { path => 'ecommerce/stores/:store_id/customers/:customer_id' },
290             add_customer => {
291             method => 'POST',
292             path => 'ecommerce/stores/:store_id/customers',
293             mandatory => [
294             qw/
295             id
296             email_address
297             opt_in_status
298             /
299             ],
300             },
301             update_customer => {
302             method => 'PATCH',
303             path => 'ecommerce/stores/:store_id/customers/:customer_id',
304             },
305             upsert_customer => {
306             method => 'PUT',
307             path => 'ecommerce/stores/:store_id/customers/:customer_id',
308             mandatory => [
309             qw/
310             id
311             email_address
312             opt_in_status
313             /
314             ],
315             },
316             delete_customer => {
317             method => 'DELETE',
318             path => 'ecommerce/stores/:store_id/customers/:customer_id',
319             },
320              
321             # ecommerce orders
322             orders => { path => 'ecommerce/stores/:store_id/orders' },
323             order => { path => 'ecommerce/stores/:store_id/orders/:order_id' },
324             add_order => {
325             method => 'POST',
326             path => 'ecommerce/stores/:store_id/orders',
327             mandatory => [
328             qw/
329             id
330             customer
331             currency_code
332             order_total
333             lines
334             /
335             ],
336             },
337             update_order => {
338             method => 'PATCH',
339             path => 'ecommerce/stores/:store_id/orders/:order_id',
340             },
341             delete_order => {
342             method => 'DELETE',
343             path => 'ecommerce/stores/:store_id/orders/:order_id',
344             },
345              
346             # ecommerce order lines
347             order_lines => { path => 'ecommerce/stores/:store_id/orders/:order_id/lines' },
348             order_line => { path => 'ecommerce/stores/:store_id/orders/:order_id/lines/:line_id' },
349             add_order_line => {
350             method => 'POST',
351             path => 'ecommerce/stores/:store_id/orders/:order_id/lines',
352             mandatory => [
353             qw/
354             id
355             product_id
356             product_variant_id
357             quantity
358             price
359             /
360             ],
361             },
362             update_order_line => {
363             method => 'PATCH',
364             path => 'ecommerce/stores/:store_id/orders/:order_id/lines/:line_id',
365             },
366             delete_order_line => {
367             method => 'DELETE',
368             path => 'ecommerce/stores/:store_id/orders/:order_id/lines/:line_id',
369             },
370              
371             # ecommerce products
372             products => { path => 'ecommerce/stores/:store_id/products' },
373             product => { path => 'ecommerce/stores/:store_id/products/:product_id' },
374             add_product => {
375             method => 'POST',
376             path => 'ecommerce/stores/:store_id/products',
377             mandatory => [ 'id', 'title', 'variants', ],
378             },
379             update_product => {
380             method => 'PATCH',
381             path => 'ecommerce/stores/:store_id/products/:product_id',
382             },
383             delete_product => {
384             method => 'DELETE',
385             path => 'ecommerce/stores/:store_id/products/:product_id',
386             },
387              
388             # ecommerce product variants
389             variants => { path => 'ecommerce/stores/:store_id/products/:product_id/variants' },
390             variant => { path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id' },
391             add_variant => {
392             method => 'POST',
393             path => 'ecommerce/stores/:store_id/products/:product_id/variants',
394             mandatory => [ 'id', 'title', ],
395             },
396             update_variant => {
397             method => 'PATCH',
398             path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id',
399             },
400             upsert_variant => {
401             method => 'PUT',
402             path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id',
403             mandatory => [ 'id', 'title', ],
404             },
405             delete_variant => {
406             method => 'DELETE',
407             path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id',
408             },
409              
410             # facebook ads
411             facebook_ads => { path => 'facebook-ads' },
412             facebook_ad => { path => 'facebook-ads/:outreach_id' },
413              
414             # file manager files
415             file_manager_files => { path => 'file-manager/files' },
416             file_manager_file => { path => 'file-manager/files/:file_id' },
417             add_file_manager_file => {
418             method => 'POST',
419             path => 'file-manager/files',
420             mandatory => [ 'name', 'file_data' ],
421             },
422             update_file_manager_file => {
423             method => 'PATCH',
424             path => 'file-manager/files/:file_id',
425             mandatory => [ 'name', 'file_data' ],
426             },
427             delete_file_manager_file => {
428             method => 'DELETE',
429             path => 'file-manager/files/:file_id',
430             },
431              
432             # file manager folders
433             file_manager_folders => { path => 'file-manager/folders' },
434             file_manager_folder => { path => 'file-manager/folders/:folder_id' },
435             add_file_manager_folder => {
436             method => 'POST',
437             path => 'file-manager/folders',
438             mandatory => ['name'],
439             },
440             update_file_manager_folder => {
441             method => 'PATCH',
442             path => 'file-manager/folders/:folder_id',
443             mandatory => ['name'],
444             },
445             delete_file_manager_folder => {
446             method => 'DELETE',
447             path => 'file-manager/folders/:folder_id',
448             },
449              
450             # google ads
451             google_ads => { path => 'google-ads' },
452             google_ads_instance => { path => 'google-ads/:outreach_id' },
453              
454             # landing pages
455             landing_pages => { path => 'landing_pages' },
456             landing_page => { path => 'landing_pages/:page_id' },
457             landing_page_content => { path => 'landing_pages/:page_id/content' },
458             add_landing_page => {
459             method => 'POST',
460             path => 'landing_pages',
461             mandatory => [
462             qw/
463             list_id
464             type
465             /
466             ],
467             },
468             update_landing_page => {
469             method => 'PATCH',
470             path => 'landing_pages/:page_id',
471             },
472             delete_landing_page => {
473             method => 'DELETE',
474             path => 'landing_pages/:page_id',
475             },
476             publish_landing_page => {
477             method => 'POST',
478             path => 'landing_pages/:page_id/actions/publish',
479             mandatory => ['id'],
480             },
481             unpublish_landing_page => {
482             method => 'POST',
483             path => 'landing_pages/:page_id/actions/unpublish',
484             mandatory => ['id'],
485             },
486              
487             # lists
488             lists => { path => 'lists' },
489             list => { path => 'lists/:list_id' },
490             add_list => {
491             method => 'POST',
492             path => 'lists',
493             mandatory => [
494             qw/
495             name
496             contact
497             permission_reminder
498             campaign_defaults
499             email_type_option
500             /
501             ],
502             },
503             update_list => {
504             method => 'PATCH',
505             path => 'lists/:list_id',
506             mandatory => [
507             qw/
508             name
509             contact
510             permission_reminder
511             campaign_defaults
512             email_type_option
513             /
514             ],
515             },
516             delete_list => {
517             method => 'DELETE',
518             path => 'lists/:list_id',
519             },
520             batch_list => {
521             method => 'POST',
522             path => 'lists/:list_id',
523             mandatory => ['members'],
524             },
525             abuse_reports => { path => 'lists/:list_id/abuse-reports' },
526             abuse_report => { path => 'lists/:list_id/abuse-reports/:report_id' },
527             list_activity => { path => 'lists/:list_id/activity' },
528             list_clients => { path => 'lists/:list_id/clients' },
529             growth_history => { path => 'lists/:list_id/growth-history' },
530             growth_history_month => { path => 'lists/:list_id/growth-history/:month' },
531              
532             # list interests
533             interest_categories => { path => 'lists/:list_id/interest-categories' },
534             interest_category => { path => 'lists/:list_id/interest-categories/:interest_category_id' },
535             add_interest_category => {
536             method => 'POST',
537             path => 'lists/:list_id/interest-categories',
538             mandatory => [ 'title', 'type' ],
539             },
540             update_interest_category => {
541             method => 'PATCH',
542             path => 'lists/:list_id/interest-categories/:interest_category_id',
543             mandatory => [ 'title', 'type' ],
544             },
545             delete_interest_category => {
546             method => 'DELETE',
547             path => 'lists/:list_id/interest-categories/:interest_category_id',
548             },
549             interests => { path => 'lists/:list_id/interest-categories/:interest_category_id/interests' },
550             interest => { path => 'lists/:list_id/interest-categories/:interest_category_id/interests/:interest_id' },
551             add_interest => {
552             method => 'POST',
553             path => 'lists/:list_id/interest-categories/:interest_category_id/interests',
554             mandatory => ['name'],
555             },
556             update_interest => {
557             method => 'PATCH',
558             path => 'lists/:list_id/interest-categories/:interest_category_id/interests/:interest_id',
559             mandatory => ['name'],
560             },
561             delete_interest => {
562             method => 'DELETE',
563             path => 'lists/:list_id/interest-categories/:interest_category_id/interests/:interest_id',
564             },
565              
566             # list members
567             members => { path => 'lists/:list_id/members' },
568             member => { path => 'lists/:list_id/members/:subscriber_hash' },
569             add_member => {
570             method => 'POST',
571             path => 'lists/:list_id/members',
572             mandatory => [ 'status', 'email_address', ],
573             },
574             update_member => {
575             method => 'PATCH',
576             path => 'lists/:list_id/members/:subscriber_hash',
577             },
578             upsert_member => {
579             method => 'PUT',
580             path => 'lists/:list_id/members/:subscriber_hash',
581             mandatory => [
582             qw/
583             email_address
584             status_if_new
585             /
586             ],
587             },
588             delete_member => {
589             method => 'DELETE',
590             path => 'lists/:list_id/members/:subscriber_hash',
591             },
592             member_activity => { path => 'lists/:list_id/members/:subscriber_hash/activity' },
593             member_goals => { path => 'lists/:list_id/members/:subscriber_hash/goals' },
594              
595             # list member notes
596             member_notes => { path => 'lists/:list_id/members/:subscriber_hash/notes' },
597             member_note => { path => 'lists/:list_id/members/:subscriber_hash/notes/:note_id' },
598             add_member_note => {
599             method => 'POST',
600             path => 'lists/:list_id/members/:subscriber_hash/notes',
601             mandatory => ['note'],
602             },
603             update_member_note => {
604             method => 'POST',
605             path => 'lists/:list_id/members/:subscriber_hash/notes/:note_id',
606             mandatory => ['note'],
607             },
608             delete_member_note => {
609             method => 'DELETE',
610             path => 'lists/:list_id/members/:subscriber_hash/notes/:note_id',
611             },
612              
613             # list member tags
614             member_tags => { path => 'lists/:list_id/members/:subscriber_hash/tags' },
615             add_member_tag => {
616             method => 'POST',
617             path => 'lists/:list_id/members/:subscriber_hash/tags',
618             mandatory => ['tags'],
619             },
620             update_member_tag => {
621             method => 'POST',
622             path => 'lists/:list_id/members/:subscriber_hash/tags',
623             mandatory => ['tags'],
624             },
625              
626             # list merge fields
627             merge_fields => { path => 'lists/:list_id/merge-fields' },
628             merge_field => { path => 'lists/:list_id/merge-fields/:merge_id' },
629             add_merge_field => {
630             method => 'POST',
631             path => 'lists/:list_id/merge-fields',
632             mandatory => [ 'name', 'type', ],
633             },
634             update_merge_field => {
635             method => 'PATCH',
636             path => 'lists/:list_id/merge-fields/:merge_id',
637             },
638             delete_merge_field => {
639             method => 'DELETE',
640             path => 'lists/:list_id/merge-fields/:merge_id',
641             },
642              
643             # list segments
644             segments => { path => 'lists/:list_id/segments' },
645             segment => { path => 'lists/:list_id/segments/:segment_id' },
646             add_segment => {
647             method => 'POST',
648             path => 'lists/:list_id/segments',
649             mandatory => ['name'],
650             },
651             update_segment => {
652             method => 'PATCH',
653             path => 'lists/:list_id/segments/:segment_id',
654             },
655             delete_segment => {
656             method => 'DELETE',
657             path => 'lists/:list_id/segments/:segment_id',
658             },
659             segment_members => { path => 'lists/:list_id/segments/:segment_id/members' },
660             add_segment_member => {
661             method => 'POST',
662             path => 'lists/:list_id/segments/:segment_id/members'
663             },
664             delete_segment_member => {
665             method => 'DELETE',
666             path => 'lists/:list_id/segments/:segment_id/members/:subscriber_hash'
667             },
668             batch_segment => {
669             method => 'POST',
670             path => 'lists/:list_id/segments/:segment_id',
671             },
672              
673             # list other
674             twitter_cards => { path => 'lists/:list_id/twitter-lead-gen-cards' },
675             twitter_card => { path => 'lists/:list_id/twitter-lead-gen-cards/:twitter_card_id' },
676             add_twitter_card => {
677             method => 'POST',
678             path => 'lists/:list_id/twitter-lead-gen-cards',
679             mandatory => [
680             qw/
681             name
682             title
683             cta_text
684             privacy_policy_url
685             image_url
686             twitter_account_id
687             /
688             ],
689             },
690             webhooks => { path => 'lists/:list_id/webhooks' },
691             webhook => { path => 'lists/:list_id/webhooks/:webhook_id' },
692             add_webhook => {
693             method => 'POST',
694             path => 'lists/:list_id/webhooks'
695             },
696             delete_webhook => {
697             method => 'DELETE',
698             path => 'lists/:list_id/webhooks/:webhook_id'
699             },
700              
701             # ping
702             ping => { path => 'ping' },
703              
704             # reporting
705             reporting => { path => 'reporting' },
706             reporting_facebook_ads => { path => 'reporting/facebook-ads' },
707             reporting_facebook_ad => { path => 'reporting/facebook-ads/:outreach_id' },
708             reporting_facebook_ad_ecommerce => { path => 'reporting/facebook-ads/:outreach_id/ecommerce-product-activity' },
709             reporting_google_ads => { path => 'reporting/google-ads' },
710             reporting_google_ad => { path => 'reporting/google-ads/:outreach_id' },
711             reporting_google_ad_ecommerce => { path => 'reporting/google-ads/:outreach_id/ecommerce-product-activity' },
712             reporting_landing_pages => { path => 'reporting/landing-pages' },
713             reporting_landing_page => { path => 'reporting/landing-pages/:outreach_id' },
714              
715             # reports
716             reports => { path => 'reports' },
717             report => { path => 'reports/:campaign_id' },
718             abuse_reports => { path => 'reports/:campaign_id/abuse-reports' },
719             abuse_report => { path => 'reports/:campaign_id/abuse-reports/:report_id' },
720             advice => { path => 'reports/:campaign_id/advice' },
721             click_details => { path => 'reports/:campaign_id/click-details' },
722             click_detail => { path => 'reports/:campaign_id/click-details/:link_id' },
723             click_details_members => { path => 'reports/:campaign_id/click-details/:link_id/members' },
724             click_details_member => { path => 'reports/:campaign_id/click-details/:link_id/members/:subscriber_hash' },
725             domain_performance => { path => 'reports/:campaign_id/domain-performance' },
726             eepurl => { path => 'reports/:campaign_id/eepurl' },
727             email_activity => { path => 'reports/:campaign_id/email-activity' },
728             member_email_activity => { path => 'reports/:campaign_id/email-activity/:subscriber_hash' },
729             locations => { path => 'reports/:campaign_id/locations' },
730             sent_to => { path => 'reports/:campaign_id/sent-to' },
731             member_sent_to => { path => 'reports/:campaign_id/sent-to/:subscriber_hash' },
732             sub_reports => { path => 'reports/:campaign_id/sub-reports' },
733             unsubscribed => { path => 'reports/:campaign_id/unsubscribed' },
734             member_unsubscribed => { path => 'reports/:campaign_id/unsubscribed/:subscriber_hash' },
735              
736             # search campaigns
737             search_campaigns => { path => 'search-campaigns' },
738              
739             # search members
740             search_members => { path => 'search-members' },
741              
742             # template folders
743             template_folders => { path => 'template-folders' },
744             template_folder => { path => 'template-folders/:folder_id' },
745             add_template_folder => {
746             method => 'POST',
747             path => 'template-folders',
748             mandatory => ['name'],
749             },
750             update_template_folder => {
751             method => 'PATCH',
752             path => 'template-folders/:folder_id',
753             mandatory => ['name'],
754             },
755             delete_template_folder => {
756             method => 'DELETE',
757             path => 'template-folders/:folder_id',
758             },
759              
760             # templates
761             templates => { path => 'templates' },
762             template => { path => 'templates/:template_id' },
763             add_template => {
764             method => 'POST',
765             path => 'templates',
766             mandatory => [ 'name', 'html' ],
767             },
768             update_template => {
769             method => 'PATCH',
770             path => 'templates/:template_id',
771             mandatory => [ 'name', 'html' ],
772             },
773             delete_template => {
774             method => 'DELETE',
775             path => 'templates/:template_id',
776             },
777             template_default_content => { path => 'templates/:template_id/default-content' },
778             # verified domains
779             verified_domains => { path => 'verified_domains' },
780             verified_domain_name => { path => 'verified_domains/:domain_name' },
781             add_domain_name => {
782             method => 'POST',
783             path => 'verified_domains',
784             },
785             delete_domain_name => {
786             method => 'DELETE',
787             path => 'verified_domains/:domain_name',
788             },
789             verify_domain_name => {
790             method => 'POST',
791             path => 'verified_domains/:domain_name/actions/verify',
792             },
793             };
794             },
795             );
796              
797             has chimp_api_version => (
798             is => 'ro',
799             isa => Num,
800             default => sub { '3.0' },
801             );
802              
803             has chimp_datacenter => (
804             is => 'lazy',
805             isa => Str,
806             default => sub {
807             my $self = shift;
808             if ($self->api_key) {
809             my ($dc) = ( $self->api_key =~ /\-(\w+)$/ );
810             return $dc;
811             }
812             else {
813             return 'us1';
814             }
815             },
816             );
817              
818             has '+decoder' => (
819             builder => 1,
820             );
821              
822              
823             sub _build_decoder {
824 1     1   120 my $self = shift;
825             return sub {
826 0     0   0 my ($content, $content_type) = @_;
827 0         0 my $data = {};
828 0 0       0 return $data unless $content;
829 0         0 for ($content_type) {
830 0 0       0 /plain/ and do {
831 0         0 chomp $content;
832 0         0 $data = { text => $content };
833             };
834 0 0       0 /urlencoded/ and do {
835 0         0 for (split /&/, $content) {
836 0         0 my ($key, $value) = split /=/;
837 0         0 $data->{ uri_unescape($key) } = uri_unescape($value);
838             }
839             };
840 0 0       0 /json/ and $data = $self->json->decode($content);
841 0 0       0 /(xml|html)/ and $data = $self->xml->XMLin( $content, NoAttr => 0 );
842             }
843 0         0 return $data;
844 1         18 };
845             }
846              
847              
848             sub commands {
849 0     0 1 0 my ($self) = @_;
850 0         0 return $self->endpoints;
851             }
852              
853              
854             sub BUILD {
855 1     1 1 147 my ($self) = @_;
856              
857 1   50     21 $self->user_agent( __PACKAGE__ . ' ' . ($Mail::Chimp3::VERSION || '') );
858 1         54 $self->base_url( 'https://' . $self->chimp_datacenter . '.api.mailchimp.com/' . $self->chimp_api_version );
859 1         86 $self->auth_type('basic');
860 1         40 $self->user('anystring');
861 1         40 $self->content_type('application/json');
862              
863 1         26 return $self;
864             }
865              
866              
867             1;
868              
869             __END__