-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add premium endpoint implementations (#8)
* feature: update balance and transaction structs * code refactor * Update pull_request_template.md * refactor code * feat: add premium account transactions endpoint * Update README.md * format and lint issues fix * Update Taskfile.yml
- Loading branch information
1 parent
92033a8
commit c81b58f
Showing
51 changed files
with
1,294 additions
and
1,456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package nordigen | ||
|
||
import "time" | ||
|
||
type Account struct { | ||
ID string `json:"id"` | ||
Created string `json:"created"` | ||
LastAccessed string `json:"last_accessed"` | ||
IBAN string `json:"iban"` | ||
InstitutionID string `json:"institution_id"` | ||
Status string `json:"status"` | ||
OwnerName string `json:"owner_name"` | ||
} | ||
|
||
type Balance struct { | ||
BalanceAmount Amount `json:"balanceAmount"` | ||
BalanceType string `json:"balanceType"` | ||
ReferenceDate string `json:"referenceDate"` | ||
CreditLimitIncluded bool `json:"creditLimitIncluded"` | ||
LastChangeDateTime time.Time `json:"lastChangeDateTime"` | ||
LastCommittedTransaction string `json:"lastCommittedTransaction"` | ||
} | ||
|
||
type Amount struct { | ||
Amount string `json:"amount"` | ||
Currency string `json:"currency"` | ||
} | ||
|
||
type Balances struct { | ||
Balances []Balance `json:"balances"` | ||
} | ||
|
||
// AccountDetails is a struct that contains the details of an account | ||
// Some fields might be empty, depending on the account type | ||
type AccountDetails struct { | ||
BBAN string `json:"bban"` | ||
BIC string `json:"bic"` | ||
Details string `json:"details"` | ||
DisplayName string `json:"displayName"` | ||
LinkedAccounts string `json:"linkedAccounts"` | ||
MisISDN string `json:"misIsdn"` | ||
OwnerAddressUnstructured string `json:"ownerAddressUnstructured"` | ||
Status string `json:"status"` | ||
Usage string `json:"usage"` | ||
ResourceID string `json:"resourceId"` | ||
IBAN string `json:"iban"` | ||
Currency string `json:"currency"` | ||
OwnerName string `json:"ownerName"` | ||
Name string `json:"name"` | ||
Product string `json:"product"` | ||
CashAccountType string `json:"cashAccountType"` | ||
} | ||
|
||
type Details struct { | ||
Account AccountDetails `json:"account"` | ||
} | ||
|
||
type TransactionParams struct { | ||
DateFrom string `url:"date_from,omitempty" json:"date_from,omitempty"` | ||
DateTo string `url:"date_to,omitempty" json:"date_to,omitempty"` | ||
} | ||
|
||
type Transaction struct { | ||
TransactionID string `json:"transactionId"` | ||
BookingDate string `json:"bookingDate"` | ||
ValueDate string `json:"valueDate"` | ||
BookingDateTime time.Time `json:"bookingDateTime"` | ||
ValueDateTime time.Time `json:"valueDateTime"` | ||
TransactionAmount Amount `json:"transactionAmount"` | ||
CreditorName string `json:"creditorName"` | ||
CreditorAccount Account `json:"creditorAccount"` | ||
DebtorName string `json:"debtorName"` | ||
DebtorAccount Account `json:"debtorAccount"` | ||
BankTransactionCode string `json:"bankTransactionCode"` | ||
RemittanceInformationUnstructured string `json:"remittanceInformationUnstructured"` | ||
RemittanceInformationUnstructuredArray []string `json:"remittanceInformationUnstructuredArray"` | ||
ProprietaryBankTransactionCode string `json:"proprietaryBankTransactionCode"` | ||
InternalTransactionID string `json:"internalTransactionId"` | ||
|
||
AdditionalInformation string `json:"additionalInformation"` | ||
AdditionalInformationStructured string `json:"additionalInformationStructured"` | ||
BalanceAfterTransaction Balance `json:"balanceAfterTransaction"` | ||
CheckID string `json:"checkId"` | ||
CreditorID string `json:"creditorId"` | ||
// CurrencyExchange []string `json:"currencyExchange"` | ||
DebtorAgent string `json:"debtorAgent"` | ||
EndToEndID string `json:"endToEndId"` | ||
EntryReference string `json:"entryReference"` | ||
MandateID string `json:"mandateId"` | ||
MerchantCategoryCode string `json:"merchantCategoryCode"` | ||
RemittanceInformationStructured string `json:"remittanceInformationStructured"` | ||
RemittanceInformationStructuredArray []string `json:"remittanceInformationStructuredArray"` | ||
UltimateCollector string `json:"ultimateCreditor"` | ||
UltimateDebtor string `json:"ultimateDebtor"` | ||
} | ||
|
||
type Transactions struct { | ||
Transactions TransactionList `json:"transactions"` | ||
} | ||
|
||
type TransactionList struct { | ||
Booked []Transaction `json:"booked"` | ||
Pending []Transaction `json:"pending"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package nordigen | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// GetAccount retrieves an account by ID | ||
func (c Client) GetAccount(ctx context.Context, token string, accountID string) (*Account, error) { | ||
var account Account | ||
endpointURL := AccountsPath + accountID | ||
err := c.HTTP.Get(ctx, endpointURL, RequestHeadersWithAuth(token), &account) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &account, nil | ||
} | ||
|
||
// GetAccountBalances retrieves balances for an account by ID | ||
func (c Client) GetAccountBalances(ctx context.Context, token string, accountID string) (*Balances, error) { | ||
var balances Balances | ||
endpointURL := AccountsPath + accountID + "/balances" | ||
err := c.HTTP.Get(ctx, endpointURL, RequestHeadersWithAuth(token), &balances) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &balances, nil | ||
} | ||
|
||
// GetAccountDetails retrieves details for an account by ID | ||
func (c Client) GetAccountDetails(ctx context.Context, token string, accountID string) (*Details, error) { | ||
var details Details | ||
endpointURL := AccountsPath + accountID + "/details" | ||
err := c.HTTP.Get(ctx, endpointURL, RequestHeadersWithAuth(token), &details) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &details, nil | ||
} | ||
|
||
// GetAccountTransactions retrieves transactions for an account by ID | ||
func (c Client) GetAccountTransactions(ctx context.Context, token string, accountID string) (*Transactions, error) { | ||
var transactions Transactions | ||
endpointURL := AccountsPath + accountID + "/transactions" | ||
err := c.HTTP.Get(ctx, endpointURL, RequestHeadersWithAuth(token), &transactions) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &transactions, nil | ||
} |
Oops, something went wrong.