Class: NeetoCommonsBackend::Services::CustomDomain
- Inherits:
-
Object
- Object
- NeetoCommonsBackend::Services::CustomDomain
- Defined in:
- lib/neeto_commons_backend/services/custom_domain_service.rb
Instance Attribute Summary collapse
-
#default_url ⇒ Object
readonly
Returns the value of attribute default_url.
-
#domain_name ⇒ Object
readonly
Returns the value of attribute domain_name.
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(domain_name) ⇒ CustomDomain
constructor
A new instance of CustomDomain.
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_url ⇒ Object (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_name ⇒ Object (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
#create ⇒ Object
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 |
#delete ⇒ Object
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 |