Begin work on YNAB client
After reading these docs https://api.youneedabudget.com/v1#/Transactions/createTransaction I successfully made a request to post a transaction to my YNAB account. Hastily created a client.go that doesn't contain much at the moment.
This commit is contained in:
		
							parent
							
								
									2e719d1174
								
							
						
					
					
						commit
						e223adfec5
					
				
					 4 changed files with 71 additions and 2 deletions
				
			
		|  | @ -13,10 +13,31 @@ import ( | |||
| 	"fmt" | ||||
| ) | ||||
| 
 | ||||
| var ( | ||||
| 	ynabAccountID = os.Getenv("ynab_account_id") | ||||
| ) | ||||
| 
 | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Business Logic | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| 
 | ||||
| func main() { | ||||
| 	fmt.Println("To be implemented...") | ||||
| // Convert a Monzo transaction struct, `tx`, into a YNAB transaction struct. | ||||
| func toYnab(tx monzoSerde.Transaction) ynabSerde.Transaction { | ||||
| 	return ynabSerde.Transaction{ | ||||
| 		Id: tx.Id, | ||||
| 		Date: tx.Created, | ||||
| 		Amount: tx.Amount, | ||||
| 		Memo: tx.Notes, | ||||
| 		AccountId: ynabAccountID, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| 	txs := monzo.TransactionsLast24Hours() | ||||
| 	var ynabTxs []ynabSerde.Transaction{} | ||||
| 	for tx := range txs { | ||||
| 		append(ynabTxs, toYnab(tx)) | ||||
| 	} | ||||
| 	ynab.PostTransactions(ynabTxs) | ||||
| 	os.Exit(0) | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue