Skip to content

Commit

Permalink
Merge pull request #1 from usabilla/add-campaigns-for-apps
Browse files Browse the repository at this point in the history
Add Campaigns for Apps endpoints
  • Loading branch information
Teun Zengerink authored Jan 5, 2018
2 parents 3e45e5d + 825fc02 commit 9dca7dd
Show file tree
Hide file tree
Showing 18 changed files with 281 additions and 96 deletions.
1 change: 0 additions & 1 deletion .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 Usabilla
Copyright (c) 2018 Usabilla

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Gobilla
# Usabilla

Gobilla is a Go client for [Usabilla API](https://usabilla.com/api).
This is a Go client for [Usabilla API](https://usabilla.com/api).

[![Build Status](https://travis-ci.org/usabilla/gobilla.svg?branch=master)](https://travis-ci.org/usabilla/gobilla)
[![GoDoc](http://godoc.org/github.com/usabilla/gobilla?status.svg)](http://godoc.org/github.com/usabilla/gobilla)
[![CircleCI](https://circleci.com/gh/usabilla/api-go.svg?style=svg)](https://circleci.com/gh/usabilla/api-go)
[![GoDoc](http://godoc.org/github.com/usabilla/api-go?status.svg)](http://godoc.org/github.com/usabilla/api-go)

## Getting Started

Expand All @@ -16,22 +16,22 @@ import (
"os"
"fmt"

"github.com/usabilla/gobilla"
"github.com/usabilla/api-go"
)

func main() {
key := os.Getenv("USABILLA_API_KEY")
secret := os.Getenv("USABILLA_API_SECRET")

// Pass the key and secret which should be defined as ENV vars
gb := gobilla.New(key, secret)
b := gb.Buttons()
usabilla := usabilla.New(key, secret)

resource := usabilla.Buttons()

// Get the first ten buttons
params := map[string]string{"limit": "10"}
buttons, _ := b.Get(params)
buttons, _ := resource.Get(params)

// Print all feedback items for each button
for _, button := range buttons.Items {
feedback, _ := b.Feedback().Get(button.ID, nil)
Expand All @@ -40,13 +40,13 @@ func main() {
}
```

Then install Gobilla package
Then install usabilla package

go get github.com/usabilla/gobilla
go get github.com/usabilla/api-go

Run the file

go run main.go
go run main.go

And you will get all feedback items for each button.

Expand Down
4 changes: 2 additions & 2 deletions auth.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 Usabilla
Copyright (c) 2018 Usabilla
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
Expand All @@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/

package gobilla
package usabilla

import "fmt"

Expand Down
6 changes: 3 additions & 3 deletions auth_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 Usabilla
Copyright (c) 2018 Usabilla
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
Expand All @@ -21,12 +21,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/

package gobilla
package usabilla

import (
"testing"

"github.com/usabilla/gobilla/internal"
"github.com/usabilla/api-go/internal"
)

var testData = map[string]string{
Expand Down
4 changes: 2 additions & 2 deletions date.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 Usabilla
Copyright (c) 2018 Usabilla
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
Expand All @@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/

package gobilla
package usabilla

import (
"time"
Expand Down
6 changes: 3 additions & 3 deletions date_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 Usabilla
Copyright (c) 2018 Usabilla
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
Expand All @@ -21,13 +21,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/

package gobilla
package usabilla

import (
"testing"
"time"

"github.com/usabilla/gobilla/internal"
"github.com/usabilla/api-go/internal"
)

var (
Expand Down
40 changes: 32 additions & 8 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"os"

"github.com/usabilla/gobilla"
"github.com/usabilla/api-go"
)

func buttons(gb *gobilla.Gobilla) {
b := gb.Buttons()
func buttons(usabilla *usabilla.Usabilla) {
b := usabilla.Buttons()

buttons, err := b.Get(nil)
if err != nil {
Expand All @@ -31,8 +31,8 @@ func buttons(gb *gobilla.Gobilla) {
fmt.Printf("RECEIVED FEEDBACK FROM %d BUTTONS\n", buttons.Count)
}

func buttonsIterator(gb *gobilla.Gobilla) {
b := gb.Buttons()
func buttonsIterator(usabilla *usabilla.Usabilla) {
b := usabilla.Buttons()

buttons, err := b.Get(nil)
if err != nil {
Expand All @@ -51,19 +51,43 @@ func buttonsIterator(gb *gobilla.Gobilla) {
fmt.Printf("RECEIVED FEEDBACK FROM %d BUTTONS\n", buttons.Count)
}

func appCampaigns(usabilla *usabilla.Usabilla) {
resource := usabilla.AppCampaigns()

campaigns, err := resource.Get(nil)
if err != nil {
fmt.Errorf("%s", err)
}

for _, campaign := range campaigns.Items {
count := 0
fmt.Printf("START PRINTING RESULTS FOR CAMPAIGN: %s\n", campaign.ID)
for result := range resource.Results().Iterate(campaign.ID, nil) {
fmt.Printf("Result %s\n", result.ID)
count++
}
fmt.Printf("Received %d results\n", count)
}

fmt.Printf("FOUND %d CAMPAIGNS IN TOTAL\n", campaigns.Count)
}

func main() {
key := os.Getenv("USABILLA_API_KEY")
secret := os.Getenv("USABILLA_API_SECRET")

// You can pass a custom http.Client
// We pass nil to use the http.DefaultClient
gb := gobilla.New(key, secret, nil)
usabilla := usabilla.New(key, secret, nil)

// Uses a simple GET to get all feedback items for all buttons.
buttons(gb)
buttons(usabilla)

// Uses a channel of feedback items, and once all items have been
// consumed and the response HasMore then it fires a new request
// for all feedback items for all buttons.
buttonsIterator(gb)
buttonsIterator(usabilla)

// Display App campaigns and their results
appCampaigns(usabilla)
}
Loading

0 comments on commit 9dca7dd

Please sign in to comment.