import "github.com/knusbaum/bento-go"
Package bento provides an interface to the bentoforbusiness.com API. Please see https://apidocs.bentoforbusiness.com/ for detailed info on how the API works.
In order to begin interacting with Bento, you need to obtain a *Session This can be done via the following functions: For production:
session, err := bento.GetProductionSession("myAccessKey", "mySecretKey")
For the sandbox:
session, err := bento.GetTestSession("myTestAccessKey", "myTestSecretKey")
Once you have a session, you can begin doing things like getting and updating cards and other resources associated with your bento account.
See the Session object's methods to see the types of objects you can interact with. This is a good starting point from which you can begin to understand the other types provided in this package.
const (
PERIOD_DAY = "Day"
PERIOD_WEEK = "Week"
PERIOD_MONTH = "Month"
PERIOD_CUSTOM = "Custom"
)
Valid periods for SpendingLimit
const (
STATUS_CANCELED = "CANCELED"
STATUS_FRAUD_PREVENTION = "FRAUD_PREVENTION"
STATUS_TURNED_ON = "TURNED_ON"
STATUS_TURNED_OFF = "TURNED_OFF"
STATUS_WEEKLY_RESTRICTION = "WEEKLY_RESTRICTION"
)
Valid Card Statuses
type Address struct {
Active bool `json:"active"`
AddressType AddressType `json:"addressType,omitempty"`
City string `json:"city,omitempty"`
Id int64 `json:"id,omitempty"`
State string `json:"state,omitempty"`
Street string `json:"street,omitempty"`
ZipCode string `json:"zipCode,omitempty"`
}
type AddressType string
AddressType can be "BUSINESS_ADDRESS" or "USER_ADDRESS"
const (
BUSINESS_ADDRESS AddressType = "BUSINESS_ADDRESS"
USER_ADDRESS AddressType = "USER_ADDRESS"
)
Valid values for AddressType
type ApiApplication struct {
ApiApplicationId int64 `json:"apiApplicationId,omitempty"`
Name string `json:"name,omitempty"`
AccessKey string `json:"accessKey,omitempty"`
Business Business `json:"business,omitempty"`
}
type BentoError struct {
Message string
BentoError string `json:"error"`
}
func (e BentoError) Error() string
type Business struct {
BusinessId int64 `json:"businessId,omitempty"`
CompanyName string `json:"companyName,omitempty"`
NameOnCard string `json:"nameOnCard,omitempty"`
Phone string `json:"phone,omitempty"`
AccountNumber string `json:"accountNumber,omitempty"`
BusinessStructure string `json:"businessStructure,omitempty"`
Status string `json:"status,omitempty"`
CreatedDate int64 `json:"createdDate,omitempty"`
ApprovalDate int64 `json:"approvalDate,omitempty"`
ApprovalStatus string `json:"approvalStatus,omitempty"`
Balance float64 `json:"balance,omitempty"`
TimeZone string `json:"timeZone,omitempty"`
Addresses []Address `json:"addresses,omitempty"`
}
type Card struct {
CardId int64 `json:"cardId,omitempty"`
Type CardType `json:"type,omitempty"`
LifecycleStatus string `json:"lifecycleStatus,omitempty"`
Status string `json:"status,omitempty"`
Expiration string `json:"expiration,omitempty"`
LastFour string `json:"lastFour,omitempty"`
VirtualCard bool `json:"virtualCard"`
Alias string `json:"alias,omitempty"`
AvailableAmount float64 `json:"availableAmount,omitempty"`
AllowedDaysActive bool `json:"allowedDaysActive"`
AllowedDays []string `json:"allowedDays,omitempty"`
AllowedCategoriesActive bool `json:"allowedCategoriesActive"`
AllowedCategories []Category `json:"allowedCategories,omitempty"`
TransactionCategoryId int64 `json:"transactionCategoryId,omitempty"`
CreatedOn int64 `json:"createdOn,omitempty"`
UpdatedOn int64 `json:"updatedOn,omitempty"`
SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"`
User User `json:"user,omitempty"`
Permissions map[string]bool `json:"permissions,omitempty"`
BentoType string `json:"bentoType,omitempty"`
}
func (card *Card) Activate(lastFour string) (*Card, error)
func (card *Card) Delete() (*Card, error)
func (card *Card) GetBillingAddress() (*Address, error)
func (card *Card) GetPanAndCvv() (*PanAndCvv, error)
func (card *Card) Put() (*Card, error)
func (card *Card) Reissue() (*Card, error)
func (card *Card) SetBillingAddress(newAddress *Address) (*Address, error)
func (card *Card) TurnOff() (*Card, error)
func (card *Card) TurnOn() (*Card, error)
func (card *Card) UpdateBillingAddress(newAddress *Address) (*Address, error)
type CardType string
const (
BUSINESS_OWNER_CARD CardType = "BusinessOwnerCard"
EMPLOYEE_CARD CardType = "EmployeeCard"
CATEGORY_CARD CardType = "CategoryCard"
)
Valid Card Types
type Category struct {
TransactionCategoryId int64 `json:"transactionCategoryId,omitempty"`
Description string `json:"description,omitempty"`
Group string `json:"group,omitempty"`
Mccs []int64 `json:"mccs,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
BentoType string `json:"bentoType,omitempty"`
}
type PanAndCvv struct {
Pan string `json:"pan,omitempty"`
Cvv string `json:"cvv,omitempty"`
}
type Payee struct {
Name string `json:"name,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country string `json:"country,omitempty"`
Zip string `json:"zip,omitempty"`
}
type Period string
Period for a SpendingLimit
type Session struct {
}
Session provides the entry point to interact with the API. Created with GetProductionSession and GetTestSession.
func GetProductionSession(accessKey, secretKey string) (*Session, error)
func GetTestSession(accessKey, secretKey string) (*Session, error)
func (session *Session) ClearLogger()
ClearLogger clears any logger set by SetLogger from session. After this call completes, nothing will be logged by the session.
func (session *Session) GetBusiness() (*Business, error)
func (session *Session) GetCard(cardId int64) (*Card, error)
func (session *Session) GetCards() ([]Card, error)
func (session *Session) GetTransactions() (*Transactions, error)
func (session *Session) NewCard(cardType CardType, alias string) (*Card, error)
func (session *Session) SetLogger(logger *log.Logger)
SetLogger sets a *log.Logger on the session. All requests and responses will be logged to that logger.
type SpendingLimit struct {
Active bool `json:"active"`
Amount float64 `json:"amount,omitempty"`
Period Period `json:"period,omitempty"`
CustomStartDate int64 `json:"customStartDate,omitempty"`
CustomEndDate int64 `json:"customEndDate,omitempty"`
}
type Transaction struct {
CardTransactionId int64 `json:"cardTransactionId,omitempty"`
Amount float64 `json:"amount,omitempty"`
ApprovalCode string `json:"approvalCode,omitempty"`
AvailableBalance float64 `json:"availableBalance,omitempty"`
Card *Card `json:"card,omitempty"`
Category *Category `json:"category,omitempty"`
Currency string `json:"currency,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Fees float64 `json:"fees,omitempty"`
LedgerBalance float64 `json:"ledgerBalance,omitempty"`
Note string `json:"node,omitempty"`
SettlementDate int64 `json:"settlementDate,omitempty"`
Status string `json:"status,omitempty"`
Tags []string `json:"tags,omitempty"`
TransactionDate int64 `json:"transactionDate,omitempty"`
Type string `json:"type,omitempty"`
Payee *Payee `json:"payee,omitempty"`
}
type Transactions struct {
Amount float64 `json:"amount,omitempty"`
Size int `json:"size",omitempty"`
CardTransactions []Transaction `json:"cardTransactions"`
}
Transactions
type User struct {
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
BirthDate int64 `json:"birthDate,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
UserId int64 `json:"userId,omitempty"`
MobileAccess bool `json:"mobileAccess"`
Deleted bool `json:"deleted"`
Created int64 `json:"created"`
BentoType string `json:"bentoType,omitempty"`
}