1
私はRails wrapper for the HubSpot APIを使用していますが、連絡先を正常に作成できてもエラーを処理できないようです。Rails 4:HubSpot APIエラーチェック
def createHubSpotContact(potential_client)
puts "creating hubspot contact..."
@potential_client = potential_client
@first_name = @potential_client.name.split(" ").first || "N/A"
@last_name = @potential_client.name.split(" ").last || "N/A"
@phone = @potential_client.phone || "N/A"
@email = @potential_client.email || "N/A"
@referrer = @potential_client.referrer || "other"
@city = Location.find(@potential_client.location_id).name || "N/A"
@message = @potential_client.message || "N/A"
contact = Hubspot::Contact.create!(@email, {
firstname: @first_name,
lastname: @last_name,
phone: @phone,
email: @email,
referrer: @referrer,
city: @city,
message: @message
})
# What can I do to handle an error here?
end