Skip to content

Commit

Permalink
v1.0.1: Add new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipeMata committed Jan 8, 2018
1 parent 162902b commit 93a48a1
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions _examples/subscription/create_subscription_history.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
25 changes: 25 additions & 0 deletions _examples/subscription/update_plan.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 1 addition & 1 deletion gerencianet/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gerencianet

var Version = "1.0.0"
var Version = "1.0.1"

const (
UrlSandbox = "https://sandbox.gerencianet.com.br/v1"
Expand Down
10 changes: 10 additions & 0 deletions gerencianet/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions gerencianet/endpoints_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit 93a48a1

Please sign in to comment.