You've already forked openaccounting-server
mirror of
https://github.com/openaccounting/oa-server.git
synced 2025-12-09 09:00:42 +13:00
Merge pull request #4 from txgruppi/get-org-account
Added GET /orgs/:orgId/accounts/:accountI API endpoint
This commit is contained in:
93
.gitignore
vendored
93
.gitignore
vendored
@@ -1,3 +1,96 @@
|
|||||||
|
|
||||||
|
# Created by https://www.gitignore.io/api/vim,linux,macos,windows
|
||||||
|
# Edit at https://www.gitignore.io/?templates=vim,linux,macos,windows
|
||||||
|
|
||||||
|
### Linux ###
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
### Vim ###
|
||||||
|
# Swap
|
||||||
|
[._]*.s[a-v][a-z]
|
||||||
|
[._]*.sw[a-p]
|
||||||
|
[._]s[a-rt-v][a-z]
|
||||||
|
[._]ss[a-gi-z]
|
||||||
|
[._]sw[a-p]
|
||||||
|
|
||||||
|
# Session
|
||||||
|
Session.vim
|
||||||
|
|
||||||
|
# Temporary
|
||||||
|
.netrwhist
|
||||||
|
# Auto-generated tag files
|
||||||
|
tags
|
||||||
|
# Persistent undo
|
||||||
|
[._]*.un~
|
||||||
|
|
||||||
|
### Windows ###
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# End of https://www.gitignore.io/api/vim,linux,macos,windows
|
||||||
|
|
||||||
|
### Custom ###
|
||||||
config.json
|
config.json
|
||||||
*.crt
|
*.crt
|
||||||
*.key
|
*.key
|
||||||
|
|||||||
@@ -2,23 +2,24 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/ant0ine/go-json-rest/rest"
|
|
||||||
"github.com/openaccounting/oa-server/core/model"
|
|
||||||
"github.com/openaccounting/oa-server/core/model/types"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ant0ine/go-json-rest/rest"
|
||||||
|
"github.com/openaccounting/oa-server/core/model"
|
||||||
|
"github.com/openaccounting/oa-server/core/model/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /orgs/:orgId/accounts Get Accounts by Org id
|
* @api {get} /orgs/:orgId/accounts Get Accounts by Org id
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetOrgAccounts
|
* @apiName GetOrgAccounts
|
||||||
* @apiGroup Account
|
* @apiGroup Account
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the Account.
|
* @apiSuccess {String} id Id of the Account.
|
||||||
* @apiSuccess {String} orgId Id of the Org.
|
* @apiSuccess {String} orgId Id of the Org.
|
||||||
@@ -83,14 +84,85 @@ func GetOrgAccounts(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
w.WriteJson(&accounts)
|
w.WriteJson(&accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {get} /orgs/:orgId/accounts/:accountId Get Acount by Org id and Account id
|
||||||
|
* @apiVersion 1.2.0
|
||||||
|
* @apiName GetOrgAccount
|
||||||
|
* @apiGroup Account
|
||||||
|
*
|
||||||
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
|
*
|
||||||
|
* @apiSuccess {String} id Id of the Account.
|
||||||
|
* @apiSuccess {String} orgId Id of the Org.
|
||||||
|
* @apiSuccess {Date} inserted Date Account was created
|
||||||
|
* @apiSuccess {Date} updated Date Account was updated
|
||||||
|
* @apiSuccess {String} name Name of the Account.
|
||||||
|
* @apiSuccess {String} parent Id of the parent Account.
|
||||||
|
* @apiSuccess {String} currency Three letter currency code.
|
||||||
|
* @apiSuccess {Number} precision How many digits the currency goes out to.
|
||||||
|
* @apiSuccess {Boolean} debitBalance True if Account has a debit balance.
|
||||||
|
* @apiSuccess {Number} balance Current Account balance in this Account's currency
|
||||||
|
* @apiSuccess {Number} nativeBalance Current Account balance in the Org's currency
|
||||||
|
*
|
||||||
|
* @apiSuccessExample Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "id": "22222222222222222222222222222222",
|
||||||
|
* "orgId": "11111111111111111111111111111111",
|
||||||
|
* "inserted": "2018-09-11T18:05:04.420Z",
|
||||||
|
* "updated": "2018-09-11T18:05:04.420Z",
|
||||||
|
* "name": "Cash",
|
||||||
|
* "parent": "11111111111111111111111111111111",
|
||||||
|
* "currency": "USD",
|
||||||
|
* "precision": 2,
|
||||||
|
* "debitBalance": true,
|
||||||
|
* "balance": 10000,
|
||||||
|
* "nativeBalance": 10000
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiUse NotAuthorizedError
|
||||||
|
* @apiUse InternalServerError
|
||||||
|
*/
|
||||||
|
func GetOrgAccount(w rest.ResponseWriter, r *rest.Request) {
|
||||||
|
user := r.Env["USER"].(*types.User)
|
||||||
|
orgId := r.PathParam("orgId")
|
||||||
|
accountId := r.PathParam("accountId")
|
||||||
|
|
||||||
|
// TODO how do we make date an optional parameter
|
||||||
|
// instead of resorting to this hack?
|
||||||
|
date := time.Date(2100, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
|
dateParam := r.URL.Query().Get("date")
|
||||||
|
|
||||||
|
if dateParam != "" {
|
||||||
|
dateParamNumeric, err := strconv.ParseInt(dateParam, 10, 64)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
rest.Error(w, "invalid date", 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
date = time.Unix(0, dateParamNumeric*1000000)
|
||||||
|
}
|
||||||
|
|
||||||
|
accounts, err := model.Instance.GetAccountWithBalance(orgId, accountId, user.Id, "", date)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
rest.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteJson(&accounts)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /orgs/:orgId/accounts Create a new Account
|
* @api {post} /orgs/:orgId/accounts Create a new Account
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostAccount
|
* @apiName PostAccount
|
||||||
* @apiGroup Account
|
* @apiGroup Account
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} id Id 32 character hex string
|
* @apiParam {String} id Id 32 character hex string
|
||||||
* @apiParam {String} name Name of the Account.
|
* @apiParam {String} name Name of the Account.
|
||||||
@@ -198,12 +270,12 @@ func PostAccounts(w rest.ResponseWriter, r *rest.Request, content []byte) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {put} /orgs/:orgId/accounts/:accountId Modify an Account
|
* @api {put} /orgs/:orgId/accounts/:accountId Modify an Account
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PutAccount
|
* @apiName PutAccount
|
||||||
* @apiGroup Account
|
* @apiGroup Account
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} id Id 32 character hex string
|
* @apiParam {String} id Id 32 character hex string
|
||||||
* @apiParam {String} name Name of the Account.
|
* @apiParam {String} name Name of the Account.
|
||||||
@@ -273,12 +345,12 @@ func PutAccount(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {delete} /orgs/:orgId/accounts/:accountId Delete an Account
|
* @api {delete} /orgs/:orgId/accounts/:accountId Delete an Account
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName DeleteAccount
|
* @apiName DeleteAccount
|
||||||
* @apiGroup Account
|
* @apiGroup Account
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccessExample Success-Response:
|
* @apiSuccessExample Success-Response:
|
||||||
* HTTP/1.1 200 OK
|
* HTTP/1.1 200 OK
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import (
|
|||||||
/**
|
/**
|
||||||
* Changelog
|
* Changelog
|
||||||
*
|
*
|
||||||
|
* 1.2.0
|
||||||
|
* - add `GET /orgs/:orgId/accounts/:accountId
|
||||||
|
*
|
||||||
* 1.1.0
|
* 1.1.0
|
||||||
* - add `GET /health-check`
|
* - add `GET /health-check`
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /apikeys Get API keys
|
* @api {get} /apikeys Get API keys
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetApiKeys
|
* @apiName GetApiKeys
|
||||||
* @apiGroup ApiKey
|
* @apiGroup ApiKey
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the ApiKey.
|
* @apiSuccess {String} id Id of the ApiKey.
|
||||||
* @apiSuccess {Date} inserted Date ApiKey was created
|
* @apiSuccess {Date} inserted Date ApiKey was created
|
||||||
@@ -52,11 +52,11 @@ func GetApiKeys(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /apikeys Create a new API key
|
* @api {post} /apikeys Create a new API key
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostApiKey
|
* @apiName PostApiKey
|
||||||
* @apiGroup ApiKey
|
* @apiGroup ApiKey
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
*
|
*
|
||||||
* @apiParam {String} id 32 character hex string
|
* @apiParam {String} id 32 character hex string
|
||||||
@@ -105,11 +105,11 @@ func PostApiKey(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {put} /apikeys Modify an API key
|
* @api {put} /apikeys Modify an API key
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PutApiKey
|
* @apiName PutApiKey
|
||||||
* @apiGroup ApiKey
|
* @apiGroup ApiKey
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
*
|
*
|
||||||
* @apiParam {String} id 32 character hex string
|
* @apiParam {String} id 32 character hex string
|
||||||
@@ -160,12 +160,12 @@ func PutApiKey(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {delete} /apikeys/:apiKeyId Delete an API key
|
* @api {delete} /apikeys/:apiKeyId Delete an API key
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName DeleteApiKey
|
* @apiName DeleteApiKey
|
||||||
* @apiGroup ApiKey
|
* @apiGroup ApiKey
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccessExample Success-Response:
|
* @apiSuccessExample Success-Response:
|
||||||
* HTTP/1.1 200 OK
|
* HTTP/1.1 200 OK
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /org/:orgId Get Org by id
|
* @api {get} /org/:orgId Get Org by id
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetOrg
|
* @apiName GetOrg
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the Org.
|
* @apiSuccess {String} id Id of the Org.
|
||||||
* @apiSuccess {Date} inserted Date Org was created
|
* @apiSuccess {Date} inserted Date Org was created
|
||||||
@@ -53,12 +53,12 @@ func GetOrg(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /orgs Get a User's Orgs
|
* @api {get} /orgs Get a User's Orgs
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetOrgs
|
* @apiName GetOrgs
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the Org.
|
* @apiSuccess {String} id Id of the Org.
|
||||||
* @apiSuccess {Date} inserted Date Org was created
|
* @apiSuccess {Date} inserted Date Org was created
|
||||||
@@ -98,12 +98,12 @@ func GetOrgs(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /orgs Create a new Org
|
* @api {post} /orgs Create a new Org
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostOrg
|
* @apiName PostOrg
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} id Id 32 character hex string
|
* @apiParam {String} id Id 32 character hex string
|
||||||
* @apiParam {String} name Name of the Org.
|
* @apiParam {String} name Name of the Org.
|
||||||
@@ -152,12 +152,12 @@ func PostOrg(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {put} /orgs/:orgId Modify an Org
|
* @api {put} /orgs/:orgId Modify an Org
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PutOrg
|
* @apiName PutOrg
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} name Name of the Org.
|
* @apiParam {String} name Name of the Org.
|
||||||
*
|
*
|
||||||
@@ -207,12 +207,12 @@ func PutOrg(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /orgs/:orgId/invites Invite a user to an Org
|
* @api {post} /orgs/:orgId/invites Invite a user to an Org
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostInvite
|
* @apiName PostInvite
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} email Email address of user
|
* @apiParam {String} email Email address of user
|
||||||
*
|
*
|
||||||
@@ -263,12 +263,12 @@ func PostInvite(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {put} /orgs/:orgId/invites/:inviteId Accept an invitation
|
* @api {put} /orgs/:orgId/invites/:inviteId Accept an invitation
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PutInvite
|
* @apiName PutInvite
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} accepted true
|
* @apiParam {String} accepted true
|
||||||
*
|
*
|
||||||
@@ -320,12 +320,12 @@ func PutInvite(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /orgs/:orgId/invites Get Org invites
|
* @api {get} /orgs/:orgId/invites Get Org invites
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetInvites
|
* @apiName GetInvites
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the Invite
|
* @apiSuccess {String} id Id of the Invite
|
||||||
* @apiSuccess {orgId} id Id of the Org
|
* @apiSuccess {orgId} id Id of the Org
|
||||||
@@ -366,12 +366,12 @@ func GetInvites(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {delete} /orgs/:orgId/invites/:inviteId Delete Invite
|
* @api {delete} /orgs/:orgId/invites/:inviteId Delete Invite
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName DeleteInvite
|
* @apiName DeleteInvite
|
||||||
* @apiGroup Org
|
* @apiGroup Org
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccessExample Success-Response:
|
* @apiSuccessExample Success-Response:
|
||||||
* HTTP/1.1 200 OK
|
* HTTP/1.1 200 OK
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /org/:orgId/prices Get prices nearest in time or by currency
|
* @api {get} /org/:orgId/prices Get prices nearest in time or by currency
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetPrices
|
* @apiName GetPrices
|
||||||
* @apiGroup Price
|
* @apiGroup Price
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {Number} nearestDate Milliseconds since epoch
|
* @apiParam {Number} nearestDate Milliseconds since epoch
|
||||||
* @apiParam {String} currency Currency code
|
* @apiParam {String} currency Currency code
|
||||||
@@ -93,12 +93,12 @@ func GetPrices(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /orgs/:orgId/prices Create a new Price
|
* @api {post} /orgs/:orgId/prices Create a new Price
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostPrice
|
* @apiName PostPrice
|
||||||
* @apiGroup Price
|
* @apiGroup Price
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} id Id 32 character hex string.
|
* @apiParam {String} id Id 32 character hex string.
|
||||||
* @apiParam {String} orgId Id of the Org.
|
* @apiParam {String} orgId Id of the Org.
|
||||||
@@ -155,12 +155,12 @@ func PostPrice(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {delete} /orgs/:orgId/prices/:priceId Delete a Price
|
* @api {delete} /orgs/:orgId/prices/:priceId Delete a Price
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName DeletePrice
|
* @apiName DeletePrice
|
||||||
* @apiGroup Price
|
* @apiGroup Price
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccessExample Success-Response:
|
* @apiSuccessExample Success-Response:
|
||||||
* HTTP/1.1 200 OK
|
* HTTP/1.1 200 OK
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func GetRouter(auth *AuthMiddleware, prefix string) (rest.App, error) {
|
|||||||
rest.Delete(prefix+"/orgs/:orgId/ledgers/:accountId", auth.RequireAuth(DeleteAccount)),
|
rest.Delete(prefix+"/orgs/:orgId/ledgers/:accountId", auth.RequireAuth(DeleteAccount)),
|
||||||
rest.Get(prefix+"/orgs/:orgId/ledgers/:accountId/transactions", auth.RequireAuth(GetTransactionsByAccount)),
|
rest.Get(prefix+"/orgs/:orgId/ledgers/:accountId/transactions", auth.RequireAuth(GetTransactionsByAccount)),
|
||||||
rest.Get(prefix+"/orgs/:orgId/accounts", auth.RequireAuth(GetOrgAccounts)),
|
rest.Get(prefix+"/orgs/:orgId/accounts", auth.RequireAuth(GetOrgAccounts)),
|
||||||
|
rest.Get(prefix+"/orgs/:orgId/accounts/:accountId", auth.RequireAuth(GetOrgAccount)),
|
||||||
rest.Post(prefix+"/orgs/:orgId/accounts", auth.RequireAuth(PostAccount)),
|
rest.Post(prefix+"/orgs/:orgId/accounts", auth.RequireAuth(PostAccount)),
|
||||||
rest.Put(prefix+"/orgs/:orgId/accounts/:accountId", auth.RequireAuth(PutAccount)),
|
rest.Put(prefix+"/orgs/:orgId/accounts/:accountId", auth.RequireAuth(PutAccount)),
|
||||||
rest.Delete(prefix+"/orgs/:orgId/accounts/:accountId", auth.RequireAuth(DeleteAccount)),
|
rest.Delete(prefix+"/orgs/:orgId/accounts/:accountId", auth.RequireAuth(DeleteAccount)),
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /sessions Create a new Session
|
* @api {post} /sessions Create a new Session
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostSession
|
* @apiName PostSession
|
||||||
* @apiGroup Session
|
* @apiGroup Session
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
*
|
*
|
||||||
* @apiParam {String} id 32 character hex string
|
* @apiParam {String} id 32 character hex string
|
||||||
@@ -59,12 +59,12 @@ func PostSession(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {delete} /sessions/:sessionId Log out of a Session
|
* @api {delete} /sessions/:sessionId Log out of a Session
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName DeleteSession
|
* @apiName DeleteSession
|
||||||
* @apiGroup Session
|
* @apiGroup Session
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccessExample Success-Response:
|
* @apiSuccessExample Success-Response:
|
||||||
* HTTP/1.1 200 OK
|
* HTTP/1.1 200 OK
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /health-check Get system health status
|
* @api {get} /health-check Get system health status
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetSystemHealthStatus
|
* @apiName GetSystemHealthStatus
|
||||||
* @apiGroup SystemHealth
|
* @apiGroup SystemHealth
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Accept-Version: 1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version: 1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} database Database status: "ok"; "fail"
|
* @apiSuccess {String} database Database status: "ok"; "fail"
|
||||||
* @apiSuccess {String} api API status: "ok"
|
* @apiSuccess {String} api API status: "ok"
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /orgs/:orgId/accounts/:accountId/transactions Get Transactions by Account Id
|
* @api {get} /orgs/:orgId/accounts/:accountId/transactions Get Transactions by Account Id
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetAccountTransactions
|
* @apiName GetAccountTransactions
|
||||||
* @apiGroup Transaction
|
* @apiGroup Transaction
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the Transaction.
|
* @apiSuccess {String} id Id of the Transaction.
|
||||||
* @apiSuccess {String} orgId Id of the Org.
|
* @apiSuccess {String} orgId Id of the Org.
|
||||||
@@ -85,12 +85,12 @@ func GetTransactionsByAccount(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /orgs/:orgId/transactions Get Transactions by Org Id
|
* @api {get} /orgs/:orgId/transactions Get Transactions by Org Id
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetOrgTransactions
|
* @apiName GetOrgTransactions
|
||||||
* @apiGroup Transaction
|
* @apiGroup Transaction
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the Transaction.
|
* @apiSuccess {String} id Id of the Transaction.
|
||||||
* @apiSuccess {String} orgId Id of the Org.
|
* @apiSuccess {String} orgId Id of the Org.
|
||||||
@@ -160,12 +160,12 @@ func GetTransactionsByOrg(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /orgs/:orgId/transactions Create a new Transaction
|
* @api {post} /orgs/:orgId/transactions Create a new Transaction
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostTransaction
|
* @apiName PostTransaction
|
||||||
* @apiGroup Transaction
|
* @apiGroup Transaction
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} id Id 32 character hex string
|
* @apiParam {String} id Id 32 character hex string
|
||||||
* @apiParam {Date} date Date of the Transaction
|
* @apiParam {Date} date Date of the Transaction
|
||||||
@@ -246,12 +246,12 @@ func PostTransaction(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {put} /orgs/:orgId/transactions/:transactionId Modify a Transaction
|
* @api {put} /orgs/:orgId/transactions/:transactionId Modify a Transaction
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PutTransaction
|
* @apiName PutTransaction
|
||||||
* @apiGroup Transaction
|
* @apiGroup Transaction
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} id 32 character hex string
|
* @apiParam {String} id 32 character hex string
|
||||||
* @apiParam {Date} date Date of the Transaction
|
* @apiParam {Date} date Date of the Transaction
|
||||||
@@ -333,12 +333,12 @@ func PutTransaction(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {delete} /orgs/:orgId/transactions/:transactionId Delete a Transaction
|
* @api {delete} /orgs/:orgId/transactions/:transactionId Delete a Transaction
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName DeleteTransaction
|
* @apiName DeleteTransaction
|
||||||
* @apiGroup Transaction
|
* @apiGroup Transaction
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccessExample Success-Response:
|
* @apiSuccessExample Success-Response:
|
||||||
* HTTP/1.1 200 OK
|
* HTTP/1.1 200 OK
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ type ResetPasswordParams struct {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /user Get Authenticated User
|
* @api {get} /user Get Authenticated User
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName GetUser
|
* @apiName GetUser
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiSuccess {String} id Id of the User.
|
* @apiSuccess {String} id Id of the User.
|
||||||
* @apiSuccess {Date} inserted Date User was created
|
* @apiSuccess {Date} inserted Date User was created
|
||||||
@@ -64,11 +64,11 @@ func GetUser(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /users Create a new User
|
* @api {post} /users Create a new User
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PostUser
|
* @apiName PostUser
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} id 32 character hex string
|
* @apiParam {String} id 32 character hex string
|
||||||
* @apiParam {String} firstName First name of the User.
|
* @apiParam {String} firstName First name of the User.
|
||||||
@@ -123,12 +123,12 @@ func PostUser(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {put} /user Modify User
|
* @api {put} /user Modify User
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName PutUser
|
* @apiName PutUser
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Authorization HTTP Basic Auth
|
* @apiHeader {String} Authorization HTTP Basic Auth
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} password New password
|
* @apiParam {String} password New password
|
||||||
* @apiParam {String} code Password reset code. (Instead of Authorization header)
|
* @apiParam {String} code Password reset code. (Instead of Authorization header)
|
||||||
@@ -204,11 +204,11 @@ func PutUser(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /user/verify Verify user email address
|
* @api {post} /user/verify Verify user email address
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName VerifyUser
|
* @apiName VerifyUser
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} code Email verification code
|
* @apiParam {String} code Email verification code
|
||||||
*
|
*
|
||||||
@@ -238,11 +238,11 @@ func VerifyUser(w rest.ResponseWriter, r *rest.Request) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /user/reset-password Send reset password email
|
* @api {post} /user/reset-password Send reset password email
|
||||||
* @apiVersion 1.1.0
|
* @apiVersion 1.2.0
|
||||||
* @apiName ResetPassword
|
* @apiName ResetPassword
|
||||||
* @apiGroup User
|
* @apiGroup User
|
||||||
*
|
*
|
||||||
* @apiHeader {String} Accept-Version ^1.1.0 semver versioning
|
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning
|
||||||
*
|
*
|
||||||
* @apiParam {String} email Email address for user
|
* @apiParam {String} email Email address for user
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func (mw *VersionMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.Handl
|
|||||||
rest.Error(writer, "Invalid version", http.StatusBadRequest)
|
rest.Error(writer, "Invalid version", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverVersion, _ := semver.NewVersion("1.1.0")
|
serverVersion, _ := semver.NewVersion("1.2.0")
|
||||||
// Pre-release versions
|
// Pre-release versions
|
||||||
compatVersion, _ := semver.NewVersion("0.1.8")
|
compatVersion, _ := semver.NewVersion("0.1.8")
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,11 @@ package model
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openaccounting/oa-server/core/model/types"
|
|
||||||
"github.com/openaccounting/oa-server/core/ws"
|
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openaccounting/oa-server/core/model/types"
|
||||||
|
"github.com/openaccounting/oa-server/core/ws"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccountInterface interface {
|
type AccountInterface interface {
|
||||||
@@ -15,6 +16,8 @@ type AccountInterface interface {
|
|||||||
DeleteAccount(id string, userId string, orgId string) error
|
DeleteAccount(id string, userId string, orgId string) error
|
||||||
GetAccounts(orgId string, userId string, tokenId string) ([]*types.Account, error)
|
GetAccounts(orgId string, userId string, tokenId string) ([]*types.Account, error)
|
||||||
GetAccountsWithBalances(orgId string, userId string, tokenId string, date time.Time) ([]*types.Account, error)
|
GetAccountsWithBalances(orgId string, userId string, tokenId string, date time.Time) ([]*types.Account, error)
|
||||||
|
GetAccount(orgId, accId, userId, tokenId string) (*types.Account, error)
|
||||||
|
GetAccountWithBalance(orgId, accId, userId, tokenId string, date time.Time) (*types.Account, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ByName []*types.Account
|
type ByName []*types.Account
|
||||||
@@ -253,6 +256,21 @@ func (model *Model) getAccounts(orgId string, userId string, tokenId string, dat
|
|||||||
return filtered, nil
|
return filtered, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (model *Model) getAccount(orgId, accId, userId, tokenId string, date time.Time, withBalances bool) (*types.Account, error) {
|
||||||
|
accounts, err := model.getAccounts(orgId, userId, tokenId, date, withBalances)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, account := range accounts {
|
||||||
|
if account.Id == accId {
|
||||||
|
return account, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (model *Model) GetAccounts(orgId string, userId string, tokenId string) ([]*types.Account, error) {
|
func (model *Model) GetAccounts(orgId string, userId string, tokenId string) ([]*types.Account, error) {
|
||||||
return model.getAccounts(orgId, userId, tokenId, time.Time{}, false)
|
return model.getAccounts(orgId, userId, tokenId, time.Time{}, false)
|
||||||
}
|
}
|
||||||
@@ -261,6 +279,14 @@ func (model *Model) GetAccountsWithBalances(orgId string, userId string, tokenId
|
|||||||
return model.getAccounts(orgId, userId, tokenId, date, true)
|
return model.getAccounts(orgId, userId, tokenId, date, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (model *Model) GetAccount(orgId, accId, userId, tokenId string) (*types.Account, error) {
|
||||||
|
return model.getAccount(orgId, accId, userId, tokenId, time.Time{}, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (model *Model) GetAccountWithBalance(orgId, accId, userId, tokenId string, date time.Time) (*types.Account, error) {
|
||||||
|
return model.getAccount(orgId, accId, userId, tokenId, date, true)
|
||||||
|
}
|
||||||
|
|
||||||
func (model *Model) getAllAccounts(orgId string) ([]*types.Account, error) {
|
func (model *Model) getAllAccounts(orgId string) ([]*types.Account, error) {
|
||||||
return model.db.GetAccountsByOrgId(orgId)
|
return model.db.GetAccountsByOrgId(orgId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "1.1.0"
|
const version = "1.2.0"
|
||||||
|
|
||||||
//var upgrader = websocket.Upgrader{} // use default options
|
//var upgrader = websocket.Upgrader{} // use default options
|
||||||
var txSubscriptions = make(map[string][]*websocket.Conn)
|
var txSubscriptions = make(map[string][]*websocket.Conn)
|
||||||
|
|||||||
Reference in New Issue
Block a user