Skip to content

Instantly share code, notes, and snippets.

@pjc
Created August 10, 2013 08:37
Show Gist options
  • Save pjc/6199616 to your computer and use it in GitHub Desktop.
Save pjc/6199616 to your computer and use it in GitHub Desktop.
FACTUAL_KEY = #omitted
FACTUAL_SECRET_KEY = #omitted
LOB_TEST_API_KEY = #omitted
require 'factual'
require 'lob'
factual = Factual.new(FACTUAL_KEY, FACTUAL_SECRET_KEY)
hotels = factual.table("hotels-us").limit(20).rows
Lob.api_key = LOB_TEST_API_KEY
@lob = Lob()
hotels.each do |hotel|
@lob.addresses.create(
name: hotel['name'],
address_line1: hotel['address'],
city: hotel['locality'],
state: hotel['region'],
country: 'US',
zip: hotel['postcode'].to_i
)
puts "Hotel #{hotel["name"]} has been created at Lob."
end
puts
puts "Here is the list of addresses from Lob:"
puts @lob.addresses.list
# puts "Hotel #{i+1} has the following info:"
# puts "Name is: #{hotel['name']}"
# puts "Address line 1 (address) is: #{hotel['address']}"
# puts "City (locality) is: #{hotel['locality']}"
# puts "State (region) is: #{hotel['region']}"
# puts "Zip (postcode) is: #{hotel['postcode']}"
# puts "=" * 75
# gem 'httparty'
# response = HTTParty.get('http://api.v3.factual.com/t/hotes-us/schema')
# puts response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment