Skip to content

Update client to support latest API behaviors / data; v0.5.0#7

Merged
theckman merged 1 commit intomasterfrom
fix_api_support
Feb 28, 2019
Merged

Update client to support latest API behaviors / data; v0.5.0#7
theckman merged 1 commit intomasterfrom
fix_api_support

Conversation

@theckman
Copy link
Copy Markdown
Collaborator

This change updates the package so that it continues to work with the ipdata.co
API. This also introduces breaking changes in the interest of simplifying the
code and reducing the API surface area.

There were some changes made to the dara structure returned over the JSON API
from ipdata.co, as well as how the authentication credentials are provided to
the API itself. This change primarily was executed to support the new format and
authentication mechanism.

Specifically, some string fields were converted to Objects within the ipdata.co
API to provide more rich data. Things like the timezone, the currency, and the
risk/threats associated with that IP. The API also stopped accepted
authentication tokens via HTTP headers, and now requires them via URL query
parameters.

In addition to that, the idea of using one struct type for the JSON
communication and another for consumers of this package to use has been
backed-out. The original implementation used a RawIP struct for communication
to JSON, and then would convert it to an IP struct while doing things like
parsing timestamps in to time.Time, timezones in to *time.Location, and
converting URLs to *url.URL.

Instead of assuming everyone would want the URL to be a *url.URL, or that they
really need to parse the timestamp, we now only deal with the serialization and
deserialization from the API. We leave it up to consumers to parse the data in
to a different type if they choose to do so.

So the IP struct was removed, and the RawIP struct was renamed to IP.
Also, all of the RawXXX functions and methods were removed.

Signed-off-by: Tim Heckman t@heckman.io

@theckman theckman force-pushed the fix_api_support branch 4 times, most recently from 4081ca8 to cea6c49 Compare February 28, 2019 17:01
This change updates the package so that it continues to work with the ipdata.co
API. This also introduces breaking changes in the interest of simplifying the
code and reducing the API surface area.

There were some changes made to the dara structure returned over the JSON API
from ipdata.co, as well as how the authentication credentials are provided to
the API itself. This change primarily was executed to support the new format and
authentication mechanism.

Specifically, some string fields were converted to Objects within the ipdata.co
API to provide more rich data. Things like the timezone, the currency, and the
risk/threats associated with that IP. The API also stopped accepted
authentication tokens via HTTP headers, and now requires them via URL query
parameters.

In addition to that, the idea of using one struct type for the JSON
communication and another for consumers of this package to use has been
backed-out. The original implementation used a `RawIP` struct for communication
to JSON, and then would convert it to an `IP` struct while doing things like
parsing timestamps in to `time.Time`, timezones in to `*time.Location`, and
converting URLs to `*url.URL`.

Instead of assuming everyone would want the URL to be a `*url.URL`, or that they
really need to parse the timestamp, we now only deal with the serialization and
deserialization from the API. We leave it up to consumers to parse the data in
to a different type if they choose to do so.

So the `IP` struct was removed, and the `RawIP` struct was renamed to `IP`.
Also, all of the `RawXXX` functions and methods were removed.

Signed-off-by: Tim Heckman <t@heckman.io>
@theckman theckman merged commit b14899b into master Feb 28, 2019
theckman added a commit that referenced this pull request Feb 28, 2019
Update client to support latest API behaviors / data; v0.5.0

Signed-off-by: Tim Heckman <t@heckman.io>
@theckman theckman deleted the fix_api_support branch October 28, 2019 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant