From e7aa926c510666b35d21f00cda9f68f28ebccca6 Mon Sep 17 00:00:00 2001 From: Maksym Novozhylov Date: Wed, 15 Feb 2017 13:41:59 +0100 Subject: [PATCH] Update Applications API: move from v3 to v4 --- changelog.rst | 6 ++ upwork/client.py | 3 +- upwork/routers/hr.py | 220 ++++++++++++++++++++++--------------------- 3 files changed, 122 insertions(+), 107 deletions(-) diff --git a/changelog.rst b/changelog.rst index 99e7090..cffeb74 100644 --- a/changelog.rst +++ b/changelog.rst @@ -5,6 +5,12 @@ Changelog *************** +.. _1.2.2: + +Version 1.2.2 +------------- +* Applications API has moved from v3 to v4 + .. _1.2.1: Version 1.2.1 diff --git a/upwork/client.py b/upwork/client.py index 63f0588..c16bf76 100644 --- a/upwork/client.py +++ b/upwork/client.py @@ -132,10 +132,11 @@ def __init__(self, public_key, secret_key, self.finreport = Finreports(self) if hr: - from upwork.routers.hr import HR_V1, HR, HR_V3 + from upwork.routers.hr import HR_V1, HR, HR_V3, HR_V4 self.hr_v1 = HR_V1(self) self.hr = HR(self) self.hr_v3 = HR_V3(self) + self.hr_v4 = HR_V4(self) if messages: from upwork.routers.messages import Messages diff --git a/upwork/routers/hr.py b/upwork/routers/hr.py index 8dd3d24..29231ce 100644 --- a/upwork/routers/hr.py +++ b/upwork/routers/hr.py @@ -1029,112 +1029,6 @@ class HR_V3(Namespace): api_url = 'hr/' version = 3 - def list_client_applications(self, buyer_team__reference, job_key, - status=None, profile_key=None, - agency_team__reference=None, - order_by=None, page_offset=None, - page_size=None): - """ - List job applications as a client. - - *Parameters:* - :buyer_team__reference: The reference ID of the client's team. - It allows getting applications for a - specific team. Example: ``34567``. - Use 'List Teams' API call to get it. - - :job_key: The job key. It allows getting applications - for a specific job. Example: ``~01d54a7xxxxx125731``. - - :status: (optional) The current status of the job application. - Valid values: ``shortlisted``, ``messaged``, - ``hired``, ``offered``, ``declined``, ``hidden``. - - :profile_key: (optional) Filters by a specific freelancer's profile key. - - :agency_team__reference: (optional) The reference ID of the agency. - - :order_by: (optional) Sorts results in format ``$field_name1;$field_name2;..$field_nameN;AD...A``. - Here ``A`` resebles ascending order, ``D`` - descending order. Example: ``order_by=created_time;D``. - - :page_offset: (optional) Number of entries to skip - - :page_size: (optional: default 20) Page size - in number of entries - - """ - data = {} - - data['buyer_team__reference'] = buyer_team__reference - data['job_key'] = job_key - - if status: - data['status'] = status - - if profile_key: - data['profile_key'] = profile_key - - if agency_team__reference: - data['agency_team__reference'] = agency_team__reference - - if order_by: - data['order_by'] = order_by - - data['page'] = '{0};{1}'.format(page_offset, page_size) - - url = 'clients/applications' - return self.get(url, data) - - def get_client_application(self, application_id, buyer_team__reference): - """ - Get specific job application as a client. - - *Parameters:* - :application_id: Job application reference ID. - - :buyer_team__reference: The reference ID of the client's team. - It allows getting applications for a - specific team. Example: ``34567``. - Use 'List Teams' API call to get it. - - """ - data = {} - - data['buyer_team__reference'] = buyer_team__reference - - url = 'clients/applications/{0}'.format(application_id) - return self.get(url, data) - - def list_freelancer_applications(self, status=None): - """ - List job applications as a freelancer. - - *Parameters:* - :status: (optional) The current status of the job application. - Valid values: ``interviews``, ``invites``, ``active``. - - """ - data = {} - - if status: - data['status'] = status - - url = 'contractors/applications' - return self.get(url, data) - - def get_freelancer_application(self, application_id): - """ - Get specific job application as a freelancer. - - *Parameters:* - :application_id: Job application reference ID. - - """ - data = {} - - url = 'contractors/applications/{0}'.format(application_id) - return self.get(url, data) - def create_milestone(self, contract_reference, milestone_description, deposit_amount, due_date=None): """ Create a milestone. @@ -1345,3 +1239,117 @@ def get_active_milestone(self, contract_reference): url = 'fp/milestones/statuses/active/contracts/{0}'.format(contract_reference) return self.get(url, data) + + +class HR_V4(Namespace): + """ + HR API version 4. + """ + api_url = 'hr/' + version = 4 + + def list_client_applications(self, buyer_team__reference, job_key, + status=None, profile_key=None, + agency_team__reference=None, + order_by=None, page_offset=None, + page_size=None): + """ + List job applications as a client. + + *Parameters:* + :buyer_team__reference: The reference ID of the client's team. + It allows getting applications for a + specific team. Example: ``34567``. + Use 'List Teams' API call to get it. + + :job_key: The job key. It allows getting applications + for a specific job. Example: ``~01d54a7xxxxx125731``. + + :status: (optional) The current status of the job application. + Valid values: ``shortlisted``, ``messaged``, + ``hired``, ``offered``, ``declined``, ``hidden``. + + :profile_key: (optional) Filters by a specific freelancer's profile key. + + :agency_team__reference: (optional) The reference ID of the agency. + + :order_by: (optional) Sorts results in format ``$field_name1;$field_name2;..$field_nameN;AD...A``. + Here ``A`` resebles ascending order, ``D`` - descending order. Example: ``order_by=created_time;D``. + + :page_offset: (optional) Number of entries to skip + + :page_size: (optional: default 20) Page size + in number of entries + + """ + data = {} + + data['buyer_team__reference'] = buyer_team__reference + data['job_key'] = job_key + + if status: + data['status'] = status + + if profile_key: + data['profile_key'] = profile_key + + if agency_team__reference: + data['agency_team__reference'] = agency_team__reference + + if order_by: + data['order_by'] = order_by + + data['page'] = '{0};{1}'.format(page_offset, page_size) + + url = 'clients/applications' + return self.get(url, data) + + def get_client_application(self, application_id, buyer_team__reference): + """ + Get specific job application as a client. + + *Parameters:* + :application_id: Job application reference ID. + + :buyer_team__reference: The reference ID of the client's team. + It allows getting applications for a + specific team. Example: ``34567``. + Use 'List Teams' API call to get it. + + """ + data = {} + + data['buyer_team__reference'] = buyer_team__reference + + url = 'clients/applications/{0}'.format(application_id) + return self.get(url, data) + + def list_freelancer_applications(self, status=None): + """ + List job applications as a freelancer. + + *Parameters:* + :status: (optional) The current status of the job application. + Valid values: ``interviews``, ``invites``, ``active``. + + """ + data = {} + + if status: + data['status'] = status + + url = 'contractors/applications' + return self.get(url, data) + + def get_freelancer_application(self, application_id): + """ + Get specific job application as a freelancer. + + *Parameters:* + :application_id: Job application reference ID. + + """ + data = {} + + url = 'contractors/applications/{0}'.format(application_id) + return self.get(url, data)