api 1.0.1 add signupSource

This commit is contained in:
Patrick Nagurny
2018-11-05 09:37:08 -05:00
parent 9b9124f730
commit 2a827bac26
14 changed files with 194 additions and 70 deletions

View File

@@ -13,12 +13,12 @@ import (
/** /**
* @api {get} /orgs/:orgId/accounts Get Accounts by Org id * @api {get} /orgs/:orgId/accounts Get Accounts by Org id
* @apiVersion 1.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.
@@ -85,12 +85,12 @@ func GetOrgAccounts(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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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 +198,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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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 +273,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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 semver versioning
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK

View File

@@ -4,6 +4,14 @@ import (
"github.com/ant0ine/go-json-rest/rest" "github.com/ant0ine/go-json-rest/rest"
) )
/**
* Changelog
*
* 1.0.1
* - add user.signupSource
*
*/
/** /**
* @apiDefine NotAuthorizedError * @apiDefine NotAuthorizedError
* *

View File

@@ -9,12 +9,12 @@ import (
/** /**
* @api {get} /apikeys Get API keys * @api {get} /apikeys Get API keys
* @apiVersion 1.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @apiName PostApiKey * @apiName PostApiKey
* @apiGroup ApiKey * @apiGroup ApiKey
* *
* @apiHeader {String} Accept-Version ^1.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @apiName PutApiKey * @apiName PutApiKey
* @apiGroup ApiKey * @apiGroup ApiKey
* *
* @apiHeader {String} Accept-Version ^1.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @apiName PostSession * @apiName PostSession
* @apiGroup Session * @apiGroup Session
* *
* @apiHeader {String} Accept-Version ^1.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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} /orgs/:orgId/accounts/:accountId/transactions Get Transactions by Account Id * @api {get} /orgs/:orgId/accounts/:accountId/transactions Get Transactions by Account Id
* @apiVersion 1.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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
@@ -37,6 +37,7 @@ type ResetPasswordParams struct {
* @apiSuccess {String} email Email of the User. * @apiSuccess {String} email Email of the User.
* @apiSuccess {Boolean} agreeToTerms Agree to terms * @apiSuccess {Boolean} agreeToTerms Agree to terms
* @apiSuccess {Boolean} emailVerified True if email has been verified. * @apiSuccess {Boolean} emailVerified True if email has been verified.
* @apiSuccess {String} signupSource Identify signup source (android, ios, web)
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@@ -48,7 +49,8 @@ type ResetPasswordParams struct {
* "lastName": "Doe", * "lastName": "Doe",
* "email": "johndoe@email.com", * "email": "johndoe@email.com",
* "agreeToTerms": true, * "agreeToTerms": true,
* "emailVerified": true * "emailVerified": true,
* "signupSource": "web"
* } * }
* *
* @apiUse NotAuthorizedError * @apiUse NotAuthorizedError
@@ -62,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.0.0 * @apiVersion 1.0.1
* @apiName PostUser * @apiName PostUser
* @apiGroup User * @apiGroup User
* *
* @apiHeader {String} Accept-Version ^1.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.
@@ -74,6 +76,7 @@ func GetUser(w rest.ResponseWriter, r *rest.Request) {
* @apiParam {String} email Email of the User. * @apiParam {String} email Email of the User.
* @apiParam {String} password Password of the User. * @apiParam {String} password Password of the User.
* @apiParam {Boolean} agreeToTerms True if you agree to terms * @apiParam {Boolean} agreeToTerms True if you agree to terms
* @apiParam {String} signupSource Identify signup source (android, ios, web)
* *
* @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
@@ -82,6 +85,7 @@ func GetUser(w rest.ResponseWriter, r *rest.Request) {
* @apiSuccess {String} lastName Last name of the User. * @apiSuccess {String} lastName Last name of the User.
* @apiSuccess {String} email Email of the User. * @apiSuccess {String} email Email of the User.
* @apiSuccess {Boolean} emailVerified True if email has been verified. * @apiSuccess {Boolean} emailVerified True if email has been verified.
* @apiSuccess {String} signupSource Identify signup source (android, ios, web)
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@@ -93,7 +97,8 @@ func GetUser(w rest.ResponseWriter, r *rest.Request) {
* "lastName": "Doe", * "lastName": "Doe",
* "email": "johndoe@email.com", * "email": "johndoe@email.com",
* "agreeToTerms": true, * "agreeToTerms": true,
* "emailVerified": true * "emailVerified": true,
* "signupSource": "web"
* } * }
* *
* @apiUse InternalServerError * @apiUse InternalServerError
@@ -118,12 +123,12 @@ func PostUser(w rest.ResponseWriter, r *rest.Request) {
/** /**
* @api {put} /user Modify User * @api {put} /user Modify User
* @apiVersion 1.0.0 * @apiVersion 1.0.1
* @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.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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)
@@ -135,6 +140,7 @@ func PostUser(w rest.ResponseWriter, r *rest.Request) {
* @apiSuccess {String} lastName Last name of the User. * @apiSuccess {String} lastName Last name of the User.
* @apiSuccess {String} email Email of the User. * @apiSuccess {String} email Email of the User.
* @apiSuccess {Boolean} emailVerified True if email has been verified. * @apiSuccess {Boolean} emailVerified True if email has been verified.
* @apiSuccess {String} signupSource Identify signup source (android, ios, web)
* *
* @apiSuccessExample Success-Response: * @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK * HTTP/1.1 200 OK
@@ -146,7 +152,8 @@ func PostUser(w rest.ResponseWriter, r *rest.Request) {
* "lastName": "Doe", * "lastName": "Doe",
* "email": "johndoe@email.com", * "email": "johndoe@email.com",
* "agreeToTerms": true, * "agreeToTerms": true,
* "emailVerified": true * "emailVerified": true,
* "signupSource": "web"
* } * }
* *
* @apiUse InternalServerError * @apiUse InternalServerError
@@ -197,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.0.0 * @apiVersion 1.0.1
* @apiName VerifyUser * @apiName VerifyUser
* @apiGroup User * @apiGroup User
* *
* @apiHeader {String} Accept-Version ^1.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 semver versioning
* *
* @apiParam {String} code Email verification code * @apiParam {String} code Email verification code
* *
@@ -231,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.0.0 * @apiVersion 1.0.1
* @apiName ResetPassword * @apiName ResetPassword
* @apiGroup User * @apiGroup User
* *
* @apiHeader {String} Accept-Version ^1.0.0 semver versioning * @apiHeader {String} Accept-Version ^1.0.1 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.0.0") serverVersion, _ := semver.NewVersion("1.0.1")
// Pre-release versions // Pre-release versions
compatVersion, _ := semver.NewVersion("0.1.8") compatVersion, _ := semver.NewVersion("0.1.8")

View File

@@ -8,7 +8,7 @@ import (
"time" "time"
) )
const userFields = "LOWER(HEX(u.id)),u.inserted,u.updated,u.firstName,u.lastName,u.email,u.passwordHash,u.agreeToTerms,u.passwordReset,u.emailVerified,u.emailVerifyCode" const userFields = "LOWER(HEX(u.id)),u.inserted,u.updated,u.firstName,u.lastName,u.email,u.passwordHash,u.agreeToTerms,u.passwordReset,u.emailVerified,u.emailVerifyCode,u.signupSource"
type UserInterface interface { type UserInterface interface {
InsertUser(*types.User) error InsertUser(*types.User) error
@@ -28,7 +28,7 @@ func (db *DB) InsertUser(user *types.User) error {
user.Updated = user.Inserted user.Updated = user.Inserted
user.PasswordReset = "" user.PasswordReset = ""
query := "INSERT INTO user(id,inserted,updated,firstName,lastName,email,passwordHash,agreeToTerms,passwordReset,emailVerified,emailVerifyCode) VALUES(UNHEX(?),?,?,?,?,?,?,?,?,?,?)" query := "INSERT INTO user(id,inserted,updated,firstName,lastName,email,passwordHash,agreeToTerms,passwordReset,emailVerified,emailVerifyCode,signupSource) VALUES(UNHEX(?),?,?,?,?,?,?,?,?,?,?,?)"
res, err := db.Exec( res, err := db.Exec(
query, query,
user.Id, user.Id,
@@ -42,6 +42,7 @@ func (db *DB) InsertUser(user *types.User) error {
user.PasswordReset, user.PasswordReset,
user.EmailVerified, user.EmailVerified,
user.EmailVerifyCode, user.EmailVerifyCode,
user.SignupSource,
) )
if err != nil { if err != nil {
return err return err
@@ -229,6 +230,7 @@ func (db *DB) unmarshalUser(row *sql.Row) (*types.User, error) {
&u.PasswordReset, &u.PasswordReset,
&u.EmailVerified, &u.EmailVerified,
&u.EmailVerifyCode, &u.EmailVerifyCode,
&u.SignupSource,
) )
if err != nil { if err != nil {
@@ -263,6 +265,7 @@ func (db *DB) unmarshalUsers(rows *sql.Rows) ([]*types.User, error) {
&u.PasswordReset, &u.PasswordReset,
&u.EmailVerified, &u.EmailVerified,
&u.EmailVerifyCode, &u.EmailVerifyCode,
&u.SignupSource,
) )
if err != nil { if err != nil {

View File

@@ -17,4 +17,5 @@ type User struct {
PasswordReset string `json:"-"` PasswordReset string `json:"-"`
EmailVerified bool `json:"emailVerified"` EmailVerified bool `json:"emailVerified"`
EmailVerifyCode string `json:"-"` EmailVerifyCode string `json:"-"`
SignupSource string `json:"signupSource"`
} }

View File

@@ -14,7 +14,7 @@ import (
"sync" "sync"
) )
const version = "1.0.0" const version = "1.0.1"
//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/migrate1.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: migrate1.go <upgrade/downgrade>")
}
command := os.Args[1]
if command != "upgrade" && command != "downgrade" {
log.Fatal("Usage: migrate1.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 user ADD COLUMN signupSource VARCHAR(100) NOT NULL AFTER emailVerifyCode"
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 user DROP COLUMN signupSource"
if _, err = tx.Exec(query1); err != nil {
return
}
return
}

View File

@@ -6,7 +6,7 @@ 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, 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, 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;
CREATE TABLE userorg (id INT UNSIGNED NOT NULL AUTO_INCREMENT, userId BINARY(16) NOT NULL, orgId BINARY(16) NOT NULL, admin BOOLEAN NOT NULL DEFAULT false, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE userorg (id INT UNSIGNED NOT NULL AUTO_INCREMENT, userId BINARY(16) NOT NULL, orgId BINARY(16) NOT NULL, admin BOOLEAN NOT NULL DEFAULT false, PRIMARY KEY(id)) ENGINE=InnoDB;