Class: Coyodlee::Facades::TransactionsFacade

Inherits:
Object
  • Object
show all
Defined in:
lib/coyodlee/facades/transactions_facade.rb

Instance Method Summary collapse

Constructor Details

#initialize(request_facade) ⇒ TransactionsFacade

Returns a new instance of TransactionsFacade.



4
5
6
# File 'lib/coyodlee/facades/transactions_facade.rb', line 4

def initialize(request_facade)
  @request_facade = request_facade
end

Instance Method Details

#all(params = {}) ⇒ Object



14
15
16
17
18
# File 'lib/coyodlee/facades/transactions_facade.rb', line 14

def all(params={})
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:get, 'transactions', params: params, headers: headers)
  @request_facade.execute(req)
end

#categorization_rulesObject



20
21
22
23
24
# File 'lib/coyodlee/facades/transactions_facade.rb', line 20

def categorization_rules
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:get, 'transactions/categories/rules', headers: headers)
  @request_facade.execute(req)
end

#count(params = {}) ⇒ Object



8
9
10
11
12
# File 'lib/coyodlee/facades/transactions_facade.rb', line 8

def count(params={})
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:get, 'transactions/count', params: params, headers: headers)
  @request_facade.execute(req)
end

#create_categorization_rule(body:) ⇒ Object



26
27
28
29
30
# File 'lib/coyodlee/facades/transactions_facade.rb', line 26

def create_categorization_rule(body:)
  headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
  req = @request_facade.build(:post, 'transactions/categories/rules', headers: headers, body: body.to_json)
  @request_facade.execute(req)
end

#create_category(category_name:, parent_category_id:) ⇒ Object



69
70
71
72
73
74
# File 'lib/coyodlee/facades/transactions_facade.rb', line 69

def create_category(category_name:, parent_category_id:)
  headers = { 'Accept' => 'application/json' }
  params = { 'categoryParam' => { 'categoryName' => category_name, 'parentCategoryId' => parent_category_id }.to_json }
  req = @request_facade.build(:post, 'transactions/categories', headers: headers, params: params)
  @request_facade.execute(req)
end

#delete_categorization_rule(rule_id:) ⇒ Object



38
39
40
41
42
# File 'lib/coyodlee/facades/transactions_facade.rb', line 38

def delete_categorization_rule(rule_id:)
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:put, "transactions/categories/rules/#{rule_id}", headers: headers)
  @request_facade.execute(req)
end

#delete_category(category_id:) ⇒ Object



82
83
84
85
86
# File 'lib/coyodlee/facades/transactions_facade.rb', line 82

def delete_category(category_id:)
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:delete, "transactions/categories/#{category_id}", headers: headers)
  @request_facade.execute(req)
end

#list_categoriesObject



63
64
65
66
67
# File 'lib/coyodlee/facades/transactions_facade.rb', line 63

def list_categories
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:get, 'transactions/categories', headers: headers)
  @request_facade.execute(req)
end

#run_all_categorization_rulesObject



50
51
52
53
54
55
# File 'lib/coyodlee/facades/transactions_facade.rb', line 50

def run_all_categorization_rules
  params = { 'action' => 'run' }
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:post, 'transactions/categories/rules', headers: headers, params: params)
  @request_facade.execute(req)
end

#run_categorization_rule(rule_id:) ⇒ Object



44
45
46
47
48
# File 'lib/coyodlee/facades/transactions_facade.rb', line 44

def run_categorization_rule(rule_id:)
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:post, "transactions/categories/rules/#{rule_id}", headers: headers)
  @request_facade.execute(req)
end

#update(transaction_id:, body: {}) ⇒ Object



57
58
59
60
61
# File 'lib/coyodlee/facades/transactions_facade.rb', line 57

def update(transaction_id:, body: {})
  headers = { 'Accept' => 'application/json' }
  req = @request_facade.build(:put, "transactions/#{transaction_id}", headers: headers, body: body)
  @request_facade.execute(req)
end

#update_categorization_rule(rule_id:, body:) ⇒ Object



32
33
34
35
36
# File 'lib/coyodlee/facades/transactions_facade.rb', line 32

def update_categorization_rule(rule_id:, body:)
  headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
  req = @request_facade.build(:put, "transactions/categories/rules/#{rule_id}", headers: headers, body: body.to_json)
  @request_facade.execute(req)
end

#update_category(body:) ⇒ Object



76
77
78
79
80
# File 'lib/coyodlee/facades/transactions_facade.rb', line 76

def update_category(body:)
  headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
  req = @request_facade.build(:put, 'transactions/categories', headers: headers, body: body.to_json)
  @request_facade.execute(req)
end