Class: Lita::Handlers::Digitalocean::Domain

Inherits:
Base
  • Object
show all
Defined in:
lib/lita/handlers/digitalocean/domain.rb

Instance Method Summary collapse

Instance Method Details

#create(response) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/lita/handlers/digitalocean/domain.rb', line 23

def create(response)
  name, ip_address = response.args[2..3]

  do_response = do_call(response) do |client|
    client.domains.create(name: name, ip_address: ip_address)
  end or return

  response.reply(t("domains.create.created", do_response[:domain]))
end

#delete(response) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/lita/handlers/digitalocean/domain.rb', line 33

def delete(response)
  do_response = do_call(response) do |client|
    client.domains.delete(response.args[2])
  end or return

  response.reply(t("domains.delete.deleted"))
end

#list(response) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/lita/handlers/digitalocean/domain.rb', line 41

def list(response)
  do_response = do_call(response) do |client|
    client.domains.list
  end or return

  messages = do_response[:domains].map { |domain| t("domains.list.detail", domain) }

  response.reply(*messages)
end

#show(response) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/lita/handlers/digitalocean/domain.rb', line 51

def show(response)
  do_response = do_call(response) do |client|
    client.domains.show(response.args[2])
  end or return

  response.reply(t("domains.show.details", do_response[:domain]))
end