Class: Dawn::Key

Inherits:
Object
  • Object
show all
Includes:
BaseApi
Defined in:
lib/dawn/api/key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseApi

included

Methods included from BaseApi::Extension

#json_request, #request

Constructor Details

#initialize(data) ⇒ Key

Returns a new instance of Key.



10
11
12
# File 'lib/dawn/api/key.rb', line 10

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/dawn/api/key.rb', line 8

def data
  @data
end

Class Method Details

.add(pubkey) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/dawn/api/key.rb', line 34

def self.add(pubkey)
  new json_request(
    method: :post,
    expects: 200,
    path: '/account/keys',
    query: { key: pubkey }
  )["key"]
end

.all(options = {}) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/dawn/api/key.rb', line 51

def self.all(options={})
  json_request(
    method: :get,
    expects: 200,
    path: '/account/keys',
    query: options
  ).map { |hsh| new(hsh["key"]) }
end

.destroy(options = {}) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/dawn/api/key.rb', line 60

def self.destroy(options={})
  request(
    method: :delete,
    expects: 200,
    path: "/account/keys/#{options[:id]}"
  )
end

.get(id) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/dawn/api/key.rb', line 43

def self.get(id)
  new json_request(
    method: :get,
    expects: 200,
    path: "/account/keys/#{id}"
  )["key"]
end

Instance Method Details

#destroyObject



26
27
28
29
30
31
32
# File 'lib/dawn/api/key.rb', line 26

def destroy
  request(
    method: :delete,
    expects: 200,
    path: "/account/keys/#{id}"
  )
end

#fingerprintObject



18
19
20
# File 'lib/dawn/api/key.rb', line 18

def fingerprint
  data["fingerprint"]
end

#idObject



14
15
16
# File 'lib/dawn/api/key.rb', line 14

def id
  data["id"]
end

#keyObject



22
23
24
# File 'lib/dawn/api/key.rb', line 22

def key
  data["key"]
end