Class: Essence::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/essence/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Client



7
8
9
10
11
12
13
# File 'lib/essence/client.rb', line 7

def initialize(**attributes)
  @client = ::Faraday.new(url: "https://essenceui.com/") do |f|
    f.request :authorization, "Bearer", -> { ::Essence.configuration.licence_key }
    f.request :json
    f.response :json
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/essence/client.rb', line 5

def client
  @client
end

Instance Method Details

#get_component(slug: nil) ⇒ Object



15
16
17
18
19
20
# File 'lib/essence/client.rb', line 15

def get_component(slug: nil)
  return if nil
  client.get("api/v1/components/#{slug}").body
rescue Faraday::Error => error
  puts error
end