1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-02 20:28:38 -04:00

Stop using form elements for API

Just send the JSON as the request body
This commit is contained in:
2017-11-13 20:48:19 -05:00
parent 9624f0c5bc
commit 5a6be5a07b
23 changed files with 87 additions and 159 deletions

View File

@ -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, "/v1/prices/", "price")
err := create(client, price, &p, "/v1/prices/")
return &p, err
}
func getPrice(client *http.Client, priceid int64) (*handlers.Price, error) {
var p handlers.Price
err := read(client, &p, "/v1/prices/"+strconv.FormatInt(priceid, 10), "price")
err := read(client, &p, "/v1/prices/"+strconv.FormatInt(priceid, 10))
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, "/v1/prices/", "prices")
err := read(client, &pl, "/v1/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, "/v1/prices/"+strconv.FormatInt(price.PriceId, 10), "price")
err := update(client, price, &p, "/v1/prices/"+strconv.FormatInt(price.PriceId, 10))
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, "/v1/prices/"+strconv.FormatInt(p.PriceId, 10), "price")
err := remove(client, "/v1/prices/"+strconv.FormatInt(p.PriceId, 10))
if err != nil {
return err
}