Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

PlayerCSVExportOptions added: extra_fields, last_active_since #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 2 additions & 4 deletions onesignal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ func TestNewRequest_userKeyType(t *testing.T) {
func TestNewRequest_invalidJSON(t *testing.T) {
c := NewClient(nil)

type T struct {
A map[int]interface{}
}
_, err := c.NewRequest("GET", "/", &T{}, APP)
inBody := make(chan int)
_, err := c.NewRequest("GET", "/", inBody, APP)

if err == nil {
t.Error("Expected error to be returned.")
Expand Down
6 changes: 4 additions & 2 deletions players.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Player struct {
// PlayerRequest represents a request to create/update a player.
type PlayerRequest struct {
AppID string `json:"app_id"`
DeviceType int `json:"device_type"`
DeviceType int `json:"device_type,omitempty"`
Identifier string `json:"identifier,omitempty"`
Language string `json:"language,omitempty"`
Timezone int `json:"timezone,omitempty"`
Expand Down Expand Up @@ -119,7 +119,9 @@ type PlayerOnFocusOptions struct {
// PlayerCSVExportOptions specifies the parameters to the
// PlayersService.CSVExport method
type PlayerCSVExportOptions struct {
AppID string `json:"app_id"`
AppID string `json:"app_id"`
ExtraFields interface{} `json:"extra_fields,omitempty"`
LastActiveSince int64 `json:"last_active_since,omitempty"`
}

// PlayerCSVExportResponse wraps the standard http.Response for the
Expand Down
5 changes: 4 additions & 1 deletion players_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"reflect"
"strconv"
"testing"
"time"

"github.com/tbalthazar/onesignal-go/testhelper"
)
Expand Down Expand Up @@ -377,7 +378,9 @@ func TestPlayersService_CSVExport(t *testing.T) {
defer teardown()

opt := &PlayerCSVExportOptions{
AppID: "id123",
AppID: "id123",
ExtraFields: []string{},
LastActiveSince: time.Now().Unix(),
}

mux.HandleFunc("/players/csv_export", func(w http.ResponseWriter, r *http.Request) {
Expand Down