Class: Hubspot::Api::TransactionEmail::SingleSend

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot/api/transaction_email/single_send.rb

Defined Under Namespace

Classes: KeyError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hapikey) ⇒ SingleSend

Returns a new instance of SingleSend.



11
12
13
# File 'lib/hubspot/api/transaction_email/single_send.rb', line 11

def initialize(hapikey)
  @hapikey = hapikey
end

Instance Attribute Details

#hapikeyObject

Returns the value of attribute hapikey.



9
10
11
# File 'lib/hubspot/api/transaction_email/single_send.rb', line 9

def hapikey
  @hapikey
end

Class Method Details

.post(options) ⇒ Object



16
17
18
# File 'lib/hubspot/api/transaction_email/single_send.rb', line 16

def post(options)
  SingleSend.new(Hubspot.configuration.hapikey).post(options)
end

Instance Method Details

#post(options = {}) ⇒ Object

TODO: DWE: if RUBY_VERSION > “2.3” See – dig(:message, :to)

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/hubspot/api/transaction_email/single_send.rb', line 22

def post(options = {})
  raise ArgumentError, "EmailId: Required Error" if options[:emailId].blank?
  raise ArgumentError, "To: Required Error" if options[:message].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