File tree 5 files changed +49
-5
lines changed
5 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ develop-eggs/
13
13
dist /
14
14
downloads /
15
15
eggs /
16
- lib /
17
16
lib64 /
18
17
parts /
19
18
sdist /
Original file line number Diff line number Diff line change
1
+ __author__ = 'gokhan'
2
+ import requests
3
+
4
+
5
+ class PostCodeClient (object ):
6
+ def getLookupPostCode (self , postcode ):
7
+ self .postcode = postcode
8
+ data = requests .get ("http://api.postcodes.io/postcodes/" + postcode ).text
9
+ return data
10
+
11
+
12
+ def getLookupPostcodes (self , payload ):
13
+ self .payload = payload
14
+ data = requests .post ("http://api.postcodes.io/postcodes" , payload ).text
15
+ return data
16
+
17
+
18
+ def getLocationBasedPostcodes (self , lon , lang ):
19
+ self .long = lon
20
+ self .lang = lang
21
+
22
+ data = requests .get ("http://api.postcodes.io/postcodes?lon=" + lon + "&lat=" + lang ).text
23
+ return data
24
+
25
+
26
+ def getBulkReverseGecoding (self , payload ):
27
+ self .payload = payload
28
+ data = requests .post ("http://api.postcodes.io/postcodes" , payload ).text
29
+ return data
30
+
31
+
32
+ def getRandomPostCodes (self ):
33
+ pass
34
+ data = requests .get ("http://api.postcodes.io/random/postcodes" ).text
35
+ return data
36
+
37
+ def validatePostCode (self , postcode ):
38
+ self .postcode = postcode
39
+ data = requests .get ("http://api.postcodes.io/postcodes/" + postcode + "/validate" ).text
40
+ return data
41
+
42
+ def getNearestPostCode (self , postcode ):
43
+ self .postcode = postcode
44
+ data = requests .get ("http://api.postcodes.io/postcodes/" + postcode + "/nearest" ).text
45
+ return data
Original file line number Diff line number Diff line change
1
+ __author__ = 'gokhan'
2
+ from PostCodeClient import PostCodeClient
Original file line number Diff line number Diff line change 8
8
version = '0.1' ,
9
9
author = 'Gokhan Karadas' ,
10
10
11
- download_url = "https://github.com/previousdeveloper/PythonPostcodesWrapper" ,
11
+ download_url = "https://github.com/previousdeveloper/PythonPostcodesWrapper" ,
12
12
url = 'https://github.com/previousdeveloper/PythonPostcodesWrapper' ,
13
13
license = 'LICENSE' ,
14
14
description = 'Postcode & Geolocation API for UK for python' ,
Original file line number Diff line number Diff line change @@ -15,9 +15,7 @@ def test_Lookup_Post_codes(self):
15
15
self .assertIsNotNone (self .client .getLookupPostCode ("OX49 5NU" ))
16
16
17
17
def test_Bulk_Lookup_Post_codes (self ):
18
- self .payload = {
19
- "lib" : ["OX49 5NU" , "M32 0JG" , "NE30 1DP" ]
20
- }
18
+ self .payload = {"postcodes" : ["OX49 5NU" , "M32 0JG" , "NE30 1DP" ]}
21
19
self .assertIsNotNone (self .client .getLookupPostcodes (self .payload ))
22
20
23
21
def test_Location_Based_Postcodes (self ):
You can’t perform that action at this time.
0 commit comments