A mailer, member database, and so much more, for digital activism.
Below is the code needed for a custom app on Freshdesk, to load details:
<style>
.identity-row {
border-bottom: 1px solid grey;
margin: 0.6em 0em;
}
.identity-section {
font-size: 16px;
}
</style>
<div class="js-identity-widget">
<div class="content">
<div class="identity-row">
<p class="identity-section"><strong>About</strong></p>
<p><strong>Name:</strong> <span class="js-member-name"></span></p>
<p><strong>Address:</strong> <span class="js-member-address"></span></p>
</div>
<div class="js-member-donations identity-row">
<p class="identity-section"><strong>Donations</strong></p>
<p><strong>Has donated:</strong> <span class="js-has-donated"></span></p>
<div class="js-donation-info">
<p><strong>Number of donations:</strong> <span class="js-donation-count"></span></p>
<p><strong>Last donation:</strong> <span class="js-last-donation"></span></p>
<p><strong>Highest donation:</strong> <span class="js-highest-donation"></span></p>
<p><strong>Average donation:</strong> <span class="js-average-donation"></span></p>
</div>
<div class="js-regular-donation-info">
<p class="identity-section"><strong>Has a regular donation</strong></p>
<p><strong>Amount:</strong> <span class="js-regular-donation-amount"></span></p>
<p><strong>Last changed:</strong> <span class="js-regular-donation-changed"></span></p>
</div>
</div>
<div class="js-mailings-info identity-row">
<p class="identity-section"><strong>Last mailings received</strong></p>
<ul></ul>
</div>
</div>
<div class="error"></div>
</div>
<script type="text/javascript">
var request = {"api_token": "<YOUR API TOKEN>", "email": "", "load_mailings": true};
jQuery.ajax({
url: 'https://<YOUR DEPLOYMENT>/api/member/details',
method: 'POST',
dataType: 'JSON',
data: JSON.stringify(request),
success: function(data) {
jQuery('.js-member-name').text(data.first_name + ' ' + data.last_name);
if (typeof data.address.line1 !== 'undefined') {
jQuery('.js-member-address').text(data.address.line1 + ', ' + data.address.town + ', ' + data.address.postcode);
}
else {
jQuery('.js-member-address').hide();
}
if (data.donations.has_donated) {
jQuery('.js-identity-widget .js-has-donated').text('Yes');
jQuery('.js-identity-widget .js-donation-count').text(data.donations.donation_count);
jQuery('.js-identity-widget .js-last-donation').text(data.donations.last_donated);
jQuery('.js-identity-widget .js-highest-donation').text(data.donations.highest_donation);
jQuery('.js-identity-widget .js-average-donation').text(data.donations.average_donation);
}
else {
jQuery('.js-identity-widget .js-has-donated').text('No');
jQuery('.js-donation-info').hide();
}
if (parseInt(data.regular_donation.current_amount) > 0) {
jQuery('.js-regular-donation-info').show();
jQuery('.js-regular-donation-info .js-regular-donation-amount').text(data.regular_donation.current_amount);
jQuery('.js-regular-donation-info .js-regular-donation-changed').text(data.regular_donation.amount_last_changed);
}
else {
jQuery('.js-regular-donation-info').hide();
}
if (data.mailings.length > 0) {
data.mailings.forEach(function(mailing, index) {
var opened = 'No';
if (mailing.first_opened === true) {
opened = 'Yes';
}
var clicked = 'No';
if (mailing.first_clicked === true) {
clicked = 'Yes';
}
var mailingHtml = '<li><strong>' + mailing.subject + '</strong><p>Received: ' + mailing.started_send_at + '<br/>Opened: ' + opened + '<br/>Clicked: ' + clicked + '</li>';
jQuery(mailingHtml).appendTo(jQuery('.js-mailings-info ul'));
});
}
},
error: function(xhr, status, errorMsg) {
jQuery('.js-identity-widget').html('Could not look up member information.');
}
});
</script>