This is a simple CLI tool that will gererate all the struct types for the GetConnectors and the UpdateConnectors that you have added to your AppConnector in AFAS Profit. It uses the Meta Data API to build the struct type.
. Features . Install . Sample commands . Sample struct .
- Create structs from GetConnectors and UpdateConnectors
- Run manually.
- Save apps (AppConnectors) to a config file inside os.UserConfigDir() for easy updating the stuct types.
- Saves tokens AES encrypted to the config file.
- Comments about length, mandatory, decimal points etc...
- Import statement time.Time for date fields.
- Formatting the .go file.
- No third party modules are used.
# Creates a randome(1) 32 bit string that is used as CipherKey in the EAS encryption. This encryptes the AFAS token.
$ rand=$(openssl rand -hex 16)
# [optional] Overrule the default config location os.UserConfigDir() (2)
$ configpath="/Users/Remco/.config/"
# building the cli
$ go install github.com/RemcoE33/go-afas-appconnector-cli \
-o "go-afas" \
-ldflags="-X 'lib.CipherKey=$rand'" \
-ldflags="-X 'main.ConfigPath=$configpath'"
# clear the shell variables
$ unset rand
$ unset configpath
Adding a new AppConnector to the config file.
# long flags:
$ go-afas add \
-test \
-member "11111" \
-token "<token><version>1</version><data>xxx</data></token>" \
# optional, otherwise the current directory is set as output location
-location "/Users/Remco/Downloads/test"
# shorthanded flags:
$ go-afas add \
# environment test
-et \
-m "11111" \
-t "<token><version>1</version><data>xxx</data></token>" \
# optional, otherwise the current directory is set as output location
-l "/Users/Remco/Downloads/test"
List added AppConnectors from the config file
$ go-afas list
# | Member | Environment type | Description | Location
1 | 11111 | production | MyAppConnector | /Users/Remco/repos/MyGoApp
Run # from the list above
# long flags:
$ go-afas run -number 1
# shorthanded flags:
$ go-afas run -n 1
Run the generation without saving to the config file first:
Same as add
but use man
# long flags:
$ go-afas del -number 1
# shorthanded flags:
$ go-afas del -n 1
package appconnector
// This code is generated with go-afas-appconnector
// DO NOT EDIT BY HAND
// Description: Verlofsaldo
// Endpoint: HrAbsBalance
type RootHrAbsBalance struct {
HrAbsBalance struct {
Element struct {
Fields struct {
Medewerker string `json:"EmId"` // Length: 15 Not-zero: true Mandatory: true
Werkgever string `json:"ErId"` // Length: 15 Not-zero: true Mandatory: true
Dienstverband int `json:"EnSe"` // Length: 9 Not-zero: false Mandatory: true
TypeVerlof string `json:"ViAt"` // Length: 10 Not-zero: true Mandatory: true
Verlofperiodetabel int `json:"PtId"` // Length: 5 Not-zero: true Mandatory: true
Boekjaar int `json:"Year"` // Length: 4 Not-zero: true Mandatory: true
Verlofperiode int `json:"SeNo"` // Length: 3 Not-zero: true Mandatory: true
ActueelSaldo float64 `json:"AcSa"` // Length: 8 Not-zero: false Mandatory: false Decimals: 2
ActueelSaldoUrenMinuten float64 `json:"AcSh"` // Length: 8 Not-zero: false Mandatory: false Decimals: 2
} `json:"Fields"`
} `json:"Element"`
} `json:"HrAbsBalance"`
}