Skip to content
Snippets Groups Projects
Select Git revision
  • 890bd51a506fdb468e5569daea8b6a24009e86d3
  • main default protected
  • v1.303.0
  • v1.302.0
  • v1.301.0
  • v1.300.0
  • v1.299.0
  • v1.298.0
  • v1.297.0
  • v1.296.0
  • v1.295.0
  • v1.294.0
  • v1.293.0
  • v1.292.0
  • v1.291.0
  • v1.290.0
  • v1.289.0
  • v1.288.0
  • v1.287.0
  • v1.286.0
  • v1.285.0
  • v1.284.0
22 results

absa_bank_transactions.go

Blame
  • absa_bank_transactions.go 7.15 KiB
    package bank_transactions
    
    import (
    	"crypto/tls"
    	"encoding/base64"
    	"github.com/go-resty/resty/v2"
    	"github.com/google/uuid"
    	"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/errors"
    	"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/secrets_manager"
    	"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/string_utils"
    	"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/struct_utils"
    	"io"
    	"strings"
    	"time"
    )
    
    type AbsaLoginInfo struct {
    	CertExpiry        string
    	CertSerialNumber  string
    	PartialNo         string
    	DeviceFingerprint string
    	AbsaSecretName    string
    	IsDebug           bool
    }
    
    var ErrPasswordChange = errors.Error("Absa CIB requires a password change")
    
    const (
    	sleepTime = time.Second * 2
    )
    
    func GetAbsaTransactions(loginInfo AbsaLoginInfo) ([]byte, error) {
    
    	client, err := setupAbsaClient(loginInfo.AbsaSecretName, loginInfo.IsDebug)
    	if err != nil {
    		return nil, err
    	}
    
    	defer logoff(client)
    
    	// Get Initial session ID
    	err = login(client, loginInfo)
    	if err != nil {
    		return nil, err
    	}
    
    	// Navigate to statement download
    	err = startStatementDownloadProcess(client)
    	if err != nil {
    		return nil, err
    	}
    
    	// Request statement
    	dateString := time.Now().Format("20060102")
    	_, err = statementDownloadProcessCall(client, map[string]string{
    		"page":                "enquiry-statement",
    		"groupselect":         "",
    		"linkallterm":         "false",
    		"buttonClicked":       "proceed",
    		"SelType":             "D",
    		"FAInd":               "false",
    		"systemDate":          dateString,
    		"account_options":     "all",
    		"fromaccountgroup":    "blank",
    		"fromaccount":         "blank",
    		"fromaccountdisplay1": "blank",
    		"showall_option":      "showall",
    		"format_options":      "file",
    		"file_format_options": "csv",
    		"statement_options":   "last",