Class: InlineCssHtmlConverter::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/inline-css-html-converter/worker.rb

Constant Summary collapse

API_VERSION =
'2.0'

Instance Method Summary collapse

Constructor Details

#initialize(apikey, html) ⇒ Worker

Returns a new instance of Worker.

Raises:



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/inline-css-html-converter/worker.rb', line 7

def initialize(apikey, html)
  raise NoApiKeyGivenError if apikey.nil?

  @apikey = apikey
  @html = html

  if apikey.split('-').length == 2
    @host = "https://#{apikey.split('-')[1]}.api.mailchimp.com/#{API_VERSION}"
  else
    raise InvalidApiKeyError, 'Your MailChimp API key must contain a suffix subdomain (e.g. "-us8").'
  end
end

Instance Method Details

#performObject



20
21
22
23
# File 'lib/inline-css-html-converter/worker.rb', line 20

def perform
  result = call_mailchimp
  result['html']
end