-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
1c26495
commit 56c34bd
Showing
17 changed files
with
195 additions
and
114 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,3 +1,4 @@ | ||
pkg/* | ||
*.gem | ||
.bundle | ||
doc/* |
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,61 @@ | ||
= Avvo API Client | ||
|
||
This gem provides an | ||
{ActiveResource}[http://api.rubyonrails.org/classes/ActiveResource/Base.html]-based | ||
client to information on {Avvo}[http://www.avvo.com], a directory of lawyers and loctors. | ||
|
||
== Requirements | ||
|
||
Apart from the gems installed as dependencies, this gem requires an | ||
account on Avvo associated with an API key. Visit the {API | ||
Documentation}[http://api.avvo.com] for details. | ||
|
||
== Usage | ||
|
||
Somewhere during your app's initialization, you should include the gem | ||
and set it up with your Avvo credentials: | ||
|
||
require 'avvo_api' | ||
AvvoApi.setup('[email protected]', 'password') | ||
|
||
For the most part, the models supplied by this gem should act like | ||
ActiveRecord models. These models parallel the resources listed on | ||
http://api.avvo.com, and everything accessible from the Avvo API is | ||
accessible using this gem. | ||
|
||
== Examples | ||
|
||
Details about the specific information returned by these calls can be | ||
found in the documentation at http://api.avvo.com. | ||
|
||
=== Find a lawyer with a known ID | ||
|
||
l = AvvoApi::Lawyer.find(28995) | ||
|
||
=== Find a lawyer based on known attributes, like email, zip code, etc. | ||
|
||
l = AvvoApi::Lawyer.resolve(:name => 'Mark Britton', :zip_code => '98101') | ||
|
||
=== Search for lawyers matching a keyword in a specific location | ||
|
||
AvvoApi::Lawyer.search(:q => 'criminal defense', :loc => 'seattle') | ||
|
||
=== Retrieve the headshot URL for a lawyer | ||
|
||
AvvoApi::Lawyer.find(28995).headshot.headshot_url | ||
|
||
or | ||
|
||
AvvoApi::Headshot.find(:one, :params => {:lawyer_id => 28995}).headshot_url | ||
|
||
=== Getting a list of addresses for a doctor | ||
|
||
addresses = AvvoApi::Doctor.find(1).addresses | ||
|
||
or | ||
|
||
addresses = AvvoApi::Address.find(:all, :params => {:doctor_id => doctor.id}) | ||
|
||
=== Getting the main address for a doctor | ||
|
||
main_address = AvvoApi::Address.main(:doctor_id => doctor.id) |
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 |
---|---|---|
|
@@ -21,7 +21,14 @@ | |
puts opts | ||
exit(1) | ||
else | ||
config = YAML.load(File.read(File.expand_path("~/.avvo"))) | ||
begin | ||
config = YAML.load(File.read(File.expand_path("~/.avvo"))) | ||
rescue | ||
puts "Please put your Avvo API credentials in ~/.avvo. This is a simple yaml file, which should look like: | ||
user: [email protected] | ||
password: your_avvo_password" | ||
exit(1) | ||
end | ||
AvvoApi.setup(config["user"], config["password"]) | ||
AvvoApi::Base.site = 'http://localhost.local:3000' | ||
|
||
|
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,27 +1,35 @@ | ||
# Constants representing the possible values of the | ||
# advanced_training_type_id parameter of AvvoApi::AdvancedTraining | ||
module AvvoApi::AdvancedTrainingType | ||
|
||
# Unknown training type | ||
UNKNOWN = 1 | ||
|
||
# Represents an internship | ||
INTERNSHIP = 2 | ||
|
||
# Represents a residency | ||
RESIDENCY = 3 | ||
|
||
# Represents a fellowship | ||
FELLOWSHIP = 4 | ||
end | ||
|
||
# Represents advanced training, like residencies, for doctors. This | ||
# model is only applicable to doctors. The following attributes MUST | ||
# be set when using this model: | ||
# | ||
# * doctor_id | ||
# * doctor_id | ||
# | ||
# This model has the following attributes: | ||
# | ||
# * id | ||
# * advanced_training_type_id: an AdvancedTrainingType constant | ||
# * specialty_name: The name of the specialty this advanced training is in | ||
# * specialty_id: The ID of the specialty, if known | ||
# * hospital_name: The normalized name of the hospital. This will be | ||
# resolved by Avvo when it is set by this client. | ||
# * hospital_id: The id of the hospital, if known. | ||
# * graduation_date: The date this training was completed | ||
# * id - The model's id | ||
# * advanced_training_type_id - an AvvoApi::AdvancedTrainingType constant | ||
# * specialty_name - The name of the specialty this advanced training is in | ||
# * hospital_name - The normalized name of the hospital. This will be | ||
# resolved by Avvo when it is set by this client. | ||
# * graduation_date - The date this training was completed | ||
# | ||
module AvvoApi::AdvancedTrainingType | ||
UNKNOWN = 1 | ||
INTERNSHIP = 2 | ||
RESIDENCY = 3 | ||
FELLOWSHIP = 4 | ||
end | ||
|
||
class AvvoApi::AdvancedTraining < AvvoApi::Base | ||
belongs_to :doctor | ||
end |
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,26 +1,20 @@ | ||
# Represents a professional's headshot. Each professional only has one | ||
# headshot, so finding a headshot should happen with the following call: | ||
# | ||
# AvvoApi::Headshot.find(:one, :lawyer_id => l.id) | ||
# AvvoApi::Headshot.find(:one, :lawyer_id => l.id) | ||
# | ||
# When using this model, one of the following attributes MUST be set: | ||
# | ||
# * doctor_id | ||
# * lawyer_id | ||
# * doctor_id | ||
# * lawyer_id | ||
# | ||
# This model has the following attribute: | ||
# | ||
# * headshot_url: The url to the standard-size headshot. | ||
# | ||
# When creating a headshot, you should set the Base64'd image data (in | ||
# JPG or PNG format) to the write_only +headshot_data+ attribute. Avvo | ||
# will do any compositing or cropping for you. | ||
# * headshot_url: The url to the standard-size headshot. | ||
# | ||
class AvvoApi::Headshot < AvvoApi::Base | ||
|
||
singleton | ||
|
||
belongs_to :lawyer | ||
belongs_to :doctor | ||
|
||
end |
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
Oops, something went wrong.