python-upwork icon indicating copy to clipboard operation
python-upwork copied to clipboard

client.epoint is modified by Gds class but not by Api

Open ChristianTheConsultant opened this issue 5 years ago • 0 comments

When calling the Gds class in the reports module the entry point is updated to "gds", however when subsequently calling an Api class it is not set back to "api". This results in the following error:

>>>from upwork.routers.hr import engagements
>>>from upwork.routers.reports.finance import earnings, billings
>>> e = engagements.Api(client).get_list("{}")
<Response [200]>
>>> r = earnings.Gds(client).get_by_freelancer('test', {'tq': quote('SELECT amount WHERE worked_on "2019-06-01" AND worked_on <= "2019-06-02"')})
<Response [200]>
>>> e = engagements.Api(client).get_list("{}")
<Response [500]>
>>> engagements.Api(client).get_list("{}")
<Response [500]>
{'version': '0.6', 'status': 'error', 'errors': [{'reason': 'other', 'message': 'Wrong URL requested'}]}
>>> client.epoint = 'api'
>>> e = engagements.Api(client).get_list("{}")
<Response [200]>
>>>

Here is an example of responsible code in the upwork.routers.reports.finanance.earnings module:

class Gds:
    """ """

    client = None
    entry_point = "gds"

    def __init__(self, client):
        self.client = client
        self.client.epoint = self.entry_point

Api class does not set this back to "api":

class Api:
    """ """

    client = None

    def __init__(self, client):
        self.client = client

ChristianTheConsultant avatar Dec 03 '20 09:12 ChristianTheConsultant