Class: RenderRuby::Client

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

Constant Summary collapse

BASE_URL =
'https://api.render.com/v1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
# File 'lib/render_ruby/client.rb', line 9

def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil)
  @api_key = api_key
  @adapter = adapter

  # Test stubs for requests
  @stubs = stubs
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



7
8
9
# File 'lib/render_ruby/client.rb', line 7

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/render_ruby/client.rb', line 7

def api_key
  @api_key
end

Instance Method Details

#connectionObject



37
38
39
40
41
42
43
44
45
# File 'lib/render_ruby/client.rb', line 37

def connection
  @connection ||= Faraday.new(BASE_URL) do |conn|
    conn.request :authorization, :Bearer, api_key
    conn.request :json
    conn.response :json, content_type: 'application/json'

    conn.adapter adapter, @stubs
  end
end

#custom_domainsObject



29
30
31
# File 'lib/render_ruby/client.rb', line 29

def custom_domains
  CustomDomainResource.new(self)
end

#deploysObject



25
26
27
# File 'lib/render_ruby/client.rb', line 25

def deploys
  DeployResource.new(self)
end

#jobsObject



33
34
35
# File 'lib/render_ruby/client.rb', line 33

def jobs
  JobResource.new(self)
end

#ownersObject



17
18
19
# File 'lib/render_ruby/client.rb', line 17

def owners
  OwnerResource.new(self)
end

#servicesObject



21
22
23
# File 'lib/render_ruby/client.rb', line 21

def services
  ServiceResource.new(self)
end