mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 07:33:21 -05:00
Prefix all API endpoints with 'v1/', pluralize collections
This commit is contained in:
parent
79ed5dad9f
commit
9429b748fa
@ -104,8 +104,8 @@ var accountTransactionsRE *regexp.Regexp
|
||||
var accountImportRE *regexp.Regexp
|
||||
|
||||
func init() {
|
||||
accountTransactionsRE = regexp.MustCompile(`^/account/[0-9]+/transactions/?$`)
|
||||
accountImportRE = regexp.MustCompile(`^/account/[0-9]+/import/[a-z]+/?$`)
|
||||
accountTransactionsRE = regexp.MustCompile(`^/v1/accounts/[0-9]+/transactions/?$`)
|
||||
accountImportRE = regexp.MustCompile(`^/v1/accounts/[0-9]+/imports/[a-z]+/?$`)
|
||||
}
|
||||
|
||||
func (a *Account) Write(w http.ResponseWriter) error {
|
||||
@ -384,12 +384,12 @@ func AccountHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
}
|
||||
|
||||
if r.Method == "POST" {
|
||||
// if URL looks like /account/[0-9]+/import, use the account
|
||||
// if URL looks like /v1/accounts/[0-9]+/imports, use the account
|
||||
// import handler
|
||||
if accountImportRE.MatchString(r.URL.Path) {
|
||||
var accountid int64
|
||||
var importtype string
|
||||
n, err := GetURLPieces(r.URL.Path, "/account/%d/import/%s", &accountid, &importtype)
|
||||
n, err := GetURLPieces(r.URL.Path, "/v1/accounts/%d/imports/%s", &accountid, &importtype)
|
||||
|
||||
if err != nil || n != 2 {
|
||||
log.Print(err)
|
||||
@ -434,7 +434,7 @@ func AccountHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
return ResponseWrapper{201, &account}
|
||||
} else if r.Method == "GET" {
|
||||
var accountid int64
|
||||
n, err := GetURLPieces(r.URL.Path, "/account/%d", &accountid)
|
||||
n, err := GetURLPieces(r.URL.Path, "/v1/accounts/%d", &accountid)
|
||||
|
||||
if err != nil || n != 1 {
|
||||
//Return all Accounts
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
|
||||
func createAccount(client *http.Client, account *handlers.Account) (*handlers.Account, error) {
|
||||
var a handlers.Account
|
||||
err := create(client, account, &a, "/account/", "account")
|
||||
err := create(client, account, &a, "/v1/accounts/", "account")
|
||||
return &a, err
|
||||
}
|
||||
|
||||
func getAccount(client *http.Client, accountid int64) (*handlers.Account, error) {
|
||||
var a handlers.Account
|
||||
err := read(client, &a, "/account/"+strconv.FormatInt(accountid, 10), "account")
|
||||
err := read(client, &a, "/v1/accounts/"+strconv.FormatInt(accountid, 10), "account")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -24,7 +24,7 @@ func getAccount(client *http.Client, accountid int64) (*handlers.Account, error)
|
||||
|
||||
func getAccounts(client *http.Client) (*handlers.AccountList, error) {
|
||||
var al handlers.AccountList
|
||||
err := read(client, &al, "/account/", "accounts")
|
||||
err := read(client, &al, "/v1/accounts/", "accounts")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -33,7 +33,7 @@ func getAccounts(client *http.Client) (*handlers.AccountList, error) {
|
||||
|
||||
func updateAccount(client *http.Client, account *handlers.Account) (*handlers.Account, error) {
|
||||
var a handlers.Account
|
||||
err := update(client, account, &a, "/account/"+strconv.FormatInt(account.AccountId, 10), "account")
|
||||
err := update(client, account, &a, "/v1/accounts/"+strconv.FormatInt(account.AccountId, 10), "account")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -41,7 +41,7 @@ func updateAccount(client *http.Client, account *handlers.Account) (*handlers.Ac
|
||||
}
|
||||
|
||||
func deleteAccount(client *http.Client, a *handlers.Account) error {
|
||||
err := remove(client, "/account/"+strconv.FormatInt(a.AccountId, 10), "account")
|
||||
err := remove(client, "/v1/accounts/"+strconv.FormatInt(a.AccountId, 10), "account")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -52,15 +52,15 @@ func TxHandlerFunc(t TxHandler, db *gorp.DbMap) http.HandlerFunc {
|
||||
|
||||
func GetHandler(db *gorp.DbMap) *http.ServeMux {
|
||||
servemux := http.NewServeMux()
|
||||
servemux.HandleFunc("/session/", TxHandlerFunc(SessionHandler, db))
|
||||
servemux.HandleFunc("/user/", TxHandlerFunc(UserHandler, db))
|
||||
servemux.HandleFunc("/security/", TxHandlerFunc(SecurityHandler, db))
|
||||
servemux.HandleFunc("/price/", TxHandlerFunc(PriceHandler, db))
|
||||
servemux.HandleFunc("/securitytemplate/", SecurityTemplateHandler)
|
||||
servemux.HandleFunc("/account/", TxHandlerFunc(AccountHandler, db))
|
||||
servemux.HandleFunc("/transaction/", TxHandlerFunc(TransactionHandler, db))
|
||||
servemux.HandleFunc("/import/gnucash", TxHandlerFunc(GnucashImportHandler, db))
|
||||
servemux.HandleFunc("/report/", TxHandlerFunc(ReportHandler, db))
|
||||
servemux.HandleFunc("/v1/sessions/", TxHandlerFunc(SessionHandler, db))
|
||||
servemux.HandleFunc("/v1/users/", TxHandlerFunc(UserHandler, db))
|
||||
servemux.HandleFunc("/v1/securities/", TxHandlerFunc(SecurityHandler, db))
|
||||
servemux.HandleFunc("/v1/prices/", TxHandlerFunc(PriceHandler, db))
|
||||
servemux.HandleFunc("/v1/securitytemplates/", SecurityTemplateHandler)
|
||||
servemux.HandleFunc("/v1/accounts/", TxHandlerFunc(AccountHandler, db))
|
||||
servemux.HandleFunc("/v1/transactions/", TxHandlerFunc(TransactionHandler, db))
|
||||
servemux.HandleFunc("/v1/imports/gnucash", TxHandlerFunc(GnucashImportHandler, db))
|
||||
servemux.HandleFunc("/v1/reports/", TxHandlerFunc(ReportHandler, db))
|
||||
|
||||
return servemux
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func PriceHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
return ResponseWrapper{201, &price}
|
||||
} else if r.Method == "GET" {
|
||||
var priceid int64
|
||||
n, err := GetURLPieces(r.URL.Path, "/price/%d", &priceid)
|
||||
n, err := GetURLPieces(r.URL.Path, "/v1/prices/%d", &priceid)
|
||||
|
||||
if err != nil || n != 1 {
|
||||
//Return all prices
|
||||
|
@ -10,13 +10,13 @@ import (
|
||||
|
||||
func createPrice(client *http.Client, price *handlers.Price) (*handlers.Price, error) {
|
||||
var p handlers.Price
|
||||
err := create(client, price, &p, "/price/", "price")
|
||||
err := create(client, price, &p, "/v1/prices/", "price")
|
||||
return &p, err
|
||||
}
|
||||
|
||||
func getPrice(client *http.Client, priceid int64) (*handlers.Price, error) {
|
||||
var p handlers.Price
|
||||
err := read(client, &p, "/price/"+strconv.FormatInt(priceid, 10), "price")
|
||||
err := read(client, &p, "/v1/prices/"+strconv.FormatInt(priceid, 10), "price")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -25,7 +25,7 @@ func getPrice(client *http.Client, priceid int64) (*handlers.Price, error) {
|
||||
|
||||
func getPrices(client *http.Client) (*handlers.PriceList, error) {
|
||||
var pl handlers.PriceList
|
||||
err := read(client, &pl, "/price/", "prices")
|
||||
err := read(client, &pl, "/v1/prices/", "prices")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -34,7 +34,7 @@ func getPrices(client *http.Client) (*handlers.PriceList, error) {
|
||||
|
||||
func updatePrice(client *http.Client, price *handlers.Price) (*handlers.Price, error) {
|
||||
var p handlers.Price
|
||||
err := update(client, price, &p, "/price/"+strconv.FormatInt(price.PriceId, 10), "price")
|
||||
err := update(client, price, &p, "/v1/prices/"+strconv.FormatInt(price.PriceId, 10), "price")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -42,7 +42,7 @@ func updatePrice(client *http.Client, price *handlers.Price) (*handlers.Price, e
|
||||
}
|
||||
|
||||
func deletePrice(client *http.Client, p *handlers.Price) error {
|
||||
err := remove(client, "/price/"+strconv.FormatInt(p.PriceId, 10), "price")
|
||||
err := remove(client, "/v1/prices/"+strconv.FormatInt(p.PriceId, 10), "price")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
var reportTabulationRE *regexp.Regexp
|
||||
|
||||
func init() {
|
||||
reportTabulationRE = regexp.MustCompile(`^/report/[0-9]+/tabulation/?$`)
|
||||
reportTabulationRE = regexp.MustCompile(`^/v1/reports/[0-9]+/tabulations/?$`)
|
||||
}
|
||||
|
||||
//type and value to store user in lua's Context
|
||||
@ -257,7 +257,7 @@ func ReportHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
} else if r.Method == "GET" {
|
||||
if reportTabulationRE.MatchString(r.URL.Path) {
|
||||
var reportid int64
|
||||
n, err := GetURLPieces(r.URL.Path, "/report/%d/tabulation", &reportid)
|
||||
n, err := GetURLPieces(r.URL.Path, "/v1/reports/%d/tabulations", &reportid)
|
||||
if err != nil || n != 1 {
|
||||
log.Print(err)
|
||||
return NewError(999 /*InternalError*/)
|
||||
@ -266,7 +266,7 @@ func ReportHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
}
|
||||
|
||||
var reportid int64
|
||||
n, err := GetURLPieces(r.URL.Path, "/report/%d", &reportid)
|
||||
n, err := GetURLPieces(r.URL.Path, "/v1/reports/%d", &reportid)
|
||||
if err != nil || n != 1 {
|
||||
//Return all Reports
|
||||
var rl ReportList
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
|
||||
func createReport(client *http.Client, report *handlers.Report) (*handlers.Report, error) {
|
||||
var r handlers.Report
|
||||
err := create(client, report, &r, "/report/", "report")
|
||||
err := create(client, report, &r, "/v1/reports/", "report")
|
||||
return &r, err
|
||||
}
|
||||
|
||||
func getReport(client *http.Client, reportid int64) (*handlers.Report, error) {
|
||||
var r handlers.Report
|
||||
err := read(client, &r, "/report/"+strconv.FormatInt(reportid, 10), "report")
|
||||
err := read(client, &r, "/v1/reports/"+strconv.FormatInt(reportid, 10), "report")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -24,7 +24,7 @@ func getReport(client *http.Client, reportid int64) (*handlers.Report, error) {
|
||||
|
||||
func getReports(client *http.Client) (*handlers.ReportList, error) {
|
||||
var rl handlers.ReportList
|
||||
err := read(client, &rl, "/report/", "reports")
|
||||
err := read(client, &rl, "/v1/reports/", "reports")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -33,7 +33,7 @@ func getReports(client *http.Client) (*handlers.ReportList, error) {
|
||||
|
||||
func updateReport(client *http.Client, report *handlers.Report) (*handlers.Report, error) {
|
||||
var r handlers.Report
|
||||
err := update(client, report, &r, "/report/"+strconv.FormatInt(report.ReportId, 10), "report")
|
||||
err := update(client, report, &r, "/v1/reports/"+strconv.FormatInt(report.ReportId, 10), "report")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -41,7 +41,7 @@ func updateReport(client *http.Client, report *handlers.Report) (*handlers.Repor
|
||||
}
|
||||
|
||||
func deleteReport(client *http.Client, r *handlers.Report) error {
|
||||
err := remove(client, "/report/"+strconv.FormatInt(r.ReportId, 10), "report")
|
||||
err := remove(client, "/v1/reports/"+strconv.FormatInt(r.ReportId, 10), "report")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -50,7 +50,7 @@ func deleteReport(client *http.Client, r *handlers.Report) error {
|
||||
|
||||
func tabulateReport(client *http.Client, reportid int64) (*handlers.Tabulation, error) {
|
||||
var t handlers.Tabulation
|
||||
err := read(client, &t, "/report/"+strconv.FormatInt(reportid, 10)+"/tabulation", "tabulation")
|
||||
err := read(client, &t, "/v1/reports/"+strconv.FormatInt(reportid, 10)+"/tabulations", "tabulation")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ func SecurityHandler(r *http.Request, tx *Tx) ResponseWriterWriter {
|
||||
return ResponseWrapper{201, &security}
|
||||
} else if r.Method == "GET" {
|
||||
var securityid int64
|
||||
n, err := GetURLPieces(r.URL.Path, "/security/%d", &securityid)
|
||||
n, err := GetURLPieces(r.URL.Path, "/v1/securities/%d", &securityid)
|
||||
|
||||
if err != nil || n != 1 {
|
||||
//Return all securities
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
|
||||
func createSecurity(client *http.Client, security *handlers.Security) (*handlers.Security, error) {
|
||||
var s handlers.Security
|
||||
err := create(client, security, &s, "/security/", "security")
|
||||
err := create(client, security, &s, "/v1/securities/", "security")
|
||||
return &s, err
|
||||
}
|
||||
|
||||
func getSecurity(client *http.Client, securityid int64) (*handlers.Security, error) {
|
||||
var s handlers.Security
|
||||
err := read(client, &s, "/security/"+strconv.FormatInt(securityid, 10), "security")
|
||||
err := read(client, &s, "/v1/securities/"+strconv.FormatInt(securityid, 10), "security")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -24,7 +24,7 @@ func getSecurity(client *http.Client, securityid int64) (*handlers.Security, err
|
||||
|
||||
func getSecurities(client *http.Client) (*handlers.SecurityList, error) {
|
||||
var sl handlers.SecurityList
|
||||
err := read(client, &sl, "/security/", "securities")
|
||||
err := read(client, &sl, "/v1/securities/", "securities")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -33,7 +33,7 @@ func getSecurities(client *http.Client) (*handlers.SecurityList, error) {
|
||||
|
||||
func updateSecurity(client *http.Client, security *handlers.Security) (*handlers.Security, error) {
|
||||
var s handlers.Security
|
||||
err := update(client, security, &s, "/security/"+strconv.FormatInt(security.SecurityId, 10), "security")
|
||||
err := update(client, security, &s, "/v1/securities/"+strconv.FormatInt(security.SecurityId, 10), "security")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -41,7 +41,7 @@ func updateSecurity(client *http.Client, security *handlers.Security) (*handlers
|
||||
}
|
||||
|
||||
func deleteSecurity(client *http.Client, s *handlers.Security) error {
|
||||
err := remove(client, "/security/"+strconv.FormatInt(s.SecurityId, 10), "security")
|
||||
err := remove(client, "/v1/securities/"+strconv.FormatInt(s.SecurityId, 10), "security")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -90,7 +90,7 @@ func TestGetSecurity(t *testing.T) {
|
||||
t.Fatalf("Error fetching security: %s\n", err)
|
||||
}
|
||||
if s.SecurityId != curr.SecurityId {
|
||||
t.Errorf("SecurityId doesn't match")
|
||||
t.Errorf("SecurityId doesn't match %+v %+v", s, curr)
|
||||
}
|
||||
if s.Name != orig.Name {
|
||||
t.Errorf("Name doesn't match")
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
func TestSecurityTemplates(t *testing.T) {
|
||||
var sl handlers.SecurityList
|
||||
response, err := server.Client().Get(server.URL + "/securitytemplate/?search=USD&type=currency")
|
||||
response, err := server.Client().Get(server.URL + "/v1/securitytemplates/?search=USD&type=currency")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -45,7 +45,7 @@ func TestSecurityTemplates(t *testing.T) {
|
||||
|
||||
func TestSecurityTemplateLimit(t *testing.T) {
|
||||
var sl handlers.SecurityList
|
||||
response, err := server.Client().Get(server.URL + "/securitytemplate/?search=e&limit=5")
|
||||
response, err := server.Client().Get(server.URL + "/v1/securitytemplates/?search=e&limit=5")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -71,7 +71,7 @@ func TestSecurityTemplateLimit(t *testing.T) {
|
||||
|
||||
func TestSecurityTemplateInvalidType(t *testing.T) {
|
||||
var e handlers.Error
|
||||
response, err := server.Client().Get(server.URL + "/securitytemplate/?search=e&type=blah")
|
||||
response, err := server.Client().Get(server.URL + "/v1/securitytemplates/?search=e&type=blah")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -94,7 +94,7 @@ func TestSecurityTemplateInvalidType(t *testing.T) {
|
||||
|
||||
func TestSecurityTemplateInvalidLimit(t *testing.T) {
|
||||
var e handlers.Error
|
||||
response, err := server.Client().Get(server.URL + "/securitytemplate/?search=e&type=Currency&limit=foo")
|
||||
response, err := server.Client().Get(server.URL + "/v1/securitytemplates/?search=e&type=Currency&limit=foo")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -21,19 +21,19 @@ func newSession(user *User) (*http.Client, error) {
|
||||
client = *server.Client()
|
||||
client.Jar = jar
|
||||
|
||||
create(&client, user, &u, "/session/", "user")
|
||||
create(&client, user, &u, "/v1/sessions/", "user")
|
||||
|
||||
return &client, nil
|
||||
}
|
||||
|
||||
func getSession(client *http.Client) (*handlers.Session, error) {
|
||||
var s handlers.Session
|
||||
err := read(client, &s, "/session/", "session")
|
||||
err := read(client, &s, "/v1/sessions/", "session")
|
||||
return &s, err
|
||||
}
|
||||
|
||||
func deleteSession(client *http.Client) error {
|
||||
return remove(client, "/session/", "session")
|
||||
return remove(client, "/v1/sessions/", "session")
|
||||
}
|
||||
|
||||
func sessionExistsOrError(c *http.Client) error {
|
||||
|
@ -12,13 +12,13 @@ import (
|
||||
|
||||
func createTransaction(client *http.Client, transaction *handlers.Transaction) (*handlers.Transaction, error) {
|
||||
var s handlers.Transaction
|
||||
err := create(client, transaction, &s, "/transaction/", "transaction")
|
||||
err := create(client, transaction, &s, "/v1/transactions/", "transaction")
|
||||
return &s, err
|
||||
}
|
||||
|
||||
func getTransaction(client *http.Client, transactionid int64) (*handlers.Transaction, error) {
|
||||
var s handlers.Transaction
|
||||
err := read(client, &s, "/transaction/"+strconv.FormatInt(transactionid, 10), "transaction")
|
||||
err := read(client, &s, "/v1/transactions/"+strconv.FormatInt(transactionid, 10), "transaction")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -27,7 +27,7 @@ func getTransaction(client *http.Client, transactionid int64) (*handlers.Transac
|
||||
|
||||
func getTransactions(client *http.Client) (*handlers.TransactionList, error) {
|
||||
var tl handlers.TransactionList
|
||||
err := read(client, &tl, "/transaction/", "transactions")
|
||||
err := read(client, &tl, "/v1/transactions/", "transactions")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -38,7 +38,7 @@ func getAccountTransactions(client *http.Client, accountid, page, limit int64, s
|
||||
var atl handlers.AccountTransactionsList
|
||||
params := url.Values{}
|
||||
|
||||
query := fmt.Sprintf("/account/%d/transactions/", accountid)
|
||||
query := fmt.Sprintf("/v1/accounts/%d/transactions/", accountid)
|
||||
if page != 0 {
|
||||
params.Set("page", fmt.Sprintf("%d", page))
|
||||
}
|
||||
@ -59,7 +59,7 @@ func getAccountTransactions(client *http.Client, accountid, page, limit int64, s
|
||||
|
||||
func updateTransaction(client *http.Client, transaction *handlers.Transaction) (*handlers.Transaction, error) {
|
||||
var s handlers.Transaction
|
||||
err := update(client, transaction, &s, "/transaction/"+strconv.FormatInt(transaction.TransactionId, 10), "transaction")
|
||||
err := update(client, transaction, &s, "/v1/transactions/"+strconv.FormatInt(transaction.TransactionId, 10), "transaction")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -67,7 +67,7 @@ func updateTransaction(client *http.Client, transaction *handlers.Transaction) (
|
||||
}
|
||||
|
||||
func deleteTransaction(client *http.Client, s *handlers.Transaction) error {
|
||||
err := remove(client, "/transaction/"+strconv.FormatInt(s.TransactionId, 10), "transaction")
|
||||
err := remove(client, "/v1/transactions/"+strconv.FormatInt(s.TransactionId, 10), "transaction")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
|
||||
func createUser(user *User) (*User, error) {
|
||||
var u User
|
||||
err := create(server.Client(), user, &u, "/user/", "user")
|
||||
err := create(server.Client(), user, &u, "/v1/users/", "user")
|
||||
return &u, err
|
||||
}
|
||||
|
||||
func getUser(client *http.Client, userid int64) (*User, error) {
|
||||
var u User
|
||||
err := read(client, &u, "/user/"+strconv.FormatInt(userid, 10), "user")
|
||||
err := read(client, &u, "/v1/users/"+strconv.FormatInt(userid, 10), "user")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -24,7 +24,7 @@ func getUser(client *http.Client, userid int64) (*User, error) {
|
||||
|
||||
func updateUser(client *http.Client, user *User) (*User, error) {
|
||||
var u User
|
||||
err := update(client, user, &u, "/user/"+strconv.FormatInt(user.UserId, 10), "user")
|
||||
err := update(client, user, &u, "/v1/users/"+strconv.FormatInt(user.UserId, 10), "user")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -32,7 +32,7 @@ func updateUser(client *http.Client, user *User) (*User, error) {
|
||||
}
|
||||
|
||||
func deleteUser(client *http.Client, u *User) error {
|
||||
err := remove(client, "/user/"+strconv.FormatInt(u.UserId, 10), "user")
|
||||
err := remove(client, "/v1/users/"+strconv.FormatInt(u.UserId, 10), "user")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ function fetchAll() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "account/",
|
||||
url: "v1/accounts/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -100,7 +100,7 @@ function create(account) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "account/",
|
||||
url: "v1/accounts/",
|
||||
data: {account: account.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -127,7 +127,7 @@ function update(account) {
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: "json",
|
||||
url: "account/"+account.AccountId+"/",
|
||||
url: "v1/accounts/"+account.AccountId+"/",
|
||||
data: {account: account.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -154,7 +154,7 @@ function remove(account) {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
url: "account/"+account.AccountId+"/",
|
||||
url: "v1/accounts/"+account.AccountId+"/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
|
@ -59,7 +59,7 @@ function importOFX(account, password, startDate, endDate) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "account/"+account.AccountId+"/import/ofx",
|
||||
url: "v1/accounts/"+account.AccountId+"/imports/ofx",
|
||||
data: {ofxdownload: ofxdownload.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -145,12 +145,12 @@ function importFile(url, inputElement) {
|
||||
}
|
||||
|
||||
function importOFXFile(inputElement, account) {
|
||||
var url = "account/"+account.AccountId+"/import/ofxfile";
|
||||
var url = "v1/accounts/"+account.AccountId+"/imports/ofxfile";
|
||||
return importFile(url, inputElement);
|
||||
}
|
||||
|
||||
function importGnucash(inputElement) {
|
||||
var url = "import/gnucash";
|
||||
var url = "v1/imports/gnucash";
|
||||
return importFile(url, inputElement);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ function fetchAll() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "report/",
|
||||
url: "v1/reports/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -129,7 +129,7 @@ function create(report) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "report/",
|
||||
url: "v1/reports/",
|
||||
data: {report: report.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -156,7 +156,7 @@ function update(report) {
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: "json",
|
||||
url: "report/"+report.ReportId+"/",
|
||||
url: "v1/reports/"+report.ReportId+"/",
|
||||
data: {report: report.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -184,7 +184,7 @@ function remove(report) {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
url: "report/"+report.ReportId+"/",
|
||||
url: "v1/reports/"+report.ReportId+"/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -208,7 +208,7 @@ function tabulate(report) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "report/"+report.ReportId+"/tabulation/",
|
||||
url: "v1/reports/"+report.ReportId+"/tabulations/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
|
@ -72,7 +72,7 @@ function fetchAll() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "security/",
|
||||
url: "v1/securities/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -100,7 +100,7 @@ function create(security) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "security/",
|
||||
url: "v1/securities/",
|
||||
data: {security: security.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -127,7 +127,7 @@ function update(security) {
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: "json",
|
||||
url: "security/"+security.SecurityId+"/",
|
||||
url: "v1/securities/"+security.SecurityId+"/",
|
||||
data: {security: security.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -154,7 +154,7 @@ function remove(security) {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
url: "security/"+security.SecurityId+"/",
|
||||
url: "v1/securities/"+security.SecurityId+"/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
|
@ -47,7 +47,7 @@ function search(searchString, searchType, limit) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "securitytemplate/?search="+searchString+"&type="+searchType+"&limit="+limit,
|
||||
url: "v1/securitytemplates/?search="+searchString+"&type="+searchType+"&limit="+limit,
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -78,7 +78,7 @@ function fetchCurrencies() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "securitytemplate/?search=&type=currency",
|
||||
url: "v1/securitytemplates/?search=&type=currency",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
|
@ -90,7 +90,7 @@ function fetchPage(account, pageSize, page) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "account/"+account.AccountId+"/transactions?sort=date-desc&limit="+pageSize+"&page="+page,
|
||||
url: "v1/accounts/"+account.AccountId+"/transactions?sort=date-desc&limit="+pageSize+"&page="+page,
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -138,7 +138,7 @@ function create(transaction) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "transaction/",
|
||||
url: "v1/transactions/",
|
||||
data: {transaction: transaction.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -165,7 +165,7 @@ function update(transaction) {
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: "json",
|
||||
url: "transaction/"+transaction.TransactionId+"/",
|
||||
url: "v1/transactions/"+transaction.TransactionId+"/",
|
||||
data: {transaction: transaction.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -192,7 +192,7 @@ function remove(transaction) {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
url: "transaction/"+transaction.TransactionId+"/",
|
||||
url: "v1/transactions/"+transaction.TransactionId+"/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
|
@ -83,7 +83,7 @@ function fetch(userId) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "user/"+userId+"/",
|
||||
url: "v1/users/"+userId+"/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -115,7 +115,7 @@ function create(user) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "user/",
|
||||
url: "v1/users/",
|
||||
data: {user: user.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -142,7 +142,7 @@ function login(user) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "session/",
|
||||
url: "v1/sessions/",
|
||||
data: {user: user.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
@ -167,7 +167,7 @@ function tryResumingSession() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "session/",
|
||||
url: "v1/sessions/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -195,7 +195,7 @@ function logout() {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
url: "session/",
|
||||
url: "v1/sessions/",
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
e.fromJSON(data);
|
||||
@ -219,7 +219,7 @@ function update(user) {
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: "json",
|
||||
url: "user/"+user.UserId+"/",
|
||||
url: "v1/users/"+user.UserId+"/",
|
||||
data: {user: user.toJSON()},
|
||||
success: function(data, status, jqXHR) {
|
||||
var e = new Error();
|
||||
|
Loading…
Reference in New Issue
Block a user