Class: Quovo::Api::Accounts

Inherits:
Base
  • Object
show all
Defined in:
lib/quovo/api/accounts.rb

Instance Attribute Summary

Attributes inherited from Base

#token

Instance Method Summary collapse

Methods inherited from Base

#api, #initialize

Methods included from Request

#request

Constructor Details

This class inherits a constructor from Quovo::Api::Base

Instance Method Details

#allObject



8
9
10
11
12
# File 'lib/quovo/api/accounts.rb', line 8

def all
  api(:get, '/accounts')
    .fetch('accounts')
    .cast(Account)
end

#create(params) ⇒ Object



21
22
23
24
25
26
# File 'lib/quovo/api/accounts.rb', line 21

def create(params)
  params.require!(:user, :brokerage, :username, :password)
  api(:post, '/accounts', params)
    .fetch('account')
    .cast(Account)
end

#delete(id) ⇒ Object



38
39
40
41
# File 'lib/quovo/api/accounts.rb', line 38

def delete(id)
  id.require!(as: :id)
  api(:delete, "/accounts/#{id}")
end

#find(id) ⇒ Object



14
15
16
17
18
19
# File 'lib/quovo/api/accounts.rb', line 14

def find(id)
  id.require!(as: :id)
  api(:get, "/accounts/#{id}")
    .fetch('account')
    .cast(Account)
end

#for_user(id) ⇒ Object



43
44
45
46
47
48
# File 'lib/quovo/api/accounts.rb', line 43

def for_user(id)
  id.require!(as: :id)
  api(:get, "/users/#{id}/accounts")
    .fetch('accounts')
    .cast(Account)
end

#sync(id) ⇒ Object



57
58
59
60
61
62
# File 'lib/quovo/api/accounts.rb', line 57

def sync(id)
  id.require!(as: :id)
  api(:get, "/accounts/#{id}/sync")
    .fetch('sync')
    .cast(Sync)
end

#sync!(id) ⇒ Object



50
51
52
53
54
55
# File 'lib/quovo/api/accounts.rb', line 50

def sync!(id)
  id.require!(as: :id)
  api(:post, "/accounts/#{id}/sync")
    .fetch('sync')
    .cast(Sync)
end

#update(id, params) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/quovo/api/accounts.rb', line 28

def update(id, params)
  id.require!(as: :id)
  params
    .permit!(:brokerage, :username, :password)
  params.require!(:username, :password) if params[:username] || params[:password]
  api(:put, "/accounts/#{id}", params)
    .fetch('account')
    .cast(Account)
end