-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from rosette-api/DEVOPS-247-address-similarity
Add /address-similarity
- Loading branch information
Showing
14 changed files
with
373 additions
and
186 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 |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
/tmp/ | ||
Gemfile.lock | ||
|
||
# Jetbrains | ||
**/.idea/* | ||
|
||
## Specific to RubyMotion: | ||
.dat* | ||
.repl_history | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
Ruby Examples | ||
============ | ||
Each example class can be run independently. | ||
## Endpoint Examples | ||
|
||
Each example file demonstrates one of the capabilities of the Rosette Platform. | ||
These examples are scripts that can be run independently to demonstrate the Rosette API functionality. | ||
|
||
A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolchain also supports it. | ||
|
||
## Running the example | ||
You can run your desired `_endpoint_.rb` file to see it in action. | ||
Each example file demonstrates one of the capabilities of the Rosette Platform. Each example, when run, prints its output to the console. | ||
|
||
`ruby _endpoint_.rb api_key(required) alternate_url(optional)` | ||
Here are some methods for running the examples. Each example will also accept an optional parameter for | ||
overriding the default URL. To use, place the url parameter after the key parameter. | ||
|
||
For example, run `ruby categories.js <your_key>` if you want to see the categories | ||
functionality demonstrated. | ||
A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolchain also supports it. | ||
|
||
All files require you to input your Rosette API User Key after `--key` to run. | ||
For example: `ruby ping.js 1234567890` | ||
#### Docker/Latest Version From RubyGems | ||
``` | ||
git clone [email protected]:rosette-api/ruby.git | ||
cd ruby | ||
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch | ||
To run all of the examples: | ||
`find -maxdepth 1 -name *.rb -exec ruby {} api_key alternate_url` | ||
gem install rosette_api | ||
Each example, when run, prints its output to the console. | ||
cd /source/examples | ||
ruby ping.rb $API_KEY | ||
``` | ||
|
||
## Docker ## | ||
A Docker image for running the examples against the compiled source library is available on Docker Hub. | ||
#### Docker/Latest Source | ||
``` | ||
git clone [email protected]:rosette-api/ruby.git | ||
cd ruby | ||
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch | ||
Command: `docker run -e API_KEY=api-key -v "<binding root directory>:/source" rosetteapi/docker-ruby` | ||
cd /source | ||
gem build rosette_api.gemspec | ||
gem install rosette_api*.gem | ||
Additional environment settings: | ||
`-e ALT_URL=<alternative URL>` | ||
`-e FILENAME=<single filename>` | ||
cd examples | ||
ruby ping.rb $API_KEY | ||
``` |
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rosette_api' | ||
|
||
api_key, url = ARGV | ||
|
||
rosette_api = if url | ||
RosetteAPI.new(api_key, url) | ||
else | ||
RosetteAPI.new(api_key) | ||
end | ||
|
||
begin | ||
address1 = AddressParameter.new( | ||
house_number: '1600', | ||
road: 'Pennsylvania Ave NW', | ||
city: 'Washington', | ||
state: 'DC', | ||
post_code: '20500' | ||
) | ||
address2 = AddressParameter.new( | ||
house_number: '160', | ||
road: 'Pennsilvana Avenue', | ||
city: 'Washington', | ||
state: 'D.C.', | ||
post_code: '20500' | ||
) | ||
params = AddressSimilarityParameters.new(address1, address2) | ||
response = rosette_api.get_address_similarity(params) | ||
puts JSON.pretty_generate(response) | ||
rescue RosetteAPIError => e | ||
printf('Rosette API Error (%<status_code>s): %<message>s', | ||
status_code: e.status_code, | ||
message: e.message) | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.