module DomainOwner

Constants

API_URL

API_URL = 'owner.platform.monster/api/domains'

VERSION

Public Class Methods

request(domain:, owner_id:, key:) click to toggle source
# File lib/domain_owner.rb, line 14
def request(domain:, owner_id:, key:)
  body = ask(domain: domain, owner_id: owner_id, key: key)
  JSON.parse(body)
end

Private Class Methods

ask(form) click to toggle source
# File lib/domain_owner.rb, line 21
def ask(form)
  uri = URI(API_URL)
  res = ::Net::HTTP.post_form(URI(API_URL), form)
  return res.body if res.is_a?(Net::HTTPOK)

  # 404:
  raise WrongParams.new('Check params') if res.is_a?(Net::HTTPNotFound)
  raise ServerError.new('Something weng wrong') if res.is_a?(Net::HTTPServerError)

  res.body
end