This pull request is to make the entire API more idiomatic. Unfortunately, this refactor is not backwards compatible.
Here is a brief summary of some of the changes made:
Functional options to NewClient(); not providing any ClientOption functions will cause NewClient() to return an ErrNoAPIKey.
API keys can be provided either explicitly, or by searching environment variables.
Fixed the (*Timestamp).UnmarshalJSON() method so that it can actually parse the time stamps present when retrieving subscribed pulses. Prior to this, it wasn't being used anywhere, probably because it wasn't able to parse the various time formats (most of the observed time stamps, in the feed, are not RFC3339-formatted).
Unexported symbols that needn't be exported.
Removed some unnecessary uses of the reflect package.
Removed the OTXThreatIntelFeedService in favour of adding a List method to the OTXPulseDetailService type.
The PulseList type returned by (*OTXPulseDetailService).List() has two convenience functions — NextPageOptions and PrevPageOptions — that return populated *ListOption values, that can be passed to further invocations of (*OTXPulseDetailService).List().
Added examples for the ClientOption functional options that will show up in GoDoc.
Updated the code in example/main.go to show use of the new API.
Moved all package code into the top-level directory, resulting the the top-level package being go get-able.
This pull request is to make the entire API more idiomatic. Unfortunately, this refactor is not backwards compatible.
Here is a brief summary of some of the changes made:
NewClient()
; not providing anyClientOption
functions will causeNewClient()
to return anErrNoAPIKey
.(*Timestamp).UnmarshalJSON()
method so that it can actually parse the time stamps present when retrieving subscribed pulses. Prior to this, it wasn't being used anywhere, probably because it wasn't able to parse the various time formats (most of the observed time stamps, in the feed, are not RFC3339-formatted).reflect
package.OTXThreatIntelFeedService
in favour of adding aList
method to theOTXPulseDetailService
type.PulseList
type returned by(*OTXPulseDetailService).List()
has two convenience functions —NextPageOptions
andPrevPageOptions
— that return populated*ListOption
values, that can be passed to further invocations of(*OTXPulseDetailService).List()
.ClientOption
functional options that will show up in GoDoc.example/main.go
to show use of the new API.go get
-able.