truecallerpy icon indicating copy to clipboard operation
truecallerpy copied to clipboard

bulk_search function converting list to string in the wrong way

Open cvipul opened this issue 2 years ago • 1 comments

async def bulk_search(phoneNumbers, countryCode, installationId):
    """
    Perform bulk search for a list of phone numbers using Truecaller API.

    Args:
        phoneNumbers (list[str]): The list of phone numbers to search.
        countryCode (str): The country code of the phone numbers.
        installationId (str): The installation ID for authorization.

The function expects "phoneNumbers" as a list of numbers but within the contents of the function, converts it into a string and send to the API

params = {
        "q": str(phoneNumbers),
        "countryCode": countryCode,
        "type": 14,
        "placement": "SEARCHRESULTS,HISTORY,DETAILS",
        "encoding": "json"
    }

While this works in getting a response from truecaller, the response have the wrong content in the "key" section

{'status_code': 200, 
 'data': {
	'data': [
		{'key': "['1234567890'",
                 ....
                }
        ]
  }
}

We should either convert the list of numbers into a comma separated string again or just ask for a comma separated string of numbers.

cvipul avatar Jan 24 '24 06:01 cvipul

@sumithemmadi - I will raise a PR in case you agree that we should make this small change

cvipul avatar Jan 24 '24 06:01 cvipul