-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
97 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: go | ||
|
||
go: | ||
- 1.12.4 | ||
- 1.13 | ||
|
||
install: | ||
- go get -v newreleases.io/newreleases/... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2019, NewReleases Go client AUTHORS. | ||
// All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package newreleases | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
) | ||
|
||
// DiscordChannelsService provides information about Discord notifications. | ||
type DiscordChannelsService service | ||
|
||
// DiscordChannel holds information about a Discord Channel that is connected to the | ||
// account. | ||
type DiscordChannel struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
} | ||
|
||
// List returns all connected Discord Channels. | ||
func (s *DiscordChannelsService) List(ctx context.Context) (channels []DiscordChannel, err error) { | ||
|
||
type discordChannelsResponse struct { | ||
Channels []DiscordChannel `json:"channels"` | ||
} | ||
|
||
var r discordChannelsResponse | ||
err = s.client.request(ctx, http.MethodGet, "v1/discord-channels", nil, &r) | ||
return r.Channels, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2019, NewReleases Go client AUTHORS. | ||
// All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package newreleases_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
"newreleases.io/newreleases" | ||
) | ||
|
||
func TestDiscordChannelsService_List(t *testing.T) { | ||
client, mux, _, teardown := newClient(t, "") | ||
defer teardown() | ||
|
||
mux.HandleFunc("/v1/discord-channels", requireMethod("GET", func(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Content-Type", jsonContentType) | ||
fmt.Fprintln(w, discordChannelsServiceList) | ||
})) | ||
|
||
got, err := client.DiscordChannels.List(context.Background()) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assertEqual(t, "", got, discordChannelsServiceListWant) | ||
} | ||
|
||
var ( | ||
discordChannelsServiceList = ` | ||
{ | ||
"channels": [ | ||
{ | ||
"id": "02bgrl5510q3pe8gf7322d8n5", | ||
"name": "NewReleases Yeah" | ||
} | ||
] | ||
} | ||
` | ||
discordChannelsServiceListWant = []newreleases.DiscordChannel{ | ||
{ | ||
ID: "02bgrl5510q3pe8gf7322d8n5", | ||
Name: "NewReleases Yeah", | ||
}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters