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   55491 use 5.010001;
  2         14  
4 2     2   890 use Moo;
  2         18361  
  2         9  
5 2     2   3157 use strictures 2;
  2         2602  
  2         69  
6 2     2   1065 use namespace::autoclean 0.16;
  2         21980  
  2         9  
7 2     2   1143 use Types::Standard qw/ Num Str /;
  2         123709  
  2         22  
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.07'; # 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             delete_product => {
380             method => 'DELETE',
381             path => 'ecommerce/stores/:store_id/products/:product_id',
382             },
383              
384             # ecommerce product variants
385             variants => { path => 'ecommerce/stores/:store_id/products/:product_id/variants' },
386             variant => { path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id' },
387             add_variant => {
388             method => 'POST',
389             path => 'ecommerce/stores/:store_id/products/:product_id/variants',
390             mandatory => [ 'id', 'title', ],
391             },
392             update_variant => {
393             method => 'PATCH',
394             path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id',
395             },
396             upsert_variant => {
397             method => 'PUT',
398             path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id',
399             mandatory => [ 'id', 'title', ],
400             },
401             delete_variant => {
402             method => 'DELETE',
403             path => 'ecommerce/stores/:store_id/products/:product_id/variants/:variant_id',
404             },
405              
406             # facebook ads
407             facebook_ads => { path => 'facebook-ads' },
408             facebook_ad => { path => 'facebook-ads/:outreach_id' },
409              
410             # file manager files
411             file_manager_files => { path => 'file-manager/files' },
412             file_manager_file => { path => 'file-manager/files/:file_id' },
413             add_file_manager_file => {
414             method => 'POST',
415             path => 'file-manager/files',
416             mandatory => [ 'name', 'file_data' ],
417             },
418             update_file_manager_file => {
419             method => 'PATCH',
420             path => 'file-manager/files/:file_id',
421             mandatory => [ 'name', 'file_data' ],
422             },
423             delete_file_manager_file => {
424             method => 'DELETE',
425             path => 'file-manager/files/:file_id',
426             },
427              
428             # file manager folders
429             file_manager_folders => { path => 'file-manager/folders' },
430             file_manager_folder => { path => 'file-manager/folders/:folder_id' },
431             add_file_manager_folder => {
432             method => 'POST',
433             path => 'file-manager/folders',
434             mandatory => ['name'],
435             },
436             update_file_manager_folder => {
437             method => 'PATCH',
438             path => 'file-manager/folders/:folder_id',
439             mandatory => ['name'],
440             },
441             delete_file_manager_folder => {
442             method => 'DELETE',
443             path => 'file-manager/folders/:folder_id',
444             },
445              
446             # google ads
447             google_ads => { path => 'google-ads' },
448             google_ads_instance => { path => 'google-ads/:outreach_id' },
449              
450             # landing pages
451             landing_pages => { path => 'landing_pages' },
452             landing_page => { path => 'landing_pages/:page_id' },
453             landing_page_content => { path => 'landing_pages/:page_id/content' },
454             add_landing_page => {
455             method => 'POST',
456             path => 'landing_pages',
457             mandatory => [
458             qw/
459             list_id
460             type
461             /
462             ],
463             },
464             update_landing_page => {
465             method => 'PATCH',
466             path => 'landing_pages/:page_id',
467             },
468             delete_landing_page => {
469             method => 'DELETE',
470             path => 'landing_pages/:page_id',
471             },
472             publish_landing_page => {
473             method => 'POST',
474             path => 'landing_pages/:page_id/actions/publish',
475             mandatory => ['id'],
476             },
477             unpublish_landing_page => {
478             method => 'POST',
479             path => 'landing_pages/:page_id/actions/unpublish',
480             mandatory => ['id'],
481             },
482              
483             # lists
484             lists => { path => 'lists' },
485             list => { path => 'lists/:list_id' },
486             add_list => {
487             method => 'POST',
488             path => 'lists',
489             mandatory => [
490             qw/
491             name
492             contact
493             permission_reminder
494             campaign_defaults
495             email_type_option
496             /
497             ],
498             },
499             update_list => {
500             method => 'PATCH',
501             path => 'lists/:list_id',
502             mandatory => [
503             qw/
504             name
505             contact
506             permission_reminder
507             campaign_defaults
508             email_type_option
509             /
510             ],
511             },
512             delete_list => {
513             method => 'DELETE',
514             path => 'lists/:list_id',
515             },
516             batch_list => {
517             method => 'POST',
518             path => 'lists/:list_id',
519             mandatory => ['members'],
520             },
521             abuse_reports => { path => 'lists/:list_id/abuse-reports' },
522             abuse_report => { path => 'lists/:list_id/abuse-reports/:report_id' },
523             list_activity => { path => 'lists/:list_id/activity' },
524             list_clients => { path => 'lists/:list_id/clients' },
525             growth_history => { path => 'lists/:list_id/growth-history' },
526             growth_history_month => { path => 'lists/:list_id/growth-history/:month' },
527              
528             # list interests
529             interest_categories => { path => 'lists/:list_id/interest-categories' },
530             interest_category => { path => 'lists/:list_id/interest-categories/:interest_category_id' },
531             add_interest_category => {
532             method => 'POST',
533             path => 'lists/:list_id/interest-categories',
534             mandatory => [ 'title', 'type' ],
535             },
536             update_interest_category => {
537             method => 'PATCH',
538             path => 'lists/:list_id/interest-categories/:interest_category_id',
539             mandatory => [ 'title', 'type' ],
540             },
541             delete_interest_category => {
542             method => 'DELETE',
543             path => 'lists/:list_id/interest-categories/:interest_category_id',
544             },
545             interests => { path => 'lists/:list_id/interest-categories/:interest_category_id/interests' },
546             interest => { path => 'lists/:list_id/interest-categories/:interest_category_id/interests/:interest_id' },
547             add_interest => {
548             method => 'POST',
549             path => 'lists/:list_id/interest-categories/:interest_category_id/interests',
550             mandatory => ['name'],
551             },
552             update_interest => {
553             method => 'PATCH',
554             path => 'lists/:list_id/interest-categories/:interest_category_id/interests/:interest_id',
555             mandatory => ['name'],
556             },
557             delete_interest => {
558             method => 'DELETE',
559             path => 'lists/:list_id/interest-categories/:interest_category_id/interests/:interest_id',
560             },
561              
562             # list members
563             members => { path => 'lists/:list_id/members' },
564             member => { path => 'lists/:list_id/members/:subscriber_hash' },
565             add_member => {
566             method => 'POST',
567             path => 'lists/:list_id/members',
568             mandatory => [ 'status', 'email_address', ],
569             },
570             update_member => {
571             method => 'PATCH',
572             path => 'lists/:list_id/members/:subscriber_hash',
573             },
574             upsert_member => {
575             method => 'PUT',
576             path => 'lists/:list_id/members/:subscriber_hash',
577             mandatory => [
578             qw/
579             email_address
580             status_if_new
581             /
582             ],
583             },
584             delete_member => {
585             method => 'DELETE',
586             path => 'lists/:list_id/members/:subscriber_hash',
587             },
588             member_activity => { path => 'lists/:list_id/members/:subscriber_hash/activity' },
589             member_goals => { path => 'lists/:list_id/members/:subscriber_hash/goals' },
590              
591             # list member notes
592             member_notes => { path => 'lists/:list_id/members/:subscriber_hash/notes' },
593             member_note => { path => 'lists/:list_id/members/:subscriber_hash/notes/:note_id' },
594             add_member_note => {
595             method => 'POST',
596             path => 'lists/:list_id/members/:subscriber_hash/notes',
597             mandatory => ['note'],
598             },
599             update_member_note => {
600             method => 'POST',
601             path => 'lists/:list_id/members/:subscriber_hash/notes/:note_id',
602             mandatory => ['note'],
603             },
604             delete_member_note => {
605             method => 'DELETE',
606             path => 'lists/:list_id/members/:subscriber_hash/notes/:note_id',
607             },
608              
609             # list member tags
610             member_tags => { path => 'lists/:list_id/members/:subscriber_hash/tags' },
611             add_member_tag => {
612             method => 'POST',
613             path => 'lists/:list_id/members/:subscriber_hash/tags',
614             mandatory => ['tags'],
615             },
616             update_member_tag => {
617             method => 'POST',
618             path => 'lists/:list_id/members/:subscriber_hash/tags',
619             mandatory => ['tags'],
620             },
621              
622             # list merge fields
623             merge_fields => { path => 'lists/:list_id/merge-fields' },
624             merge_field => { path => 'lists/:list_id/merge-fields/:merge_id' },
625             add_merge_field => {
626             method => 'POST',
627             path => 'lists/:list_id/merge-fields',
628             mandatory => [ 'name', 'type', ],
629             },
630             update_merge_field => {
631             method => 'PATCH',
632             path => 'lists/:list_id/merge-fields/:merge_id',
633             },
634             delete_merge_field => {
635             method => 'DELETE',
636             path => 'lists/:list_id/merge-fields/:merge_id',
637             },
638              
639             # list segments
640             segments => { path => 'lists/:list_id/segments' },
641             segment => { path => 'lists/:list_id/segments/:segment_id' },
642             add_segment => {
643             method => 'POST',
644             path => 'lists/:list_id/segments',
645             mandatory => ['name'],
646             },
647             update_segment => {
648             method => 'PATCH',
649             path => 'lists/:list_id/segments/:segment_id',
650             },
651             delete_segment => {
652             method => 'DELETE',
653             path => 'lists/:list_id/segments/:segment_id',
654             },
655             segment_members => { path => 'lists/:list_id/segments/:segment_id/members' },
656             add_segment_member => {
657             method => 'POST',
658             path => 'lists/:list_id/segments/:segment_id/members'
659             },
660             delete_segment_member => {
661             method => 'DELETE',
662             path => 'lists/:list_id/segments/:segment_id/members/:subscriber_hash'
663             },
664             batch_segment => {
665             method => 'POST',
666             path => 'lists/:list_id/segments/:segment_id',
667             },
668              
669             # list other
670             twitter_cards => { path => 'lists/:list_id/twitter-lead-gen-cards' },
671             twitter_card => { path => 'lists/:list_id/twitter-lead-gen-cards/:twitter_card_id' },
672             add_twitter_card => {
673             method => 'POST',
674             path => 'lists/:list_id/twitter-lead-gen-cards',
675             mandatory => [
676             qw/
677             name
678             title
679             cta_text
680             privacy_policy_url
681             image_url
682             twitter_account_id
683             /
684             ],
685             },
686             webhooks => { path => 'lists/:list_id/webhooks' },
687             webhook => { path => 'lists/:list_id/webhooks/:webhook_id' },
688             add_webhook => {
689             method => 'POST',
690             path => 'lists/:list_id/webhooks'
691             },
692             delete_webhook => {
693             method => 'DELETE',
694             path => 'lists/:list_id/webhooks/:webhook_id'
695             },
696              
697             # ping
698             ping => { path => 'ping' },
699              
700             # reporting
701             reporting => { path => 'reporting' },
702             reporting_facebook_ads => { path => 'reporting/facebook-ads' },
703             reporting_facebook_ad => { path => 'reporting/facebook-ads/:outreach_id' },
704             reporting_facebook_ad_ecommerce => { path => 'reporting/facebook-ads/:outreach_id/ecommerce-product-activity' },
705             reporting_google_ads => { path => 'reporting/google-ads' },
706             reporting_google_ad => { path => 'reporting/google-ads/:outreach_id' },
707             reporting_google_ad_ecommerce => { path => 'reporting/google-ads/:outreach_id/ecommerce-product-activity' },
708             reporting_landing_pages => { path => 'reporting/landing-pages' },
709             reporting_landing_page => { path => 'reporting/landing-pages/:outreach_id' },
710              
711             # reports
712             reports => { path => 'reports' },
713             report => { path => 'reports/:campaign_id' },
714             abuse_reports => { path => 'reports/:campaign_id/abuse-reports' },
715             abuse_report => { path => 'reports/:campaign_id/abuse-reports/:report_id' },
716             advice => { path => 'reports/:campaign_id/advice' },
717             click_details => { path => 'reports/:campaign_id/click-details' },
718             click_detail => { path => 'reports/:campaign_id/click-details/:link_id' },
719             click_details_members => { path => 'reports/:campaign_id/click-details/:link_id/members' },
720             click_details_member => { path => 'reports/:campaign_id/click-details/:link_id/members/:subscriber_hash' },
721             domain_performance => { path => 'reports/:campaign_id/domain-performance' },
722             eepurl => { path => 'reports/:campaign_id/eepurl' },
723             email_activity => { path => 'reports/:campaign_id/email-activity' },
724             member_email_activity => { path => 'reports/:campaign_id/email-activity/:subscriber_hash' },
725             locations => { path => 'reports/:campaign_id/locations' },
726             sent_to => { path => 'reports/:campaign_id/sent-to' },
727             member_sent_to => { path => 'reports/:campaign_id/sent-to/:subscriber_hash' },
728             sub_reports => { path => 'reports/:campaign_id/sub-reports' },
729             unsubscribed => { path => 'reports/:campaign_id/unsubscribed' },
730             member_unsubscribed => { path => 'reports/:campaign_id/unsubscribed/:subscriber_hash' },
731              
732             # search campaigns
733             search_campaigns => { path => 'search-campaigns' },
734              
735             # search members
736             search_members => { path => 'search-members' },
737              
738             # template folders
739             template_folders => { path => 'template-folders' },
740             template_folder => { path => 'template-folders/:folder_id' },
741             add_template_folder => {
742             method => 'POST',
743             path => 'template-folders',
744             mandatory => ['name'],
745             },
746             update_template_folder => {
747             method => 'PATCH',
748             path => 'template-folders/:folder_id',
749             mandatory => ['name'],
750             },
751             delete_template_folder => {
752             method => 'DELETE',
753             path => 'template-folders/:folder_id',
754             },
755              
756             # templates
757             templates => { path => 'templates' },
758             template => { path => 'templates/:template_id' },
759             add_template => {
760             method => 'POST',
761             path => 'templates',
762             mandatory => [ 'name', 'html' ],
763             },
764             update_template => {
765             method => 'PATCH',
766             path => 'templates/:template_id',
767             mandatory => [ 'name', 'html' ],
768             },
769             delete_template => {
770             method => 'DELETE',
771             path => 'templates/:template_id',
772             },
773             template_default_content => { path => 'templates/:template_id/default-content' },
774             # verified domains
775             verified_domains => { path => 'verified_domains' },
776             verified_domain_name => { path => 'verified_domains/:domain_name' },
777             add_domain_name => {
778             method => 'POST',
779             path => 'verified_domains',
780             },
781             delete_domain_name => {
782             method => 'DELETE',
783             path => 'verified_domains/:domain_name',
784             },
785             verify_domain_name => {
786             method => 'POST',
787             path => 'verified_domains/:domain_name/actions/verify',
788             },
789             };
790             },
791             );
792              
793             has chimp_api_version => (
794             is => 'ro',
795             isa => Num,
796             default => sub { '3.0' },
797             );
798              
799             has chimp_datacenter => (
800             is => 'lazy',
801             isa => Str,
802             default => sub {
803             my $self = shift;
804             if ($self->api_key) {
805             my ($dc) = ( $self->api_key =~ /\-(\w+)$/ );
806             return $dc;
807             }
808             else {
809             return 'us1';
810             }
811             },
812             );
813              
814             has '+decoder' => (
815             builder => 1,
816             );
817              
818              
819             sub _build_decoder {
820 1     1   119 my $self = shift;
821             return sub {
822 0     0   0 my ($content, $content_type) = @_;
823 0         0 my $data = {};
824 0 0       0 return $data unless $content;
825 0         0 for ($content_type) {
826 0 0       0 /plain/ and do {
827 0         0 chomp $content;
828 0         0 $data = { text => $content };
829             };
830 0 0       0 /urlencoded/ and do {
831 0         0 for (split /&/, $content) {
832 0         0 my ($key, $value) = split /=/;
833 0         0 $data->{ uri_unescape($key) } = uri_unescape($value);
834             }
835             };
836 0 0       0 /json/ and $data = $self->json->decode($content);
837 0 0       0 /(xml|html)/ and $data = $self->xml->XMLin( $content, NoAttr => 0 );
838             }
839 0         0 return $data;
840 1         18 };
841             }
842              
843              
844             sub commands {
845 0     0 1 0 my ($self) = @_;
846 0         0 return $self->endpoints;
847             }
848              
849              
850             sub BUILD {
851 1     1 1 161 my ($self) = @_;
852              
853 1   50     22 $self->user_agent( __PACKAGE__ . ' ' . ($Mail::Chimp3::VERSION || '') );
854 1         43 $self->base_url( 'https://' . $self->chimp_datacenter . '.api.mailchimp.com/' . $self->chimp_api_version );
855 1         88 $self->auth_type('basic');
856 1         43 $self->user('anystring');
857 1         39 $self->content_type('application/json');
858              
859 1         28 return $self;
860             }
861              
862              
863             1;
864              
865             __END__