Merge pull request #7 from pnagurny/feature/timezones

Feature/timezones
This commit is contained in:
Patrick Nagurny
2019-06-28 15:34:31 -04:00
committed by GitHub
15 changed files with 194 additions and 74 deletions

View File

@@ -14,12 +14,12 @@ import (
/** /**
* @api {get} /orgs/:orgId/accounts Get Accounts by Org id * @api {get} /orgs/:orgId/accounts Get Accounts by Org id
* @apiVersion 1.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.
@@ -86,12 +86,12 @@ func GetOrgAccounts(w rest.ResponseWriter, r *rest.Request) {
/** /**
* @api {get} /orgs/:orgId/accounts/:accountId Get Acount by Org id and Account id * @api {get} /orgs/:orgId/accounts/:accountId Get Acount by Org id and Account id
* @apiVersion 1.2.0 * @apiVersion 1.3.0
* @apiName GetOrgAccount * @apiName GetOrgAccount
* @apiGroup Account * @apiGroup Account
* *
* @apiHeader {String} Authorization HTTP Basic Auth * @apiHeader {String} Authorization HTTP Basic Auth
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.
@@ -157,12 +157,12 @@ func GetOrgAccount(w rest.ResponseWriter, r *rest.Request) {
/** /**
* @api {post} /orgs/:orgId/accounts Create a new Account * @api {post} /orgs/:orgId/accounts Create a new Account
* @apiVersion 1.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.
@@ -270,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.
@@ -345,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK

View File

@@ -7,6 +7,9 @@ import (
/** /**
* Changelog * Changelog
* *
* 1.3.0
* - add org.timezone
*
* 1.2.0 * 1.2.0
* - add `GET /orgs/:orgId/accounts/:accountId * - add `GET /orgs/:orgId/accounts/:accountId
* *

View File

@@ -9,12 +9,12 @@ import (
/** /**
* @api {get} /apikeys Get API keys * @api {get} /apikeys Get API keys
* @apiVersion 1.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.0
* @apiName PostApiKey * @apiName PostApiKey
* @apiGroup ApiKey * @apiGroup ApiKey
* *
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.0
* @apiName PutApiKey * @apiName PutApiKey
* @apiGroup ApiKey * @apiGroup ApiKey
* *
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK

View File

@@ -9,12 +9,12 @@ import (
/** /**
* @api {get} /org/:orgId Get Org by id * @api {get} /org/:orgId Get Org by id
* @apiVersion 1.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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
@@ -22,6 +22,7 @@ import (
* @apiSuccess {String} name Name of the Org. * @apiSuccess {String} name Name of the Org.
* @apiSuccess {String} currency Three letter currency code. * @apiSuccess {String} currency Three letter currency code.
* @apiSuccess {Number} precision How many digits the currency goes out to. * @apiSuccess {Number} precision How many digits the currency goes out to.
* @apiSuccess {String} timezone Timezone to use for accounting.
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@@ -32,6 +33,7 @@ import (
* "name": "MyOrg", * "name": "MyOrg",
* "currency": "USD", * "currency": "USD",
* "precision": 2, * "precision": 2,
* "timezone": "America/New_York"
* } * }
* *
* @apiUse NotAuthorizedError * @apiUse NotAuthorizedError
@@ -53,12 +55,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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
@@ -66,6 +68,7 @@ func GetOrg(w rest.ResponseWriter, r *rest.Request) {
* @apiSuccess {String} name Name of the Org. * @apiSuccess {String} name Name of the Org.
* @apiSuccess {String} currency Three letter currency code. * @apiSuccess {String} currency Three letter currency code.
* @apiSuccess {Number} precision How many digits the currency goes out to. * @apiSuccess {Number} precision How many digits the currency goes out to.
@apiSuccess {String} timezone Timezone to use for accounting.
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@@ -77,6 +80,7 @@ func GetOrg(w rest.ResponseWriter, r *rest.Request) {
* "name": "MyOrg", * "name": "MyOrg",
* "currency": "USD", * "currency": "USD",
* "precision": 2, * "precision": 2,
* "timezone": "America/New_York"
* } * }
* ] * ]
* *
@@ -98,17 +102,18 @@ func GetOrgs(w rest.ResponseWriter, r *rest.Request) {
/** /**
* @api {post} /orgs Create a new Org * @api {post} /orgs Create a new Org
* @apiVersion 1.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.
* @apiParam {String} currency Three letter currency code. * @apiParam {String} currency Three letter currency code.
* @apiParam {Number} precision How many digits the currency goes out to. * @apiParam {Number} precision How many digits the currency goes out to.
* @apiParam {String} timezone Timezone to use for accounting.
* *
* @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
@@ -116,6 +121,7 @@ func GetOrgs(w rest.ResponseWriter, r *rest.Request) {
* @apiSuccess {String} name Name of the Org. * @apiSuccess {String} name Name of the Org.
* @apiSuccess {String} currency Three letter currency code. * @apiSuccess {String} currency Three letter currency code.
* @apiSuccess {Number} precision How many digits the currency goes out to. * @apiSuccess {Number} precision How many digits the currency goes out to.
* @apiSuccess {String} timezone Timezone to use for accounting.
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@@ -126,6 +132,7 @@ func GetOrgs(w rest.ResponseWriter, r *rest.Request) {
* "name": "MyOrg", * "name": "MyOrg",
* "currency": "USD", * "currency": "USD",
* "precision": 2, * "precision": 2,
* "timezone": "America/New_York"
* } * }
* *
* @apiUse NotAuthorizedError * @apiUse NotAuthorizedError
@@ -152,12 +159,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiParam {String} name Name of the Org. * @apiParam {String} name Name of the Org.
* *
@@ -167,6 +174,7 @@ func PostOrg(w rest.ResponseWriter, r *rest.Request) {
* @apiSuccess {String} name Name of the Org. * @apiSuccess {String} name Name of the Org.
* @apiSuccess {String} currency Three letter currency code. * @apiSuccess {String} currency Three letter currency code.
* @apiSuccess {Number} precision How many digits the currency goes out to. * @apiSuccess {Number} precision How many digits the currency goes out to.
* @apiSuccess {String} timezone Timezone to use for accounting.
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@@ -177,6 +185,7 @@ func PostOrg(w rest.ResponseWriter, r *rest.Request) {
* "name": "MyOrg", * "name": "MyOrg",
* "currency": "USD", * "currency": "USD",
* "precision": 2, * "precision": 2,
* "timezone": "America/New_York"
* } * }
* *
* @apiUse NotAuthorizedError * @apiUse NotAuthorizedError
@@ -207,12 +216,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiParam {String} email Email address of user * @apiParam {String} email Email address of user
* *
@@ -263,12 +272,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiParam {String} accepted true * @apiParam {String} accepted true
* *
@@ -320,12 +329,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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 +375,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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK

View File

@@ -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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK

View File

@@ -9,11 +9,11 @@ import (
/** /**
* @api {post} /sessions Create a new Session * @api {post} /sessions Create a new Session
* @apiVersion 1.2.0 * @apiVersion 1.3.0
* @apiName PostSession * @apiName PostSession
* @apiGroup Session * @apiGroup Session
* *
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK

View File

@@ -7,12 +7,12 @@ import (
/** /**
* @api {get} /health-check Get system health status * @api {get} /health-check Get system health status
* @apiVersion 1.2.0 * @apiVersion 1.3.0
* @apiName GetSystemHealthStatus * @apiName GetSystemHealthStatus
* @apiGroup SystemHealth * @apiGroup SystemHealth
* *
* *
* @apiHeader {String} Accept-Version: 1.2.0 semver versioning * @apiHeader {String} Accept-Version: 1.3.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"

View File

@@ -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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK

View File

@@ -22,12 +22,12 @@ type ResetPasswordParams struct {
/** /**
* @api {get} /user Get Authenticated User * @api {get} /user Get Authenticated User
* @apiVersion 1.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.0
* @apiName PostUser * @apiName PostUser
* @apiGroup User * @apiGroup User
* *
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.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.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.0
* @apiName VerifyUser * @apiName VerifyUser
* @apiGroup User * @apiGroup User
* *
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.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.2.0 * @apiVersion 1.3.0
* @apiName ResetPassword * @apiName ResetPassword
* @apiGroup User * @apiGroup User
* *
* @apiHeader {String} Accept-Version ^1.2.0 semver versioning * @apiHeader {String} Accept-Version ^1.3.0 semver versioning
* *
* @apiParam {String} email Email address for user * @apiParam {String} email Email address for user
* *

View File

@@ -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.2.0") serverVersion, _ := semver.NewVersion("1.3.0")
// Pre-release versions // Pre-release versions
compatVersion, _ := semver.NewVersion("0.1.8") compatVersion, _ := semver.NewVersion("0.1.8")

View File

@@ -21,7 +21,7 @@ type OrgInterface interface {
DeleteInvite(string) error DeleteInvite(string) error
} }
const orgFields = "LOWER(HEX(o.id)),o.inserted,o.updated,o.name,o.currency,o.`precision`" const orgFields = "LOWER(HEX(o.id)),o.inserted,o.updated,o.name,o.currency,o.`precision`,o.timezone"
const inviteFields = "i.id,LOWER(HEX(i.orgId)),i.inserted,i.updated,i.email,i.accepted" const inviteFields = "i.id,LOWER(HEX(i.orgId)),i.inserted,i.updated,i.email,i.accepted"
func (db *DB) CreateOrg(org *types.Org, userId string, accounts []*types.Account) (err error) { func (db *DB) CreateOrg(org *types.Org, userId string, accounts []*types.Account) (err error) {
@@ -46,7 +46,7 @@ func (db *DB) CreateOrg(org *types.Org, userId string, accounts []*types.Account
org.Updated = org.Inserted org.Updated = org.Inserted
// create org // create org
query1 := "INSERT INTO org(id,inserted,updated,name,currency,`precision`) VALUES(UNHEX(?),?,?,?,?,?)" query1 := "INSERT INTO org(id,inserted,updated,name,currency,`precision`,timezone) VALUES(UNHEX(?),?,?,?,?,?,?)"
res, err := tx.Exec( res, err := tx.Exec(
query1, query1,
@@ -56,6 +56,7 @@ func (db *DB) CreateOrg(org *types.Org, userId string, accounts []*types.Account
org.Name, org.Name,
org.Currency, org.Currency,
org.Precision, org.Precision,
org.Timezone,
) )
if err != nil { if err != nil {
@@ -126,11 +127,12 @@ func (db *DB) CreateOrg(org *types.Org, userId string, accounts []*types.Account
func (db *DB) UpdateOrg(org *types.Org) error { func (db *DB) UpdateOrg(org *types.Org) error {
org.Updated = time.Now() org.Updated = time.Now()
query := "UPDATE org SET updated = ?, name = ? WHERE id = UNHEX(?)" query := "UPDATE org SET updated = ?, name = ?, timezone = ? WHERE id = UNHEX(?)"
_, err := db.Exec( _, err := db.Exec(
query, query,
util.TimeToMs(org.Updated), util.TimeToMs(org.Updated),
org.Name, org.Name,
org.Timezone,
org.Id, org.Id,
) )
@@ -143,7 +145,7 @@ func (db *DB) GetOrg(orgId string, userId string) (*types.Org, error) {
var updated int64 var updated int64
err := db.QueryRow("SELECT "+orgFields+" FROM org o JOIN userorg ON userorg.orgId = o.id WHERE o.id = UNHEX(?) AND userorg.userId = UNHEX(?)", orgId, userId). err := db.QueryRow("SELECT "+orgFields+" FROM org o JOIN userorg ON userorg.orgId = o.id WHERE o.id = UNHEX(?) AND userorg.userId = UNHEX(?)", orgId, userId).
Scan(&o.Id, &inserted, &updated, &o.Name, &o.Currency, &o.Precision) Scan(&o.Id, &inserted, &updated, &o.Name, &o.Currency, &o.Precision, &o.Timezone)
switch { switch {
case err == sql.ErrNoRows: case err == sql.ErrNoRows:
@@ -173,7 +175,7 @@ func (db *DB) GetOrgs(userId string) ([]*types.Org, error) {
var inserted int64 var inserted int64
var updated int64 var updated int64
err = rows.Scan(&o.Id, &inserted, &updated, &o.Name, &o.Currency, &o.Precision) err = rows.Scan(&o.Id, &inserted, &updated, &o.Name, &o.Currency, &o.Precision, &o.Timezone)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -11,4 +11,5 @@ type Org struct {
Name string `json:"name"` Name string `json:"name"`
Currency string `json:"currency"` Currency string `json:"currency"`
Precision int `json:"precision"` Precision int `json:"precision"`
Timezone string `json:"timezone"`
} }

View File

@@ -14,7 +14,7 @@ import (
"sync" "sync"
) )
const version = "1.2.0" const version = "1.3.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)

105
migrations/migrate2.go Normal file
View File

@@ -0,0 +1,105 @@
package main
import (
"encoding/json"
"github.com/openaccounting/oa-server/core/model/db"
"github.com/openaccounting/oa-server/core/model/types"
"log"
"os"
)
func main() {
if len(os.Args) != 2 {
log.Fatal("Usage: migrate2.go <upgrade/downgrade>")
}
command := os.Args[1]
if command != "upgrade" && command != "downgrade" {
log.Fatal("Usage: migrate2.go <upgrade/downgrade>")
}
//filename is the path to the json config file
var config types.Config
file, err := os.Open("./config.json")
if err != nil {
log.Fatal(err)
}
decoder := json.NewDecoder(file)
err = decoder.Decode(&config)
if err != nil {
log.Fatal(err)
}
connectionString := config.User + ":" + config.Password + "@/" + config.Database
db, err := db.NewDB(connectionString)
if command == "upgrade" {
err = upgrade(db)
} else {
err = downgrade(db)
}
if err != nil {
log.Fatal(err)
}
log.Println("done")
}
func upgrade(db *db.DB) (err error) {
tx, err := db.Begin()
if err != nil {
return
}
defer func() {
if p := recover(); p != nil {
tx.Rollback()
panic(p) // re-throw panic after Rollback
} else if err != nil {
tx.Rollback()
} else {
err = tx.Commit()
}
}()
query1 := "ALTER TABLE org ADD COLUMN timezone VARCHAR(100) NOT NULL AFTER `precision`"
if _, err = tx.Exec(query1); err != nil {
return
}
return
}
func downgrade(db *db.DB) (err error) {
tx, err := db.Begin()
if err != nil {
return
}
defer func() {
if p := recover(); p != nil {
tx.Rollback()
panic(p) // re-throw panic after Rollback
} else if err != nil {
tx.Rollback()
} else {
err = tx.Commit()
}
}()
query1 := "ALTER TABLE org DROP COLUMN timezone"
if _, err = tx.Exec(query1); err != nil {
return
}
return
}

View File

@@ -4,7 +4,7 @@ CREATE DATABASE openaccounting CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
use openaccounting; use openaccounting;
CREATE TABLE org (id BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, updated BIGINT UNSIGNED NOT NULL, name VARCHAR(100) NOT NULL, currency VARCHAR(10) NOT NULL, `precision` INT NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE org (id BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, updated BIGINT UNSIGNED NOT NULL, name VARCHAR(100) NOT NULL, currency VARCHAR(10) NOT NULL, `precision` INT NOT NULL, timezone VARCHAR(100) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
CREATE TABLE user (id BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, updated BIGINT UNSIGNED NOT NULL, firstName VARCHAR(50) NOT NULL, lastName VARCHAR(50) NOT NULL, email VARCHAR(100) NOT NULL, passwordHash VARCHAR(100) NOT NULL, agreeToTerms BOOLEAN NOT NULL, passwordReset VARCHAR(32) NOT NULL, emailVerified BOOLEAN NOT NULL, emailVerifyCode VARCHAR(32) NOT NULL, signupSource VARCHAR(100) NOT NULL, UNIQUE(email), PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE user (id BINARY(16) NOT NULL, inserted BIGINT UNSIGNED NOT NULL, updated BIGINT UNSIGNED NOT NULL, firstName VARCHAR(50) NOT NULL, lastName VARCHAR(50) NOT NULL, email VARCHAR(100) NOT NULL, passwordHash VARCHAR(100) NOT NULL, agreeToTerms BOOLEAN NOT NULL, passwordReset VARCHAR(32) NOT NULL, emailVerified BOOLEAN NOT NULL, emailVerifyCode VARCHAR(32) NOT NULL, signupSource VARCHAR(100) NOT NULL, UNIQUE(email), PRIMARY KEY(id)) ENGINE=InnoDB;