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

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

Instance Method Summary collapse

Methods inherited from Base

name

Instance Method Details

#create(response) ⇒ Object



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

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



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

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



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

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



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

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