SmartyStreets not getting zip codes - zipcode

I installed SmartyStreets on my form and all works fine except for the zip code which does not populate. I also notice on the page for SmartyStreets where you can try the samples the zip code does not populate. Is this normal, is there a problem with the API or with my installation?
I am using the following on my page:
<script src="//d79i1fxsrar4t.cloudfront.net/jquery.liveaddress/2.5/jquery.liveaddress.min.js"></script>
<script>var liveaddress = $.LiveAddress({
key: mykey,
addresses: [{
street: '#edit-submitted-address',
city: '#edit-submitted-city',
state: '#edit-submitted-state',
zipcode: '#edit-submitted-zip'
}]
});
</script>

I work for SmartyStreets. Our autocomplete service doesn't return the ZIP Code on its own. The ZIP Code should populate once the address has been verified, because confirming the ZIP is part of the verification process.
If the ZIP isn't populating even after the address has been validated, then there is a problem with your setup. You'll want to check to make sure the fields on your form are all mapped correctly. See more in the mapping docs.

Related

How can I add unsubscribe links to my emails when sending via sendgrid/mail

I'm sending emails using: https://github.com/sendgrid/sendgrid-nodejs/tree/master/packages/mail
I have not been able to find out HOW I can add the Unsubscribe equivalent. This is documented in here: https://sendgrid.com/docs/Classroom/Basics/Marketing_Campaigns/unsubscribe_groups.html#-Using-a-Custom-Unsubscribe-Link
On the website, you just use a shortcode [Unsubscribe], this does not work when sending emails via the sendgrid/mail package.
One tip that would have saved me an hour or two is that:
It's possible to send the following in the api json along with other stuff:
"asm":{
"group_id":123,
"groups_to_display": [123],
}
then the following variables become available to use within the template:
<%asm_group_unsubscribe_raw_url%>
<%asm_preferences_raw_url%>
If you want to keep things simple don't include the following variable as it fiddles with too many things (this wasn't obvious from the documentation so obviously I did so and wasted time :( ):
"tracking_settings": {
"subscription_tracking": {
"enable": true,
"substitution_tag": "[unsubscribe_url]"
}
}
Just use them in their raw format and you shall be fine.
Since you're sending using code, it's a "transactional" type of message. You'll want to either turn on the Subscription Tracking filter at the account level (via [UI](subscription tracking setting) or API), or turn it on as you send the message, as part of the mail/send API call, under tracking_settings.
It's important to note that you can't mix those. If you define anything in the mail/send API call, you'll need to define everything for Subscription Tracking in that call. SendGrid won't look at some settings at the mail level, and some at the account level.
Most users will just set it at the account level. There, you can customize the HTML & Text of the Unsubscribe footer, customize the HTML of the landing page, or redirect landing to a URL of your choosing, which will send the recipient there with ?email=test#domain.com in the URL string for your system to catch. You can also define the "replacement tag" like [%unsubscribe%], so that you can place the URL wherever you want within your HTML.
https://app.sendgrid.com/ > Suppressions > Unsubscribe Groups > Create New Group
Note down group_id/ids. e.g 123 (Only number !Not string)
Send email using node.js
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(SENDGRID_API_KEY);
const tags = { invitedBy : Alex }
const msg = {
to: email,
from: { "email": SENDER_EMAIL,
"name": SENDER_NAME
},
templateId: TEMPLATE_ID,
dynamic_template_data: {
Sender_Name: name,
...tags
},
asm: {
group_id: 123,
groups_to_display: [
123
],
},
};
await sgMail.send(msg);
The best approach is to use Group Unsubscribes.
First create a group in Sendgrid:
Groups > Unsubscribe Groups > Create a group
Next, insert a module into the Sendgrid template that creates specific tags in your email, which are populated when you make an API request
Go to your template
Insert an unsubscribe module in an HTML block
Save
Finally make an API request and specify the group created in step 1:
"asm":{
"group_id":544,
"groups_to_display": [544, 788],
}
These will be inserted into the module mentioned in step 2 when the email is sent.
Unfortunately Sendgrid unsubscribe links are not as straightforward as they could be. They are explained in more detail here
The easiest way is to do this via the SendGrid GUI.
Go to Settings -> Tracking -> Subscription Tracking

How to restrict returned Wordpress REST-API fields when using WP-API Node Module

If I call this Wordpress blog url in a browser
<root...>wp-json/wp/v2/posts?per_page=5&fields=id,link,title
I get back JSON and the result is restricted to 3 fields
So how can I do this when using the node js wp-api module?
I would like something similar to .fields([]) but there is nothing in the docs, can find nothing in the module code.
TypeError: wpapi.posts(...).perPage(...).fields is not a function
Or something like .filter({})
TypeError: wpapi.posts(...).perPage(...).filter is not a function
But I think this might be connected with another Wordpress plugin that's required.
wpapi.posts()
.perPage(5)
.fields(['id','link','title'])
.search( 'search-term' ) //= (search in title or content)
.filter({
category_name: 'islands',
fields: [ 'id','link','title' ]
})
.get(function (err, data) {
..... etc.
TypeError: wpapi.posts(...).perPage(...).fields is not a function
Can anyone point me in the right direction? Thanks
It appears wp-api node module does not allow this.
So I uninstalled it and am now using axios along with standard text urls.
This worked for me:
wpapi.posts().param('_fields', 'id,title,content').get()
The node-wpapi documentation seems to suggest say that perPage() and functions like it are convenience functions that call param(props, value).
wpapi.posts().param('_fields', ['id','title','content']).get()
also seems to work but the first option gives a resulting request url that looks more like the format the Wordpress REST API Handbook uses

Meteor Routing and subsequent data order

I got stuck at understanding Meteor Routes and data flow.
In the beginning it was simple blog app, with 1 collection named Posts.
Now I want to store history of changes, so I've created a second collection and named it History.
On every edit in Posts I'm adding state of post (author,content, etc ...) to History including the ID of edited post.
Question is how should I configure Iron Router to make it pass the current post id to posts/:_id/history from previous state (posts/:_id/) and get entries from History with this matching ID?
To pass the id from one view to the next, you can do it via template like so:
<a href="/posts/1/history>Post History</a>
or
<a href="/posts/{{_id}}/history>Post History</a>
or programmatically like so:
Router.go('postHistory', {_id: 1});
To get the history entries, you can resolve the data in iron router during the route request as so:
this.route('postHistory', {
path: '/posts/:_id/history',
data: function() {
return History.findOne({postId: this.params._id});
}
});
Without seeing your code it is hard to tell what you have tried already. But in order to help you understand Meteor routes perhaps you could take a look at these two links:
This introduction to routes with Iron Router
This link on more advanced routes
These should help you comprehend how to make two collections work together.

Retrieving chromebook user email in extension

I have a chrome extension installed on a Chromebook. I'm looking for a way for that extension to retrieve the email address with which I'm currently signed into the Chromebook. I tried using the following:
chrome.identity.getProfileUserInfo(function(userInfo){
console.log(userInfo.email);
});
However it's always empty.
Thanks!
As stated in this answer, to use the new chrome.identity.getProfileUserInfo API you'll need to request the permission for "identity.email" in your manifest.
So first of all add it to your manifest.json:
"permissions": {
...
"identity.email"
...
}
Then you can call the method as you wanted:
chrome.identity.getProfileUserInfo(function(info) {
console.log(info);
});
// {email: "someone#somesite.com", id: xxxxxx}

Angular JS: Full example of GET/POST/DELETE/PUT client for a REST/CRUD backend?

I've implemented a REST/CRUD backend by following this article as an example: http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/ . I have MongoDB running locally, I'm not using MongoLabs.
I've followed the Google tutorial that uses ngResource and a Factory pattern and I have query (GET all items), get an item (GET), create an item (POST), and delete an item (DELETE) working. I'm having difficulty implementing PUT the way the backend API wants it -- a PUT to a URL that includes the id (.../foo/) and also includes the updated data.
I have this bit of code to define my services:
angular.module('realmenServices', ['ngResource']).
factory('RealMen', function($resource){
return $resource('http://localhost\\:3000/realmen/:entryId', {}, {
query: {method:'GET', params:{entryId:''}, isArray:true},
post: {method:'POST'},
update: {method:'PUT'},
remove: {method:'DELETE'}
});
I call the method from this controller code:
$scope.change = function() {
RealMen.update({entryId: $scope.entryId}, function() {
$location.path('/');
});
}
but when I call the update function, the URL does not include the ID value: it's only "/realmen", not "/realmen/ID".
I've tried various solutions involving adding a "RealMen.prototype.update", but still cannot get the entryId to show up on the URL. (It also looks like I'll have to build the JSON holding just the DB field values myself -- the POST operation does it for me automatically when creating a new entry, but there doesn't seem to be a data structure that only contains the field values when I'm viewing/editing a single entry).
Is there an example client app that uses all four verbs in the expected RESTful way?
I've also seen references to Restangular and another solution that overrides $save so that it can issue either a POST or PUT (http://kirkbushell.me/angular-js-using-ng-resource-in-a-more-restful-manner/). This technology seems to be changing so rapidly that there doesn't seem to be a good reference solution that folks can use as an example.
I'm the creator of Restangular.
You can take a look at this CRUD example to see how you can PUT/POST/GET elements without all that URL configuration and $resource configuration that you need to do. Besides it, you can then use nested resources without any configuration :).
Check out this plunkr example:
http://plnkr.co/edit/d6yDka?p=preview
You could also see the README and check the documentation here https://github.com/mgonto/restangular
If you need some feature that's not there, just create an issue. I usually add features asked within a week, as I also use this library for all my AngularJS projects :)
Hope it helps!
Because your update uses PUT method, {entryId: $scope.entryId} is considered as data, to tell angular generate from the PUT data, you need to add params: {entryId: '#entryId'} when you define your update, which means
return $resource('http://localhost\\:3000/realmen/:entryId', {}, {
query: {method:'GET', params:{entryId:''}, isArray:true},
post: {method:'POST'},
update: {method:'PUT', params: {entryId: '#entryId'}},
remove: {method:'DELETE'}
});
Fix: Was missing a closing curly brace on the update line.
You can implement this way
$resource('http://localhost\\:3000/realmen/:entryId', {entryId: '#entryId'}, {
UPDATE: {method: 'PUT', url: 'http://localhost\\:3000/realmen/:entryId' },
ACTION: {method: 'PUT', url: 'http://localhost\\:3000/realmen/:entryId/action' }
})
RealMen.query() //GET /realmen/
RealMen.save({entryId: 1},{post data}) // POST /realmen/1
RealMen.delete({entryId: 1}) //DELETE /realmen/1
//any optional method
RealMen.UPDATE({entryId:1}, {post data}) // PUT /realmen/1
//query string
RealMen.query({name:'john'}) //GET /realmen?name=john
Documentation:
https://docs.angularjs.org/api/ngResource/service/$resource
Hope it helps