class InlineCssHtmlConverter::Worker
Constants
- API_VERSION
Public Class Methods
new(apikey, html)
click to toggle source
# 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
Public Instance Methods
perform()
click to toggle source
# File lib/inline-css-html-converter/worker.rb, line 20 def perform result = call_mailchimp result['html'] end
Private Instance Methods
call_mailchimp()
click to toggle source
# File lib/inline-css-html-converter/worker.rb, line 27 def call_mailchimp HTTParty.post(call_url, body: parameters.to_json, verify: true, headers: { 'Content-Type' => 'application/json' }) end
call_url()
click to toggle source
# File lib/inline-css-html-converter/worker.rb, line 34 def call_url @host + '/helper/inline-css.json' end
parameters()
click to toggle source
# File lib/inline-css-html-converter/worker.rb, line 38 def parameters { apikey: @apikey, html: @html } end