class Hubspot::Api::TransactionEmail::SingleSend

Attributes

hapikey[RW]

Public Class Methods

new(hapikey) click to toggle source
# File lib/hubspot/api/transaction_email/single_send.rb, line 11
def initialize(hapikey)
  @hapikey = hapikey
end
post(options) click to toggle source
# File lib/hubspot/api/transaction_email/single_send.rb, line 16
def post(options)
  config = Hubspot.configuration
  SingleSend.new(config.hapikey).post(options)
end

Public Instance Methods

post(options = {}) click to toggle source
# File lib/hubspot/api/transaction_email/single_send.rb, line 22
def post(options = {})
  raise ArgumentError, "EmailId: Required Error" if options.dig(:emailId).blank? 
  raise ArgumentError, "To: Required Error" if options.dig(:message, :to).blank?
  raise KeyError, "Hubspot Api Key Error" if hapikey.blank?

  response = Hubspot.post("/email/public/v1/singleEmail/send?hapikey=#{hapikey}", options)
  if response[:status] == "200"
    response
  else
    raise StandardError, "Something went wrong!"
  end
end