コード例 #1
0
ファイル: hr.py プロジェクト: mdmitr/python-upwork
    def post_team_adjustment(self,
                             team_reference,
                             engagement_reference,
                             comments,
                             charge_amount,
                             notes=None):
        """
        Add bonus to an engagement.

        *Parameters:*
          :team_reference:        The Team reference ID

          :engagement_reference:  The Engagement reference ID

          :comments:              Comments about this adjustment, e.g.
                                 "Bonus for a good job"

          :charge_amount:         The amount that will be charged to the employer, e.g. 110

          :notes:                 (optional) Notes

        .. note:: You should use either ``amount`` parameter or \
        ``charge_amount``, but not both. Make sure that at least \
        one of them is present.

        """
        url = 'teams/{0}/adjustments'.format(team_reference)
        data = {}

        data['engagement__reference'] = engagement_reference
        data['comments'] = comments

        if charge_amount is None or charge_amount == 0:
            raise ApiValueError(
                'Missed obligatory parameter ``charge_amount``')

        data['charge_amount'] = charge_amount

        if notes:
            data['notes'] = notes

        result = self.post(url, data)
        return result.get('adjustment', result)
コード例 #2
0
ファイル: hr.py プロジェクト: mdmitr/python-upwork
    def invite_to_interview(self,
                            job_id,
                            cover,
                            profile_key=None,
                            provider_reference=None):
        """
        Invite to an interview.

        *Parameters:*
          :job_id:               Job reference ID

          :cover:                Text of the cover letter

          :profile_key:          (optional) Unique contractor's key,
                                 e.g. ~~677961dcd7f65c01

          :provider_reference:   (optional) Developer's unique reference ID,
                                 e.g. 12345. Use it if no profile_key available

        Either one of the parameters ``profile_key`` or ``provider_reference``
        should be provided, otherwise error will be raised.

        """
        data = {}

        if profile_key is None and provider_reference is None:
            raise ApiValueError('Either one of the parameters ``profile_key`` '
                                'or ``provider_reference`` should be provided')

        if profile_key:
            data['profile_key'] = profile_key

        if provider_reference:
            data['provider__reference'] = provider_reference

        data['cover'] = cover

        url = 'jobs/{0}/candidates'.format(job_id)
        return self.post(url, data)
コード例 #3
0
ファイル: hr.py プロジェクト: mdmitr/python-upwork
    def post_offer(self,
                   job_reference,
                   provider_team_reference=None,
                   provider_reference=None,
                   profile_key=None,
                   message_from_buyer=None,
                   engagement_title=None,
                   attached_doc=None,
                   fixed_charge_amount_agreed=None,
                   fixed_pay_amount_agreed=None,
                   fixed_price_upfront_payment=None,
                   hourly_pay_rate=None,
                   weekly_salary_charge_amount=None,
                   weekly_salary_pay_amount=None,
                   weekly_stipend_hours=None,
                   weekly_hours_limit=None,
                   start_date=None,
                   keep_open=None):
        """Make an offer to the provider.

        *Parameters:*
          :job_reference:                  The Job's reference ID

          :provider_team_reference:        (optional) The reference ID
                                           of the provider team. If specified,
                                           the check is performed whether user
                                           you're making offer to belongs
                                           to the team

          :provider_reference:             (conditionally optional)
                                           The provider's reference. Has
                                           the override priority over
                                           ``profile_key`` if both specified.

          :profile_key:                    (conditionally optional)
                                           Unique profile key,
                                           used if ``provider_reference``
                                           is absent

          :message_from_buyer:             (optional) Text message

          :engagement_title:               (optional) The engagement title

          :attached_doc:                   (optional) Attachment

          :fixed_charge_amount_agreed:     (optional) The amount of agreed
                                           charge, required by fixed-price job

          :fixed_pay_amount_agreed:        (optional) The amount of agreed pay

          :fixed_price_upfront_payment:    (optional) The amount of upfront
                                           payment

          :hourly_pay_rate:                (optional) Hourly pay rate

          :weekly_salary_charge_amount:    (optional) Salary charge amount
                                           per week

          :weekly_salary_pay_amount:       (optional) Salary pay amount per
                                           week, required by fixed-price job

          :weekly_stipend_hours:           (optional) Stipend hours per week

          :weekly_hours_limit:             (optional) Limit of hours per week

          :start_date:                     (optional) The offer start date

          :keep_open:                      (optional, default: 'no')
                                           Leave the job opened.
                                           Possible values are: 'yes', 'no'

        When just job and provider reference params are provided in the request
        then an invitation for an interview should be send to the according
        provider. Provider can either choose to accept the invitation and start
        the communication with the user or decline it, in which case
        communication between client and provider stops.

        When additionally engagement title and charge amount params are
        provided in the request, then an actual offer is created for the
        provider. In this case the provider can either accept the offer
        and start working or decline the offer.

        """
        url = 'offers'

        data = {}
        data['job__reference'] = job_reference

        if provider_team_reference:
            data['provider_team__reference'] = provider_team_reference

        if profile_key is None and provider_reference is None:
            raise ApiValueError('Either one of the parameters ``profile_key`` '
                                'or ``provider_reference`` should be provided')

        if provider_reference:
            data['provider__reference'] = provider_reference
        if profile_key:
            data['profile_key'] = profile_key

        if message_from_buyer:
            data['message_from_buyer'] = message_from_buyer

        if engagement_title:
            data['engagement_title'] = engagement_title

        if attached_doc:
            data['attached_doc'] = attached_doc

        if fixed_charge_amount_agreed:
            data['fixed_charge_amount_agreed'] = fixed_charge_amount_agreed

        if fixed_pay_amount_agreed:
            data['fixed_pay_amount_agreed'] = fixed_pay_amount_agreed

        if fixed_price_upfront_payment:
            data['fixed_price_upfront_payment'] = fixed_price_upfront_payment

        if hourly_pay_rate:
            data['hourly_pay_rate'] = hourly_pay_rate

        if weekly_salary_charge_amount:
            data['weekly_salary_charge_amount'] = weekly_salary_charge_amount

        if weekly_salary_pay_amount:
            data['weekly_salary_pay_amount'] = weekly_salary_pay_amount

        if weekly_stipend_hours:
            data['weekly_stipend_hours'] = weekly_stipend_hours

        if weekly_hours_limit:
            data['weekly_hours_limit'] = weekly_hours_limit

        if start_date:
            data['start_date'] = start_date

        if keep_open:
            assert_parameter('keep_open', keep_open,
                             self.JOB_KEEP_OPEN_OPTIONS)
            data['keep_open'] = keep_open

        return self.post(url, data)
コード例 #4
0
ファイル: hr.py プロジェクト: mdmitr/python-upwork
    def update_job(self,
                   job_id,
                   buyer_team_reference,
                   title,
                   description,
                   visibility,
                   category=None,
                   subcategory=None,
                   budget=None,
                   duration=None,
                   start_date=None,
                   status=None):
        """
        Update a job.

        *Parameters:*
          :job_id:                 Job reference ID

          :buyer_team_reference:   Reference ID of the buyer team that is
                                   posting the job, e.g. 34567

          :title:                  Title of the Job

          :description:            The job's description

          :visibility:             The job's visibility, e.g. 'private'.
                                   Possible values are:
                                     - 'public' jobs are available to all
                                       users who search jobs
                                     - 'private' job is visible to
                                       employer only
                                     - 'upwork' jobs appear in search
                                       results only for Upwork users
                                       who are logged into the service
                                     - 'invite-only' jobs do not appear
                                       in search and are used for jobs
                                       where the buyer wants to control
                                       the potential applicants

          :category:               (optional) The category of job, e.g.
                                   'Web Development'
                                   (where to get? - see Metadata API)

          :subcategory:            (optional) The subcategory of job, e.g.
                                   'Web Programming'
                                   (where to get? - see Metadata API)

          :budget:                 (conditionally optional) The budget of the
                                   Job, e.g. 100. Is used for 'fixed-price'
                                   jobs only.

          :duration:               (conditionally optional) The duration of the
                                   job in hours, e.g. 90. Used for
                                   'hourly-jobs' only.

          :start_date:             (optional) The start date of the Job,
                                   e.g. 06-15-2011. If start_date is not
                                   included the job will default to
                                   starting immediately.

          :status:                 (required) The status of the job,
                                   e.g. 'filled'.
                                   Possible values are:
                                   - 'open'
                                   - 'filled'
                                   - 'cancelled'

        """
        url = 'jobs/{0}'.format(job_id)
        data = {}

        data['buyer_team__reference'] = buyer_team_reference
        data['title'] = title
        data['description'] = description

        assert_parameter('visibility', visibility, self.JOB_VISIBILITY_OPTIONS)
        data['visibility'] = visibility

        data['category'] = category
        data['subcategory'] = subcategory

        if budget is None and duration is None:
            raise ApiValueError('Either one of the ``budget``or ``duration`` '
                                'parameters must be specified')

        if budget:
            data['budget'] = budget
        if duration:
            data['duration'] = duration
        if start_date:
            data['start_date'] = start_date

        if status:
            assert_parameter('status', status, self.JOB_STATUSES)
            data['status'] = status
        else:
            raise ApiValueError('Missing required parameter "status"')

        return self.put(url, data)
コード例 #5
0
ファイル: hr.py プロジェクト: mdmitr/python-upwork
    def post_job(self,
                 buyer_team_reference,
                 title,
                 job_type,
                 description,
                 visibility,
                 category=None,
                 subcategory=None,
                 budget=None,
                 duration=None,
                 start_date=None,
                 skills=None,
                 subcategory2=None):
        """
        Post a job.

        *Parameters:*
          :buyer_team_reference:   Reference ID of the buyer team that is
                                   posting the job, e.g. 34567

          :title:                  Title of the Job

          :job_type:               Type of posted job, e.g. "hourly"
                                   Possible values are:
                                     * 'hourly'
                                     * 'fixed-price'

          :description:            The job's description

          :visibility:             The job's visibility, e.g. 'private'.
                                   Possible values are:
                                     - 'public' jobs are available to all
                                       users who search jobs
                                     - 'private' job is visible to
                                       employer only
                                     - 'upwork' jobs appear in search
                                       results only for Upwork users
                                       who are logged into the service
                                     - 'invite-only' jobs do not appear
                                       in search and are used for jobs
                                       where the buyer wants to control
                                       the potential applicants

          :category:               (conditionally optional) The category of job, e.g. 'Web Development'
                                   (where to get? - see Metadata API)

          :subcategory:            (conditionally optional) The subcategory of job, e.g.
                                   'Web Programming'
                                   (where to get? - see Metadata API)

          :budget:                 (conditionally optional) The budget of the
                                   Job, e.g. 100. Is used for 'fixed-price'
                                   jobs only.

          :duration:               (conditionally optional) The duration of the
                                   job in hours, e.g. 90. Used for
                                   'hourly-jobs' only.

          :start_date:             (optional) The start date of the Job,
                                   e.g. 06-15-2011. If start_date is not
                                   included the job will default to
                                   starting immediately.

          :skills:                 (optional) Skills required for the job.
                                   Must be a list or tuple even of one item,
                                   e.g. ``['python']``

          :subcategory2:           (conditionally optional) The subcategory (V2) of job, e.g.
                                   'Web & Mobile Programming'
                                   (where to get? - see Metadata API, List Categories (V2))

        """
        url = 'jobs'
        data = {}

        data['buyer_team__reference'] = buyer_team_reference
        data['title'] = title

        assert_parameter('job_type', job_type, self.JOB_TYPES)
        data['job_type'] = job_type

        data['description'] = description

        assert_parameter('visibility', visibility, self.JOB_VISIBILITY_OPTIONS)
        data['visibility'] = visibility

        if (category is None or subcategory is None) and subcategory2 is None:
            raise ApiValueError(
                'Either one of the sub/category V1 or V2 parameters '
                'must be specified')
        if category:
            data['category'] = category

        if subcategory:
            data['subcategory'] = subcategory

        if subcategory2:
            data['subcategory2'] = subcategory2

        if budget is None and duration is None:
            raise ApiValueError('Either one of the ``budget``or ``duration`` '
                                'parameters must be specified')

        if budget:
            data['budget'] = budget
        if duration:
            data['duration'] = duration
        if start_date:
            data['start_date'] = start_date
        if skills:
            data['skills'] = ';'.join(skills)

        result = self.post(url, data)
        return result