Skip to content

Commit f67630d

Browse files
authored
Merge pull request #183 from tutorcruncher/contractor-distance
Add user list distance filter section
2 parents f6cfb61 + c02207f commit f67630d

File tree

6 files changed

+36
-2
lines changed

6 files changed

+36
-2
lines changed

pages/api.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ info_sections:
1616
title: Creating/Updating Users
1717
id: creating-updating-users
1818
layout: /creating-updating-users/creating-updating-users.yml
19+
-
20+
title: Distance Filter on User Lists
21+
id: distance-filter
22+
layout: /distance-filter/distance-filter.yml
1923
-
2024
title: Custom Fields
2125
id: custom-fields

pages/contractors/contractor-object.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ filters:
229229
type: string
230230
description: Filter by the Contractor's status.
231231
-
232-
name: address
232+
name: distance_address
233233
type: string
234234
description: Filter by the address.
235235
-
236-
name: radius
236+
name: distance_radius
237237
type: integer
238238
description: Filter by the radius of the address. This is used in conjunction with the `address` filter.
239239
-
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
attributes:
2+
-
3+
name: distance_address
4+
type: string
5+
description: A URL-encoded string representing the starting location for the search. This must be specific (e.g., including city, postal code, and country) for accurate results. Ensure the address is properly URL-encoded.
6+
-
7+
name: distance_radius
8+
type: integer
9+
description: The radius in kilometers around the distance_address to filter users. Users outside this radius will not be included.
10+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Agents](#agents), [Clients](#clients), [Contractors](#contractors), [Recipients](#recipients) can be filtered based on their proximity
2+
to a specific location using the distance_address and distance_radius parameters.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pprint
2+
import requests
3+
from urllib.parse import urlencode
4+
5+
headers = {'Authorization': 'token <API KEY>'}
6+
params = {
7+
'distance_address': 'The Food Exchange, New Covent Garden Market, Nine Elms, London SW8 5EL, ENGLAND',
8+
'distance_radius': 1
9+
}
10+
url = f"https://secure.tutorcruncher.com/api/contractors/?{urlencode(params)}"
11+
response = requests.get(url, headers=headers)
12+
pprint.pprint(response.json())
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sections:
2+
-
3+
description: /distance-filter/distance-filter.md
4+
code: /distance-filter/distance-filter.py
5+
attributes: /distance-filter/distance-filter-object.yml
6+
code_type: POST

0 commit comments

Comments
 (0)