Skip to content

Commit

Permalink
Feed type conversion method, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jun 8, 2021
1 parent 7e72346 commit bf1eaf0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion campaigns.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *Client) UpdateCampaign(campaign *Campaign) (response *StandardResponse,
// This will return an Error if no campaigns are found (404)
//
// For more information: https://docs.tonicpow.com/#b3fe69d3-24ba-4c2a-a485-affbb0a738de
func (c *Client) CampaignsFeed(feedType feedType) (feed string, response *StandardResponse, err error) {
func (c *Client) CampaignsFeed(feedType FeedType) (feed string, response *StandardResponse, err error) {

// Fire the Request
if response, err = c.Request(
Expand Down
6 changes: 3 additions & 3 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ func TestClient_GetUserAgent(t *testing.T) {
// See more examples in /examples/
func ExampleVersion() {
fmt.Printf("version: %s", Version())
// Output:version: v0.6.2
// Output:version: v0.6.3
}

// ExampleUserAgent example using UserAgent()
//
// See more examples in /examples/
func ExampleUserAgent() {
fmt.Printf("user agent: %s", UserAgent())
// Output:user agent: go-tonicpow: v0.6.2
// Output:user agent: go-tonicpow: v0.6.3
}

// TestClient_GetEnvironment will test the method GetEnvironment()
Expand All @@ -191,7 +191,7 @@ func ExampleNewClient() {
return
}
fmt.Printf("loaded client: %s", client.options.userAgent)
// Output:loaded client: go-tonicpow: v0.6.2
// Output:loaded client: go-tonicpow: v0.6.3
}

// BenchmarkNewClient benchmarks the method NewClient()
Expand Down
12 changes: 6 additions & 6 deletions definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
defaultHTTPTimeout = 10 * time.Second // Default timeout for all GET requests in seconds
defaultRetryCount int = 2 // Default retry count for HTTP requests
defaultUserAgent = "go-tonicpow: " + version // Default user agent
version string = "v0.6.2" // go-tonicpow version
version string = "v0.6.3" // go-tonicpow version

// Field key names for various model requests
fieldAdvertiserProfileID = "advertiser_profile_id"
Expand Down Expand Up @@ -80,13 +80,13 @@ const (
SortOrderDesc string = "desc"

// FeedTypeAtom is for using the feed type: Atom
FeedTypeAtom feedType = "atom"
FeedTypeAtom FeedType = "atom"

// FeedTypeJSON is for using the feed type: JSON
FeedTypeJSON feedType = "json"
FeedTypeJSON FeedType = "json"

// FeedTypeRSS is for using the feed type: RSS
FeedTypeRSS feedType = "rss"
FeedTypeRSS FeedType = "rss"
)

var (
Expand All @@ -107,8 +107,8 @@ var (
}
)

// feedType is used for the campaign feeds (rss, atom, json)
type feedType string
// FeedType is used for the campaign feeds (rss, atom, json)
type FeedType string

// environment is used for changing the environment for running client requests
type environment struct {
Expand Down
14 changes: 13 additions & 1 deletion tonicpow.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ func Version() string {
return version
}

// UserAgent will return the default user agent string
// UserAgent will return the default user-agent string
func UserAgent() string {
return defaultUserAgent
}

// GetFeedType will return the feed type based on the provided string
func GetFeedType(feedType string) FeedType {
switch feedType {
case "atom":
return FeedTypeAtom
case "json":
return FeedTypeJSON
default:
return FeedTypeRSS
}
}
10 changes: 10 additions & 0 deletions tonicpow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ func TestUserAgent(t *testing.T) {
})
}

// TestGetFeedType will test the method GetFeedType()
func TestGetFeedType(t *testing.T) {
t.Run("test valid cases", func(t *testing.T) {
assert.Equal(t, FeedTypeRSS, GetFeedType("rss"))
assert.Equal(t, FeedTypeJSON, GetFeedType("json"))
assert.Equal(t, FeedTypeAtom, GetFeedType("atom"))
assert.Equal(t, FeedTypeRSS, GetFeedType(""))
})
}

// mockResponseData is used for mocking the response
func mockResponseData(method, endpoint string, statusCode int, model interface{}) error {
httpmock.Reset()
Expand Down

0 comments on commit bf1eaf0

Please sign in to comment.