Refactor Mailbluster API URL into a constant
This commit is contained in:
parent
340865ddbd
commit
4db96208e8
1 changed files with 23 additions and 24 deletions
47
app/helpers/external/mailbluster_helper.rb
vendored
47
app/helpers/external/mailbluster_helper.rb
vendored
|
|
@ -2,36 +2,35 @@
|
||||||
|
|
||||||
module External
|
module External
|
||||||
module MailblusterHelper
|
module MailblusterHelper
|
||||||
def query_api()
|
MAILBLUSTER_URL = 'https://api.mailbluster.com/api/leads'
|
||||||
|
|
||||||
end
|
def query_api; end
|
||||||
|
|
||||||
def create_lead(user)
|
def create_lead(user)
|
||||||
# TODO
|
# TODO
|
||||||
begin
|
|
||||||
uri = URI("http://api.mailbluster.com/api/leads")
|
uri = URI(MAILBLUSTER_URL)
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
request = Net::HTTP::Post.new(uri.path,
|
request = Net::HTTP::Post.new(uri.path,
|
||||||
{'Authorization' => ENV["MAILBLUSTER_API_KEY"]}) # TODO Authorization=APIKEY
|
'Authorization' => ENV['MAILBLUSTER_API_KEY']) # TODO: Authorization=APIKEY
|
||||||
request.body = {
|
request.body = {
|
||||||
'email' => user.email,
|
'email' => user.email,
|
||||||
'firstName' => user.name,
|
'firstName' => user.name,
|
||||||
'overrideExisting' => true,
|
'overrideExisting' => true,
|
||||||
'subscribed' => true,
|
'subscribed' => true,
|
||||||
'tags' => ["snapcon"],
|
'tags' => ['snapcon']
|
||||||
}.to_json
|
}.to_json
|
||||||
response = http.request(request)
|
response = http.request(request)
|
||||||
# puts request.body.to_json
|
# puts request.body.to_json
|
||||||
# puts response.body.to_json
|
# puts response.body.to_json
|
||||||
return response.to_json
|
response.to_json
|
||||||
rescue => e
|
rescue StandardError => e
|
||||||
puts "ERROR #{e}"
|
puts "ERROR #{e}"
|
||||||
return nil
|
nil
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_lead(user)
|
def delete_lead(user)
|
||||||
|
# TODO
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue