Class: Dawn::Account

Inherits:
Object
  • Object
show all
Includes:
BaseApi
Defined in:
lib/dawn/api/models/account.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) ⇒ Account

Returns a new instance of Account.

Parameters:

  • data (Hash)


23
24
25
# File 'lib/dawn/api/models/account.rb', line 23

def initialize(data)
  @data = data
end

Class Method Details

.current(options = {}) ⇒ Dawn::Account

Parameters:

  • data (Hash)

Returns:



65
66
67
68
69
70
# File 'lib/dawn/api/models/account.rb', line 65

def self.current(options={})
  new get(
    path: "/account",
    query: options
  )["user"]
end

Instance Method Details

#refresh(options = {}) ⇒ self

Parameters:

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

Returns:

  • (self)


31
32
33
34
35
36
37
# File 'lib/dawn/api/models/account.rb', line 31

def refresh(options={})
  @data = get(
    path: "/account",
    query: options
  )["user"]
  self
end

#saveself

Using the currently stored @data, #update self

Returns:

  • (self)


57
58
59
# File 'lib/dawn/api/models/account.rb', line 57

def save
  update(account: @data)
end

#update(options = {}) ⇒ self

Parameters:

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

Returns:

  • (self)


43
44
45
46
47
48
49
50
51
# File 'lib/dawn/api/models/account.rb', line 43

def update(options={})
  options.fetch(:account)

  @data = patch(
    path: "/account",
    body: options.to_json
  )["user"]
  self
end