mirror of
				https://github.com/aclindsa/ofxgo.git
				synced 2025-11-04 02:03:26 -05:00 
			
		
		
		
	Generalize response parsing code
This removes the many decodeXXXMessageSet() functions and replaces them with a large map and a single generic decodeMessageSet() function. Also change Responses to satisfy the Message interface as pointer types (instead of the raw types), add the full set of top-level message sets (though most of them still lack any message-parsing ability), adjust the message set names to more closely mirror their OFX names, and fixup tests and the command-line client to match the above changes.
This commit is contained in:
		@@ -44,7 +44,7 @@ func invTransactions() {
 | 
			
		||||
		Include401K:    true,
 | 
			
		||||
		Include401KBal: true,
 | 
			
		||||
	}
 | 
			
		||||
	query.Investments = append(query.Investments, &statementRequest)
 | 
			
		||||
	query.InvStmt = append(query.InvStmt, &statementRequest)
 | 
			
		||||
 | 
			
		||||
	response, err := client.Request(query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -59,12 +59,12 @@ func invTransactions() {
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(response.Investments) < 1 {
 | 
			
		||||
	if len(response.InvStmt) < 1 {
 | 
			
		||||
		fmt.Println("No investment messages received")
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if stmt, ok := response.Investments[0].(ofxgo.InvStatementResponse); ok {
 | 
			
		||||
	if stmt, ok := response.InvStmt[0].(*ofxgo.InvStatementResponse); ok {
 | 
			
		||||
		availCash := big.Rat(stmt.InvBal.AvailCash)
 | 
			
		||||
		if availCash.IsInt() && availCash.Num().Int64() != 0 {
 | 
			
		||||
			fmt.Printf("Balance: %s %s (as of %s)\n", stmt.InvBal.AvailCash, stmt.CurDef, stmt.DtAsOf)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user