Skip to content

Commit

Permalink
Allow specifying of ynab_account_id when calling webhooks
Browse files Browse the repository at this point in the history
Closes #101
  • Loading branch information
scottrobertson committed Aug 19, 2018
1 parent e751242 commit 4711066
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/controllers/monzo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def receive
description << " (Repayment to #{webhook[:data][:counterparty][:name]})"
end

# @todo remove the final fall back at some point. It will be a breaking change.
ynab_account_id = params[:ynab_account_id] || ENV['YNAB_MONZO_ACCOUNT_ID'] || ENV['YNAB_ACCOUNT_ID']

ynab_creator = YNAB::TransactionCreator.new(
id: "M#{webhook[:data][:id]}",
date: Time.parse(webhook[:data][:created]).to_date,
Expand All @@ -42,7 +45,7 @@ def receive
description: description.strip,
cleared: !foreign_transaction,
flag: flag,
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
account_id: ynab_account_id
)

create = ynab_creator.create
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/starling_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def receive
description: description.strip,
cleared: !foreign_transaction,
flag: flag,
account_id: ENV['YNAB_STARLING_ACCOUNT_ID']
account_id: params[:ynab_account_id] || ENV['YNAB_STARLING_ACCOUNT_ID']
)

create = ynab_creator.create
Expand Down

0 comments on commit 4711066

Please sign in to comment.