Module: Myra::Domains

Extended by:
RequestHandler
Defined in:
lib/myra/actions/domains.rb

Constant Summary collapse

PATH =
'/domains'

Class Method Summary collapse

Methods included from RequestHandler

errors, handle

Class Method Details

.create(domain) ⇒ Object



14
15
16
17
18
19
# File 'lib/myra/actions/domains.rb', line 14

def self.create(domain)
  request = Request.new(path: PATH, type: :put)
  request.payload = Oj.dump(domain.to_hash)
  value = handle request
  Domain.from_hash(value['targetObject'].first)
end

.delete(domain) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/myra/actions/domains.rb', line 21

def self.delete(domain)
  request = Request.new(path: PATH, type: :delete)
  payload = domain.to_hash.select { |k, _| %w(id modified).include?(k) }
  request.payload = Oj.dump(payload)
  value = handle request
  Domain.from_hash(value['targetObject'].first)
end

.list(page = 1) ⇒ Object



9
10
11
12
# File 'lib/myra/actions/domains.rb', line 9

def self.list(page = 1)
  values = handle Request.new(path: "#{PATH}/#{page}")
  values['list'].map { |domain| Domain.from_hash(domain) }
end

.update(domain) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/myra/actions/domains.rb', line 29

def self.update(domain)
  request = Request.new path: PATH, type: :post
  payload = domain.to_hash.select do |k, _|
    %w(id modified autoUpdate).include? k
  end
  request.payload = Oj.dump(payload)
  value = handle request
  Domain.from_hash(value['targetObject'].first)
end