Init create_lead, fix MailblusterHelper name

This commit is contained in:
Ziyi 2021-03-13 15:22:19 -08:00 committed by CactusPuppy
parent 27baa935c1
commit 5500fc8acf
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82
2 changed files with 21 additions and 4 deletions

View file

@ -1,9 +1,26 @@
# frozen_string_literal: true
module External
module Mailbluster
module MailblusterHelper
def create_lead(user)
# TODO
begin
uri = URI("api.mailbluster.com/api/leads")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.path,
{'Authorization' => ENV["MAILBLUSTER_API_KEY"]}) # TODO Authorization=APIKEY
request.body = {'firstName' => user.name,
'email' => user.email,
'subscribed' => true,
'tags' => ["snapcon"],
'overrideExisting' => true}.to_json
response = http.request(request)
puts response
return true
rescue => e
puts "ERROR #{e}"
return false
end
end
end
end
end