@@ -34,21 +34,24 @@ def legislators(self, **kwargs):
34
34
'legislator' )
35
35
36
36
37
- def legislator_search (self , name , threshold = 0.9 , all_legislators = False ):
37
+ def legislator_search (self , name , threshold = 0.9 , all_legislators = False ,
38
+ ** kwargs ):
38
39
"""
39
40
Fuzzy-matching name search against federal legislators.
40
41
41
42
See documentation at `legislators.search
42
43
<http://services.sunlightlabs.com/docs/congressapi/legislators.search/>`_
43
44
"""
44
- params = {'name' : name , 'threshold' : threshold }
45
+ params = kwargs .copy ()
46
+ params .update ({'name' : name , 'threshold' : threshold })
47
+
45
48
if all_legislators :
46
49
params ['all_legislators' ] = 1
47
- return _unpack ( self . get ( 'legislators.search' , ** params ),
48
- 'result' )
50
+
51
+ return _unpack ( self . get ( 'legislators.search' , ** params ), 'result' )
49
52
50
53
51
- def legislators_for_zip (self , zipcode ):
54
+ def legislators_for_zip (self , zipcode , ** kwargs ):
52
55
"""
53
56
Query for all legislators representing a given ZIP code.
54
57
@@ -59,71 +62,95 @@ def legislators_for_zip(self, zipcode):
59
62
See documentation at `legislators.allForZip
60
63
<http://services.sunlightlabs.com/docs/congressapi/legislators.allForZip/>`_
61
64
"""
62
- return _unpack (self .get ('legislators.allForZip' , zip = zipcode ),
63
- 'legislator'
64
- )
65
+ params = kwargs .copy ()
66
+ params .update ({
67
+ "zip" : zipcode
68
+ })
69
+ return _unpack (self .get ('legislators.allForZip' , ** params ),
70
+ 'legislator' )
65
71
66
- def legislators_for_lat_lon (self , latitude , longitude ):
72
+ def legislators_for_lat_lon (self , latitude , longitude , ** kwargs ):
67
73
"""
68
74
Query for all legislators representing an given location.
69
75
70
76
See documentation at `legislators.allForLatLong
71
77
<http://services.sunlightlabs.com/docs/congressapi/legislators.allForLatLong/>`_
72
78
"""
73
- return _unpack (self .get ('legislators.allForLatLong' , latitude = latitude ,
74
- longitude = longitude ), 'legislator' )
79
+ params = kwargs .copy ()
80
+ params .update ({
81
+ "latitude" : latitude ,
82
+ "longitude" : longitude
83
+ })
84
+ return _unpack (self .get ('legislators.allForLatLong' , ** params ),
85
+ 'legislator' )
75
86
76
- def districts_for_zip (self , zipcode ):
87
+ def districts_for_zip (self , zipcode , ** kwargs ):
77
88
"""
78
89
Query for all congressional districts overlapping a zip code.
79
90
80
91
See documentation at `districts.getDistrictFromLatLong
81
92
<http://services.sunlightlabs.com/docs/congressapi/districts.getDistrictFromLatLong/>`_
82
93
"""
83
- return _unpack (self .get ('districts.getDistrictsFromZip' , zip = zipcode ),
84
- 'district'
85
- )
94
+ params = kwargs .copy ()
95
+ params .update ({
96
+ "zip" : zipcode
97
+ })
98
+ return _unpack (self .get ('districts.getDistrictsFromZip' , ** params ),
99
+ 'district' )
86
100
87
- def districts_for_lat_lon (self , latitude , longitude ):
101
+ def districts_for_lat_lon (self , latitude , longitude , ** kwargs ):
88
102
"""
89
103
Query for all congressional districts containing a given location.
90
104
91
105
See documentation at `districts.getDistrictFromLatLong
92
106
<http://services.sunlightlabs.com/docs/congressapi/districts.getDistrictFromLatLong/>`_
93
107
"""
94
- return _unpack (self .get ('districts.getDistrictFromLatLong' ,
95
- latitude = latitude , longitude = longitude ),
96
- 'district'
97
- )
108
+ params = kwargs .copy ()
109
+ params .update ({
110
+ "latitude" : latitude ,
111
+ "longitude" : longitude
112
+ })
113
+ return _unpack (self .get ('districts.getDistrictFromLatLong' , ** params ),
114
+ 'district' )
115
+
98
116
99
- def committees (self , chamber ):
117
+ def committees (self , chamber , ** kwargs ):
100
118
"""
101
119
Query for all committees for a chamber. (House|Senate|Joint)
102
120
103
121
See documentation at `committees.getList
104
122
<http://services.sunlightlabs.com/docs/congressapi/committees.getList/>`_
105
123
"""
106
- return _unpack (self .get ('committees.getList' , chamber = chamber ),
124
+ params = kwargs .copy ()
125
+ params .update ({"chamber" : chamber })
126
+ return _unpack (self .get ('committees.getList' , ** params ),
107
127
'committee' )
108
128
109
- def committee_detail (self , id ):
129
+ def committee_detail (self , committee_id , ** kwargs ):
110
130
"""
111
131
Query for all details for a committee, including members.
112
132
113
133
See documentation at `committees.get
114
134
<http://services.sunlightlabs.com/docs/congressapi/committees.get/>`_
115
135
"""
116
- return self .get ('committees.get' , id = id )['committee' ]
136
+ params = kwargs .copy ()
137
+ params .update ({"id" : committee_id })
138
+ # We can't use _unpack since top level is `committee' not committees
139
+ return self .get ('committees.get' , ** params )['committee' ]
117
140
118
- def committees_for_legislator (self , bioguide_id ):
141
+ def committees_for_legislator (self , bioguide_id , ** kwargs ):
119
142
"""
120
143
Query for all details for all of a legislator's committee assignments.
121
144
122
145
See documentation at `committees.allForLegislator
123
146
<http://services.sunlightlabs.com/docs/congressapi/committees.allForLegislator/>`_
124
147
"""
125
- return _unpack (self .get ('committees.allForLegislator' ,
126
- bioguide_id = bioguide_id ), 'committee' )
148
+ params = kwargs .copy ()
149
+ params .update ({
150
+ "bioguide_id" : bioguide_id
151
+ })
152
+ return _unpack (self .get ('committees.allForLegislator' , ** params ),
153
+ 'committee' )
127
154
128
155
# implementation methods
129
156
def _get_url (self , obj , apikey , ** kwargs ):
0 commit comments