Skip to content

Commit 4711066

Browse files
Allow specifying of ynab_account_id when calling webhooks
Closes #101
1 parent e751242 commit 4711066

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

app/controllers/monzo_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def receive
3434
description << " (Repayment to #{webhook[:data][:counterparty][:name]})"
3535
end
3636

37+
# @todo remove the final fall back at some point. It will be a breaking change.
38+
ynab_account_id = params[:ynab_account_id] || ENV['YNAB_MONZO_ACCOUNT_ID'] || ENV['YNAB_ACCOUNT_ID']
39+
3740
ynab_creator = YNAB::TransactionCreator.new(
3841
id: "M#{webhook[:data][:id]}",
3942
date: Time.parse(webhook[:data][:created]).to_date,
@@ -42,7 +45,7 @@ def receive
4245
description: description.strip,
4346
cleared: !foreign_transaction,
4447
flag: flag,
45-
account_id: ENV['YNAB_MONZO_ACCOUNT_ID'] || ENV['YNAB_ACCOUNT_ID'] # @todo remove the fall back at some point. It will be a breaking change
48+
account_id: ynab_account_id
4649
)
4750

4851
create = ynab_creator.create

app/controllers/starling_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def receive
4848
description: description.strip,
4949
cleared: !foreign_transaction,
5050
flag: flag,
51-
account_id: ENV['YNAB_STARLING_ACCOUNT_ID']
51+
account_id: params[:ynab_account_id] || ENV['YNAB_STARLING_ACCOUNT_ID']
5252
)
5353

5454
create = ynab_creator.create

0 commit comments

Comments
 (0)