From 93a48a1985a5b26c2688c265307171579172f236 Mon Sep 17 00:00:00 2001 From: Filipe Santos Date: Mon, 8 Jan 2018 10:11:54 -0200 Subject: [PATCH] v1.0.1: Add new endpoints --- CHANGELOG.md | 6 +++++ .../create_subscription_history.go | 25 +++++++++++++++++++ _examples/subscription/update_plan.go | 25 +++++++++++++++++++ gerencianet/constants.go | 2 +- gerencianet/endpoints.go | 10 ++++++++ gerencianet/endpoints_internal_test.go | 2 ++ 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100755 _examples/subscription/create_subscription_history.go create mode 100755 _examples/subscription/update_plan.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 02cf0a9..aaccf57 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.0.1 + +- Added: new endpoint (update plan) +- Added: new endpoint (create subscription history) +- Updated: examples + # 1.0.0 - Initial release diff --git a/_examples/subscription/create_subscription_history.go b/_examples/subscription/create_subscription_history.go new file mode 100755 index 0000000..021505b --- /dev/null +++ b/_examples/subscription/create_subscription_history.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/gerencianet/gn-api-sdk-go/gerencianet" + "github.com/gerencianet/gn-api-sdk-go/_examples/configs" +) + +func main(){ + + credentials := configs.Credentials + gn := gerencianet.NewGerencianet(credentials) + + body := map[string]interface{} { + "description": "This subscription was not fully paid", + } + + res, err := gn.CreateSubscriptionHistory(13100, body) // no lugar do 1 coloque o subscription_id certo + + if err != nil { + fmt.Println(err) + } else { + fmt.Println(res) + } +} \ No newline at end of file diff --git a/_examples/subscription/update_plan.go b/_examples/subscription/update_plan.go new file mode 100755 index 0000000..b5f8f1a --- /dev/null +++ b/_examples/subscription/update_plan.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/gerencianet/gn-api-sdk-go/gerencianet" + "github.com/gerencianet/gn-api-sdk-go/_examples/configs" +) + +func main(){ + + credentials := configs.Credentials + gn := gerencianet.NewGerencianet(credentials) + + body := map[string]interface{} { + "name": "My new plan", + } + + res, err := gn.UpdatePlan(1, body) // no lugar do 1 coloque o plan_id certo + + if err != nil { + fmt.Println(err) + } else { + fmt.Println(res) + } +} \ No newline at end of file diff --git a/gerencianet/constants.go b/gerencianet/constants.go index 124fea3..0786c11 100755 --- a/gerencianet/constants.go +++ b/gerencianet/constants.go @@ -1,6 +1,6 @@ package gerencianet -var Version = "1.0.0" +var Version = "1.0.1" const ( UrlSandbox = "https://sandbox.gerencianet.com.br/v1" diff --git a/gerencianet/endpoints.go b/gerencianet/endpoints.go index 7bf1f77..c407e8b 100755 --- a/gerencianet/endpoints.go +++ b/gerencianet/endpoints.go @@ -163,4 +163,14 @@ func (endpoints endpoints) ChargeLink(chargeID int, body map[string]interface{}) func (endpoints endpoints) UpdateChargeLink(chargeID int, body map[string]interface{}) (string, error) { params := map[string]string{ "id": strconv.Itoa(chargeID) } return endpoints.requester.request("/charge/:id/link", "PUT", params, body) +} + +func (endpoints endpoints) CreateSubscriptionHistory(subscriptionID int, body map[string]interface{}) (string, error) { + params := map[string]string{ "id": strconv.Itoa(subscriptionID) } + return endpoints.requester.request("/subscription/:id/history", "POST", params, body) +} + +func (endpoints endpoints) UpdatePlan(planID int, body map[string]interface{}) (string, error) { + params := map[string]string{ "id": strconv.Itoa(planID) } + return endpoints.requester.request("/plan/:id", "PUT", params, body) } \ No newline at end of file diff --git a/gerencianet/endpoints_internal_test.go b/gerencianet/endpoints_internal_test.go index deb53b5..40642bd 100755 --- a/gerencianet/endpoints_internal_test.go +++ b/gerencianet/endpoints_internal_test.go @@ -42,5 +42,7 @@ func Test_endpoints(t *testing.T) { endpoints.CancelParcel(1, 1) endpoints.ChargeLink(1, nil) endpoints.UpdateChargeLink(1, nil) + endpoints.UpdatePlan(1, nil) + endpoints.CreateSubscriptionHistory(1, nil) t.Skip("skipping endpoints tests") } \ No newline at end of file