Class: Dawn::Key

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

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseApi

included, #to_h

Methods included from BaseApi::RequestExtension

#request

Methods included from SafeExtension

#safe

Constructor Details

#initialize(data) ⇒ Key

Returns a new instance of Key.

Parameters:

  • data (Hash)


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

def initialize(data)
  @data = data
end

Class Method Details

.all(options = {}) ⇒ Array<Dawn::Key>

Parameters:

  • options (Hash) (defaults to: {})

Returns:



49
50
51
52
53
54
# File 'lib/dawn/api/models/key.rb', line 49

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

.create(options = {}) ⇒ Dawn::Key

Parameters:

  • options (Hash) (defaults to: {})

Returns:



36
37
38
39
40
41
42
43
# File 'lib/dawn/api/models/key.rb', line 36

def self.create(options={})
  options.fetch(:key)

  new post(
    path: '/account/keys',
    body: options.to_json
  )["key"]
end

.destroy(options = {}) ⇒ Void

Returns:

  • (Void)


72
73
74
75
76
77
78
79
# File 'lib/dawn/api/models/key.rb', line 72

def self.destroy(options={})
  id = id_param(options)

  delete(
    path: "/account/keys/#{id}",
    query: options
  )
end

.find(options = {}) ⇒ Dawn::Key

Parameters:

  • options (Hash) (defaults to: {})

Returns:



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

def self.find(options={})
  id = id_param(options)

  new get(
    path: "/account/keys/#{id}",
    query: options
  )["key"]
end

Instance Method Details

#destroy(options = {}) ⇒ Void

Returns:

  • (Void)


28
29
30
# File 'lib/dawn/api/models/key.rb', line 28

def destroy(options={})
  self.class.destroy(options.merge(id: id))
end