Skip to content

Instantly share code, notes, and snippets.

@CZagrobelny
Last active December 27, 2018 22:33
Show Gist options
  • Save CZagrobelny/f9bfc7c340ac917d7f06ff8517d96e6a to your computer and use it in GitHub Desktop.
Save CZagrobelny/f9bfc7c340ac917d7f06ff8517d96e6a to your computer and use it in GitHub Desktop.
# To run: ruby tag_nation_builder_person.thor tag [EMAIL]
require 'rubygems'
gem 'thor'
require 'thor'
gem 'nationbuilder-rb', require: 'nationbuilder'
require 'nationbuilder'
class TagNationBuilderPerson < Thor
desc 'tag PERSON', 'Find a NationBuilder person by email and tag them'
def tag(email)
begin
client = NationBuilder::Client.new('my_nation_name', 'my_api_token', retries: 8)
match = client.call(:people, :match, email: email)
nb_id = match['person']['id']
tagging = client.call(:people, :tag_person, id: nb_id, "tagging": { "tag": "completed_google_form" })
puts "Successfully tagged #{email} with: #{tagging}"
rescue => e
puts "Tagging #{email} failed: #{e}"
end
end
end
TagNationBuilderPerson.start(ARGV)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment