Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 26c0ed66cf | 
							
								
								
									
										38
									
								
								lib/apis.js
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								lib/apis.js
									
									
									
									
									
								
							| @ -431,8 +431,38 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) { | |||||||
|               enumerable: true |               enumerable: true | ||||||
|             , configurable: false |             , configurable: false | ||||||
|             , get: function () { |             , get: function () { | ||||||
|                 var Mailchimp = require('mailchimp-api-v3'); |                 if (_mailchimp) { | ||||||
|                 _mailchimp = _mailchimp || new Mailchimp(siteConfig['mailchimp.com'].apiKey); |                   return _mailchimp; | ||||||
|  |                 } | ||||||
|  |                 var Mailchimp = new (require('mailchimp-api-v3'))(siteConfig['mailchimp@daplie.com'].apiKey); | ||||||
|  |                 _mailchimp = { | ||||||
|  |                   saveSubscriber: function (email, opts) { | ||||||
|  |                     var config = siteConfig['mailchimp@daplie.com']; | ||||||
|  |                     var interests = {}; | ||||||
|  |                     Object.keys(config.defaultInterests).forEach(function (name) { | ||||||
|  |                       interests[config.defaultInterests[name]] = true; | ||||||
|  |                     }); | ||||||
|  |                     Object.keys(config.optionalInterests).forEach(function (name) { | ||||||
|  |                       if (opts[name]) { | ||||||
|  |                         interests[config.optionalInterests[name]] = true; | ||||||
|  |                       } | ||||||
|  |                     }); | ||||||
|  | 
 | ||||||
|  |                     Mailchimp.post({ | ||||||
|  |                       // Daplie Updates list
 | ||||||
|  |                       path: '/lists/' + config.listId + '/members' | ||||||
|  |                     , body: { | ||||||
|  |                         'email_address': email | ||||||
|  |                       , 'status_if_new': 'subscribed' | ||||||
|  |                       , 'status': 'subscribed' | ||||||
|  |                       , 'interests': interests | ||||||
|  |                       } | ||||||
|  |                     }).catch(function (err) { | ||||||
|  |                       console.error("mailchimp failure", email, JSON.stringify(opts)); | ||||||
|  |                       console.error(err); | ||||||
|  |                     }); | ||||||
|  |                   } | ||||||
|  |                 }; | ||||||
|                 return _mailchimp; |                 return _mailchimp; | ||||||
|               } |               } | ||||||
|             }); |             }); | ||||||
| @ -543,6 +573,9 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) { | |||||||
|             function mailgunMail(/*opts*/) { |             function mailgunMail(/*opts*/) { | ||||||
|               return apiDeps.Promise.resolve(req.getSiteMailer()); |               return apiDeps.Promise.resolve(req.getSiteMailer()); | ||||||
|             } |             } | ||||||
|  |             function mailchimpList() { | ||||||
|  |               return apiDeps.Promise.resolve(req.Mailchimp); | ||||||
|  |             } | ||||||
|             function getResponseList() { |             function getResponseList() { | ||||||
|               return apiDeps.Promise.resolve(req.GetResponse); |               return apiDeps.Promise.resolve(req.GetResponse); | ||||||
|             } |             } | ||||||
| @ -611,6 +644,7 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) { | |||||||
|             , 'com.daplie.tel.twilio': twilioTel  // deprecated alias
 |             , 'com.daplie.tel.twilio': twilioTel  // deprecated alias
 | ||||||
| 
 | 
 | ||||||
|             , 'getresponse@daplie.com': getResponseList |             , 'getresponse@daplie.com': getResponseList | ||||||
|  |             , 'mailchimp@daplie.com': mailchimpList | ||||||
|               //
 |               //
 | ||||||
|               // Webhook Parsers
 |               // Webhook Parsers
 | ||||||
|               //
 |               //
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user