Skip to content

Commit

Permalink
Removed doctors and dentists from the Avvo API.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinweiss committed Nov 27, 2012
1 parent 310e941 commit dffffaf
Show file tree
Hide file tree
Showing 27 changed files with 144 additions and 308 deletions.
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PATH
remote: .
specs:
avvo_api (0.1.1)
avvo_api (0.2.0)
activeresource (~> 3.0.0)
reactive_resource (~> 0.5)

GEM
Expand Down
12 changes: 6 additions & 6 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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 doctors.
client to information on {Avvo}[http://www.avvo.com], a directory of lawyers.

== Requirements

Expand Down Expand Up @@ -50,14 +50,14 @@ or

AvvoApi::Headshot.find(:one, :params => {:lawyer_id => 28995}).headshot_url

=== Getting a list of addresses for a doctor
=== Getting a list of addresses for a lawyer

addresses = AvvoApi::Doctor.find(1).addresses
addresses = AvvoApi::Lawyer.find(28995).addresses

or

addresses = AvvoApi::Address.find(:all, :params => {:doctor_id => doctor.id})
addresses = AvvoApi::Address.find(:all, :params => {:lawyer_id => lawyer.id})

=== Getting the main address for a doctor
=== Getting the main address for a lawyer

main_address = AvvoApi::Address.main(:doctor_id => doctor.id)
main_address = AvvoApi::Address.main(:lawyer_id => lawyer.id)
3 changes: 2 additions & 1 deletion avvo_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Gem::Specification.new do |s|
s.summary = %q{An ActiveResource client to the Avvo API}
s.description = %q{An ActiveResource client to the Avvo API}

s.add_dependency "activeresource", '~> 3.0.0'
s.add_dependency "reactive_resource", '~> 0.5'
s.add_development_dependency "shoulda", '~> 2.11.3'
s.add_development_dependency "webmock", '~> 1.6.1'

s.rubyforge_project = "avvo_api"

s.files = `git ls-files`.split("\n")
Expand Down
25 changes: 11 additions & 14 deletions examples/avvo_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
professional_klass = nil
professional_param = nil

opts = OptionParser.new("Usage: avvo_cli.rb [options] ID")
opts.on("-l", "--lawyer", "Get details about a lawyer") { professional_klass = AvvoApi::Lawyer; professional_param = :lawyer_id }
opts.on("-d", "--doctor", "Get details about a doctor") { professional_klass = AvvoApi::Doctor; professional_param = :doctor_id }
opts = OptionParser.new("Usage: avvo_cli.rb ID")
rest = opts.parse ARGV

if !professional_klass
puts "You must specify either --lawyer or --doctor"
puts opts
exit(1)
elsif !rest.first
professional_klass = AvvoApi::Lawyer
professional_param = :lawyer_id

if !rest.first
puts "You must specify the ID of the professional you are looking for"
puts opts
exit(1)
Expand All @@ -32,8 +29,8 @@
exit(1)
end
AvvoApi.setup(config["email"], config["password"])
AvvoApi::Base.site = 'http://localhost.local:3000'
AvvoApi::Base.site = 'https://api.avvo.com/'

professional = professional_klass.find(rest.first)

address = AvvoApi::Address.main(professional_param => professional.id)
Expand All @@ -55,20 +52,20 @@
phones.each do |phone|
printf format, "#{phone.phone_type}:", phone.phone_number
end

specialties.each_with_index do |specialty, i|
header = i == 0 ? "Specialties:" : ""
printf format, header, "#{specialty.specialty_name.strip} (#{specialty.specialty_percent}%)"
end

puts
printf format, "Reviews ", ''
reviews.each do |review|
printf format, "Rating:", review.overall_rating
printf format, "Title:", review.title
printf format, "URL:", review.url
printf format, "By:", review.posted_by
puts
puts
end

end
5 changes: 1 addition & 4 deletions lib/avvo_api.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
require 'avvo_api/base'
require 'avvo_api/professional_methods'

# The Avvo API Client. All API models live in this module.
module AvvoApi

autoload :Lawyer, 'avvo_api/lawyer'
autoload :Doctor, 'avvo_api/doctor'
autoload :School, 'avvo_api/school'
autoload :Address, 'avvo_api/address'
autoload :Phone, 'avvo_api/phone'
autoload :Language, 'avvo_api/language'
autoload :Specialty, 'avvo_api/specialty'
autoload :Headshot, 'avvo_api/headshot'
autoload :AdvancedTraining, 'avvo_api/advanced_training'
autoload :Review, 'avvo_api/review'

# Tells this client to use +email+ and +password+ to authenticate to
# the Avvo API.
def self.setup(email, password)
Expand Down
8 changes: 3 additions & 5 deletions lib/avvo_api/address.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Represents an address. One of the following attributes MUST
# Represents an address. The following attribute MUST
# be set when using this model:
#
# * doctor_id
#
# * lawyer_id
#
# This model has the following attributes:
Expand All @@ -14,10 +13,9 @@
# * postal_code
# * latitude
# * longitude
#
#
class AvvoApi::Address < AvvoApi::Base
belongs_to :lawyer
belongs_to :doctor
has_many :phones

# Returns the 'main' address associated with the passed in
Expand Down
35 changes: 0 additions & 35 deletions lib/avvo_api/advanced_training.rb

This file was deleted.

22 changes: 0 additions & 22 deletions lib/avvo_api/doctor.rb

This file was deleted.

8 changes: 3 additions & 5 deletions lib/avvo_api/headshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
#
# AvvoApi::Headshot.find(:one, :lawyer_id => l.id)
#
# When using this model, one of the following attributes MUST be set:
#
# * doctor_id
# When using this model, The following attribute MUST be set:
#
# * lawyer_id
#
# This model has the following attribute:
#
# * headshot_url: The url to the standard-size headshot.
#
#
class AvvoApi::Headshot < AvvoApi::Base
singleton

belongs_to :lawyer
belongs_to :doctor
end
10 changes: 4 additions & 6 deletions lib/avvo_api/language.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Represents a language. One of the following attributes MUST
# Represents a language. The following attribute MUST
# be set when using this model:
#
# * doctor_id
#
# * lawyer_id
#
# This model has the following attributes:
#
# * id
# * id
# * name: The language name.
# * specialty_id: The language id. 'name' takes priority over this if both are set.
#
#
class AvvoApi::Language < AvvoApi::Base
belongs_to :lawyer
belongs_to :doctor
end
47 changes: 44 additions & 3 deletions lib/avvo_api/lawyer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Represents a lawyer on Avvo. Attributes include:
#
#
# * id: The id of this lawyer
# * firstname: the first name of this lawyer
# * middlename: the middle name of this lawyer
Expand All @@ -9,12 +9,53 @@
# * website_url
#
class AvvoApi::Lawyer < AvvoApi::Base

has_many :addresses
has_many :reviews
has_many :schools
has_many :languages
has_many :specialties
has_one :headshot
include AvvoApi::ProfessionalMethods

# Search avvo for a list of the top 10 professionals matching the
# passed-in parameters. Accepts the following parameters:
#
# [q] The search query
# [loc] The location to search in
#
# These parameters match the search boxes on the Avvo website.
#
# This method pre-dates the REST API, and thus returns a hash of
# data rather than API objects. Hopefully, we'll eventually come
# up with something better. To see an actual response, look at
# http://api.avvo.com/docs/get/lawyers/search.html
def self.search(params)
response = self.get(:search, params)

if response && response['num_results']
response
else
raise ActiveResource::ResourceNotFound.new(response)
end
end

# Attempts to find a professional on Avvo that matches the
# passed-in params. Currently accepts the following params:
#
# [name] The full name of the lawyer you are trying to find
# [phone] The phone number of the lawyer, in the format XXX-XXX-XXXX
# [fax] The fax number of the lawyer, in the format XXX-XXX-XXXX
# [address] The full address of the lawyer
# [zip_code] The zip code of the lawyer
# [email_address] The e-mail address of the lawyer
def self.resolve(params)
response = self.get(:resolve, :params => params)
if response && response[collection_name]
response[collection_name].map do |params|
new(params.merge({"annotation" => response['annotation']}))
end
else
raise ActiveResource::ResourceNotFound.new(response)
end
end
end
12 changes: 4 additions & 8 deletions lib/avvo_api/phone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ module AvvoApi::PhoneType
MOBILE = 4
end

# Represents a phone number tied to an address. One of the
# following attributes MUST be set when using this model:
#
# * doctor_id
# * lawyer_id
# Represents a phone number tied to an address. The following
# attributes MUST be set when using this model:
#
# Additionally, the following attribute MUST be set when using this model:
#
# * lawyer_id
# * address_id
#
# This model has the following attributes:
#
# * id
# * id
# * phone_number: The phone number. Will be normalized by Avvo.
# * phone_type_id: The type of the phone number, as an AvvoApi::PhoneType
# constant. (Only applicable when creating or updating records)
Expand Down
52 changes: 0 additions & 52 deletions lib/avvo_api/professional_methods.rb

This file was deleted.

Loading

0 comments on commit dffffaf

Please sign in to comment.