File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import os
1010import re
1111from typing import Iterator
12+ from urllib .parse import urlencode
1213
1314import requests
1415
16+
1517from abstractions import AdoptablePet , PetSource
1618
1719logger = logging .getLogger (__name__ )
@@ -63,10 +65,9 @@ def fetch_pets(self) -> Iterator[AdoptablePet]:
6365 "Set CUTEPETSBOSTON_RESCUEGROUPS_API_KEY environment variable."
6466 )
6567
66- url = f"{ self .BASE_URL } /{ self .species } "
67- headers = {
68- "Content-Type" : "application/vnd.api+json" ,
69- "Authorization" : self ._api_key ,
68+ query_url_params = {
69+ 'limit' : 2 ,
70+ 'sort' : 'random'
7071 }
7172 payload = {
7273 # "filters": [
@@ -80,7 +81,12 @@ def fetch_pets(self) -> Iterator[AdoptablePet]:
8081 # "miles": self.radius_miles,
8182 # "postalcode": self.postal_code,
8283 # },
83- "limit" : 2 ,
84+ }
85+ query_string = urlencode (query_url_params )
86+ url = f"{ self .BASE_URL } /{ self .species } ?{ query_string } "
87+ headers = {
88+ "Content-Type" : "application/vnd.api+json" ,
89+ "Authorization" : self ._api_key ,
8490 }
8591
8692 logger .info (
You can’t perform that action at this time.
0 commit comments