Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Campaigns for Apps endpoints #1

Merged
merged 3 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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