WebService::NationBuilder - NationBuilder API bindings
version 0.0107
use WebService::NationBuilder; my $nb = WebService::NationBuilder->new( access_token => 'abc123', subdomain => 'testing', ); $nb->get_sites();
This module provides bindings for the NationBuilder API.
Instantiates a new WebService::NationBuilder client object.
my $nb = WebService::NationBuilder->new( access_token => $access_token, subdomain => $subdomain, domain => $domain, # optional version => $version, # optional retries => $retries, # optional );
Parameters
access_token
Required
A valid NationBuilder OAuth 2.0 access token for your nation.
subdomain
The NationBuilder subdomain (slug) for your nation.
domain
Optional
The NationBuilder top-level domain to make API calls against. Defaults to nationbuilder.com.
version
The NationBuilder API version to use. Defaults to v1.
v1
retries
The number of times to retry requests in cases when Balanced returns a 5xx response. Defaults to 0.
0
Get information about the sites hosted by a nation.
Request:
get_sites({ page => 1, per_page => 10, });
Response:
[{ id => 1, name => 'Foobar', slug => 'foobar', domain => 'foobarsoftwares.com', }, { id => 2, name => 'Test Site', slug => 'test', domain => undef, }]
Get a list of the people in a nation.
get_people({ page => 1, per_page => 10, });
[{ id => 1, email => 'test@gmail.com' phone => '415-123-4567', mobile => '555-123-4567', first_name => 'Firstname', last_name => 'Lastname', created_at => '2013-12-08T04:27:12-08:00', updated_at => '2013-12-24T12:03:51-08:00', sex => undef, twitter_id => '123456789', primary_address => { address1 => undef, address2 => undef, zip => undef, city => 'San Francisco', state => 'CA', country_code => 'US', lat => '37.7749295', lng => '-122.4194155', } }]
Get a full representation of the person with the provided id.
id
get_person(1);
{ id => 1, email => 'test@gmail.com' phone => '415-123-4567', mobile => '555-123-4578', first_name => 'Firstname', last_name => 'Lastname', created_at => '2013-12-08T04:27:12-08:00', updated_at => '2013-12-24T12:03:51-08:00', sex => undef, twitter_id => '123456789', primary_address => { address1 => undef, address2 => undef, zip => undef, city => 'San Francisco', state => 'CA', country_code => 'US', lat => '37.7749295', lng => '-122.4194155', } }
Get a full representation of the person with certain attributes.
match_person({ email => 'test@gmail.com', phone => '415-123-4567', mobile => '555-123-4567', first_name => 'Firstname', last_name => 'Lastname', });
Create a person with the provided data, and return a full representation of the person who was created.
create_person({ email => 'test@gmail.com', phone => '415-123-4567', mobile => '555-123-4567', first_name => 'Firstname', last_name => 'Lastname', });
{ id => 1, email => 'test@gmail.com' phone => '415-123-4567', mobile => '555-123-4578', first_name => 'Firstname', last_name => 'Lastname', created_at => '2013-12-08T04:27:12-08:00', updated_at => '2013-12-24T12:03:51-08:00', sex => undef, twitter_id => undef, primary_address => undef, }
Update the person with the provided id to have the provided data, and return a full representation of the person who was updated.
update_person(1, { email => 'test2@gmail.com', phone => '123-456-7890', mobile => '999-876-5432', first_name => 'Firstname2', last_name => 'Lastname2', });
{ id => 1, email => 'test2@gmail.com' phone => '123-456-7890', mobile => '999-876-5432', first_name => 'Firstname2', last_name => 'Lastname2', created_at => '2013-12-08T04:27:12-08:00', updated_at => '2013-12-24T12:03:51-08:00', sex => undef, twitter_id => undef, primary_address => undef, }
Update a person matched by email address, or create a new person if no match is found, then return a full representation of the person who was created or updated.
push_person({ email => 'test2@gmail.com', sex => 'M', first_name => 'Firstname3', last_name => 'Lastname3', });
{ id => 1, email => 'test2@gmail.com' phone => '123-456-7890', mobile => '999-876-5432', first_name => 'Firstname3', last_name => 'Lastname3', created_at => '2013-12-08T04:27:12-08:00', updated_at => '2013-12-24T12:03:51-08:00', sex => 'M', twitter_id => undef, primary_address => undef, }
Removes the person with the provided id from the nation.
delete_person(1);
1
Get the tags that have been used before in a nation.
get_tags({ page => 1, per_page => 10, });
[{ name => 'tag1', }, { name => 'tag2', }]
Gets a list of the tags for a given person with the provided id.
get_person_tags(1);
[{ person_id => 1, tag => 'tag1', }, { person_id => 1, tag => 'tag2', }]
Associates a tag to a given person with the provided id.
set_tag(1, 'tag3');
{ person_id => 1, tag => 'tag3', }
Removes a tag from a given person with the provided id.
delete_tag(1, 'tag3');
Ali Anari <ali@anari.me>
This software is copyright (c) 2014 by Crowdtilt, Inc..
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install WebService::NationBuilder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::NationBuilder
CPAN shell
perl -MCPAN -e shell install WebService::NationBuilder
For more information on module installation, please visit the detailed CPAN module installation guide.