Module: HtmlCssToImage

Defined in:
lib/html_css_to_image.rb,
lib/html_css_to_image/image.rb,
lib/html_css_to_image/version.rb,
lib/html_css_to_image/data/image.rb

Defined Under Namespace

Modules: Data Classes: Error, Image

Constant Summary collapse

API_SCHEME =
"https"
API_HOST =
"hcti.io"
API_VERSION =
"v1"
API_ORIGIN =
"#{API_SCHEME}://#{API_HOST}"
VERSION =
"0.1.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_key=(value) ⇒ Object (writeonly)

Sets the attribute api_key

Parameters:

  • value

    the value to set the attribute api_key to.



20
21
22
# File 'lib/html_css_to_image.rb', line 20

def api_key=(value)
  @api_key = value
end

.user_id=(value) ⇒ Object (writeonly)

Sets the attribute user_id

Parameters:

  • value

    the value to set the attribute user_id to.



20
21
22
# File 'lib/html_css_to_image.rb', line 20

def user_id=(value)
  @user_id = value
end

Class Method Details

.connectionObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/html_css_to_image.rb', line 22

def connection
  raise "API key not set" if @api_key.nil?
  raise "User id not set" if @user_id.nil?

  Faraday.new(API_ORIGIN) do |connection|
    connection.adapter Faraday.default_adapter
    connection.headers["Content-Type"] = "application/json"
    connection.headers["Accept"]       = "application/json"
    connection.basic_auth @user_id, @api_key
  end
end