--- a/gondole.go Wed Apr 05 22:03:09 2017 +0200
+++ b/gondole.go Thu Apr 06 23:31:31 2017 +0200
@@ -1,17 +1,40 @@
package gondole
import ()
+import (
+ "github.com/sendgrid/rest"
+ "fmt"
+)
const (
- Version = "0.0"
+ APIVersion = "0.0"
APIEndpoint = "/api/v1"
+
+ NoRedirect = "urn:ietf:wg:oauth:2.0:oob"
)
-func NewApp(name, redirectURI string) (g *Gondole, err error) {
- g = &Gondole{
- Name: name,
- RedirectURI: redirectURI,
+// prepareRequest insert all pre-defined stuff
+func (g *Gondole) prepareRequest(what string) (req rest.Request) {
+ endPoint := APIEndpoint + fmt.Sprintf("/%s/", what)
+ key, ok := HasAPIKey()
+
+ // Add at least one option, the APIkey if present
+ hdrs := make(map[string]string)
+ opts := make(map[string]string)
+
+ // Insert our sig
+ hdrs["User-Agent"] = fmt.Sprintf("Gondole/%s", APIVersion)
+
+ // Insert key
+ if ok {
+ opts["key"] = key
+ }
+
+ req = rest.Request{
+ BaseURL: endPoint,
+ Headers: hdrs,
+ QueryParams: opts,
}
return
}