Skip to content

Commit a9bba7d

Browse files
committed
Rename package to
1 parent 525cb9e commit a9bba7d

20 files changed

+70
-104
lines changed

Makefile

-48
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Go library to access GoCardless API. This library provides a simple wrapper arou
1212
## Getting started
1313

1414
```
15-
go get 'https://github.com/saopayne/gocardless-pro-go'
15+
go get github.com/saopayne/gocardless
1616
```
1717

1818
## Initializing the client

Usage.md

+10
Original file line numberDiff line numberDiff line change
@@ -582,4 +582,14 @@ if err != nil {
582582
fmt.Sprintf("The error while canceling a subscription is :%s", err.Error())
583583
}
584584
fmt.Sprintf("The subscription canceled returned the response: %s ", subToCancel)
585+
586+
//list all subscriptions
587+
subscriptionsListReq := &SubscriptionListRequest{
588+
Limit: 100,
589+
}
590+
// list all subscriptions
591+
_, err := client.Subscription.ListSubscriptions(subscriptionsListReq)
592+
if err != nil {
593+
fmt.Sprintf("The error while getting list of subscriptions is :%s", err.Error())
594+
}
585595
```

bank_details_lookup.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"fmt"

creditor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"

creditor_bank_account.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"fmt"

customer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"

customer_bank_account.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"

doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
package main
1+
package gocardless

error.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"fmt"

event.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"fmt"

gocardless.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"bytes"
@@ -28,26 +28,26 @@ const (
2828
acceptJsonType = "application/json"
2929
)
3030

31-
func main() {
32-
33-
apiKey := "sandbox_o55p5OowBX59Rd8aDR7c_25LQdBTHRaACeVnqj0o"
34-
35-
//second param is an optional http client, allowing overriding of the HTTP client to use.
36-
//This is useful if you're running in a Google AppEngine environment
37-
//where the http.DefaultClient is not available.
38-
client := NewClient(apiKey, nil)
39-
client.LoggingEnabled = true
40-
41-
payoutsListReq := &PayoutListRequest{
42-
Limit: 100,
43-
}
44-
// list all payouts
45-
_, err := client.Payout.ListPayouts(payoutsListReq)
46-
if err != nil {
47-
fmt.Sprintf("The error while getting list of payouts is :%s", err.Error())
48-
}
49-
50-
}
31+
//func main() {
32+
//
33+
// apiKey := "sandbox_o55p5OowBX59Rd8aDR7c_25LQdBTHRaACeVnqj0o"
34+
//
35+
// //second param is an optional http client, allowing overriding of the HTTP client to use.
36+
// //This is useful if you're running in a Google AppEngine environment
37+
// //where the http.DefaultClient is not available.
38+
// client := NewClient(apiKey, nil)
39+
// client.LoggingEnabled = true
40+
//
41+
// subscriptionsListReq := &SubscriptionListRequest{
42+
// Limit: 100,
43+
// }
44+
// // list all subscriptions
45+
// _, err := client.Subscription.ListSubscriptions(subscriptionsListReq)
46+
// if err != nil {
47+
// fmt.Sprintf("The error while getting list of subscriptions is :%s", err.Error())
48+
// }
49+
//
50+
//}
5151

5252
type service struct {
5353
client *Client

link.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
type CreditorLink struct {
44
Creditor string `json:"creditor,omitempty"`

mandate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"

mandate_pdf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"

payment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"

payout.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"fmt"

redirect_flow.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"fmt"

refund.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"

subscription.go

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
package main
1+
package gocardless
22

33
import (
44
"encoding/json"
55
"fmt"
6-
"net/url"
6+
"log"
7+
"net/http"
8+
"os"
79
)
810

911
type SubscriptionService service
@@ -92,24 +94,26 @@ func (s *SubscriptionService) CreateSubscription(subscriptionReq *SubscriptionCr
9294

9395
// List returns a list of subscriptions
9496
func (s *SubscriptionService) ListSubscriptions(req *SubscriptionListRequest) (*SubscriptionList, error) {
95-
return s.ListNSubscriptions(10, 0, req)
96-
}
97-
98-
func (s *SubscriptionService) ListNSubscriptions(count, offset int, req *SubscriptionListRequest) (*SubscriptionList, error) {
99-
params := url.Values{}
100-
params.Add("after", req.After)
101-
params.Add("before", req.Before)
102-
params.Add("created_at[gt]", req.CreatedAt.Gt)
103-
params.Add("created_at[gte]", req.CreatedAt.Gte)
104-
params.Add("created_at[lt]", req.CreatedAt.Lt)
105-
params.Add("created_at[lte]", req.CreatedAt.Lte)
106-
params.Add("limit", string(req.Limit))
107-
params.Add("mandate", req.Mandate)
108-
params.Add("customer", req.Customer)
109-
110-
u := paginateURL("/subscriptions", count, offset)
97+
reqd, err := http.NewRequest("GET", "/subscriptions", nil)
98+
if err != nil {
99+
log.Print(err)
100+
os.Exit(1)
101+
}
102+
params := reqd.URL.Query()
103+
if req.After != "" { params.Add("after", req.After) }
104+
if req.Before != "" { params.Add("before", req.Before) }
105+
if req.CreatedAt.Gt != "" { params.Add("created_at[gt]", req.CreatedAt.Gt) }
106+
if req.CreatedAt.Gte != "" { params.Add("created_at[gte]", req.CreatedAt.Gte) }
107+
if req.CreatedAt.Lt != "" { params.Add("created_at[lt]", req.CreatedAt.Lt) }
108+
if req.CreatedAt.Lte != "" { params.Add("created_at[lte]", req.CreatedAt.Lte) }
109+
if req.Limit > 0 { params.Add("limit", string(req.Limit)) }
110+
if req.Mandate != "" { params.Add("mandate", req.Mandate) }
111+
if req.Customer != "" { params.Add("customer", req.Customer) }
112+
113+
reqd.URL.RawQuery = params.Encode()
114+
path := reqd.URL.String()
111115
subscriptions := &SubscriptionList{}
112-
err := s.client.Call("GET", u, params, subscriptions)
116+
err = s.client.Call("GET", path, nil, subscriptions)
113117

114118
return subscriptions, err
115119
}

0 commit comments

Comments
 (0)