Skip to content

Commit

Permalink
add lapi git source
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonborg committed Jun 29, 2017
1 parent 4624720 commit 65c9da9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gem 'governator', '0.1.10'
gem 'has_scope', '~> 0.7.1'
gem 'impressionist', '~> 1.6.0'
gem 'jbuilder', '~> 2.4.0', '>= 2.4.1'
# gem 'lapi', path: '../../lapi'
gem 'lapi', git: 'https://github.com/msimonborg/lapi'
gem 'multi_json', '~> 1.12.0', '>= 1.12.1'
gem 'naught', '~> 1.1.0'
gem 'nokogiri', '~> 1.8.0'
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: https://github.com/msimonborg/lapi
revision: 5e1a33eaa1ef8cb82150e91103fccee121e1c49a
specs:
lapi (0.1.0)
httparty (>= 0.15.0)
lazy_record (>= 0.6.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -108,13 +116,18 @@ GEM
domain_name (~> 0.5)
http-form_data (1.0.3)
http_parser.rb (0.6.0)
httparty (0.15.5)
multi_xml (>= 0.5.2)
i18n (0.8.1)
impressionist (1.6.0)
nokogiri (~> 1)
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
json (2.1.0)
lazy_record (0.6.2)
activesupport (~> 5.0)
scoped_attr_accessor (~> 1.0, >= 1.0.3)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -131,6 +144,7 @@ GEM
mini_portile2 (2.2.0)
minitest (5.10.2)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
naught (1.1.0)
nio4r (2.0.0)
Expand Down Expand Up @@ -224,6 +238,7 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
scoped_attr_accessor (1.0.3)
simple_oauth (0.3.1)
simple_token_authentication (1.15.1)
actionmailer (>= 3.2.6, < 6)
Expand Down Expand Up @@ -295,6 +310,7 @@ DEPENDENCIES
has_scope (~> 0.7.1)
impressionist (~> 1.6.0)
jbuilder (~> 2.4.0, >= 2.4.1)
lapi!
listen (~> 3.0.5)
multi_json (~> 1.12.0, >= 1.12.1)
naught (~> 1.1.0)
Expand Down
70 changes: 35 additions & 35 deletions config/initializers/lapi.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# frozen_string_literal: true

# module OpenStates
# LAPI.new 'OpenStates' do |api|
# api.base_uri = 'https://www.openstates.org/api/v1/'
# api.key = :apikey, ENV['OPENSTATES_API_KEY']
#
# api.add_resource :legislators do
# optional_params :state, :first_name, :last_name, :chamber,
# :active, :term, :district, :party, :lat, :long
#
# add_attributes :first_name, :last_name, :middle_name, :district, :chamber,
# :url, :created_at, :updated_at, :email, :active, :state,
# :full_name, :leg_id, :party, :suffixes, :id, :photo_url,
# :level, :fax
#
# add_collections :offices
#
# add_scopes democrat: -> { where party: 'Democratic' },
# republican: -> { where party: 'Republican' }
# end
#
# api.add_resource :offices do
# add_attributes :fax, :name, :phone, :address, :type, :email
# end
#
# api.add_resource :districts do
# add_attributes :abbr, :boundary_id, :chamber, :id, :name, :num_seats, :shape
#
# add_collections :legislators
# end
#
# api.add_resource :metadata do
# add_attributes :name, :abbreviation, :chambers
# end
# end
# end
module OpenStates
LAPI.new 'OpenStates' do |api|
api.base_uri = 'https://www.openstates.org/api/v1/'
api.key = :apikey, ENV['OPENSTATES_API_KEY']

api.add_resource :legislators do
optional_params :state, :first_name, :last_name, :chamber,
:active, :term, :district, :party, :lat, :long

add_attributes :first_name, :last_name, :middle_name, :district, :chamber,
:url, :created_at, :updated_at, :email, :active, :state,
:full_name, :leg_id, :party, :suffixes, :id, :photo_url,
:level, :fax

add_collections :offices

add_scopes democrat: -> { where party: 'Democratic' },
republican: -> { where party: 'Republican' }
end

api.add_resource :offices do
add_attributes :fax, :name, :phone, :address, :type, :email
end

api.add_resource :districts do
add_attributes :abbr, :boundary_id, :chamber, :id, :name, :num_seats, :shape

add_collections :legislators
end

api.add_resource :metadata do
add_attributes :name, :abbreviation, :chambers
end
end
end

0 comments on commit 65c9da9

Please sign in to comment.