Class: NeetoCommonsBackend::Services::CustomDomain

Inherits:
Object
  • Object
show all
Defined in:
lib/neeto_commons_backend/services/custom_domain_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain_name) ⇒ CustomDomain

Returns a new instance of CustomDomain.



8
9
10
11
# File 'lib/neeto_commons_backend/services/custom_domain_service.rb', line 8

def initialize(domain_name)
  @domain_name = domain_name
  @default_url = "https://api.heroku.com/apps/#{Rails.application.secrets.heroku[:app_name]}/domains"
end

Instance Attribute Details

#default_urlObject (readonly)

Returns the value of attribute default_url.



6
7
8
# File 'lib/neeto_commons_backend/services/custom_domain_service.rb', line 6

def default_url
  @default_url
end

#domain_nameObject (readonly)

Returns the value of attribute domain_name.



6
7
8
# File 'lib/neeto_commons_backend/services/custom_domain_service.rb', line 6

def domain_name
  @domain_name
end

Instance Method Details

#createObject



13
14
15
16
17
18
# File 'lib/neeto_commons_backend/services/custom_domain_service.rb', line 13

def create
  params = { hostname: domain_name, sni_endpoint: Rails.application.secrets.heroku[:certificate_name] }
  uri = URI(default_url)
  req = Net::HTTP::Post.new(uri)
  make_api_request(req, params, uri)
end

#deleteObject



20
21
22
23
24
# File 'lib/neeto_commons_backend/services/custom_domain_service.rb', line 20

def delete
  uri = URI("#{default_url}/#{domain_name}")
  req = Net::HTTP::Delete.new(uri)
  make_api_request(req, nil, uri)
end