示例#1
0
def minor_major():
    """Request for major/minor change"""
    try:
        req_json = request.get_json(force=True)
    except TypeError:
        return jsonify(message='Invalid json input'), 400

    student = req_json['student']
    envelope_args = {
        'signer_client_id': 1000,
        'ds_return_url': req_json['callback-url']
    }

    try:
        # Create envelope
        envelope = DsDocument.create('minor-major.html', student,
                                     envelope_args)
        # Submit envelope to the Docusign
        envelope_id = Envelope.send(envelope, session)
    except ApiException as exc:
        return process_error(exc)

    user_documents = session.get('ds_documents')
    if not user_documents:
        session['ds_documents'] = [envelope_id]
    else:
        session['ds_documents'].append(envelope_id)

    try:
        # Get the recipient view
        result = Envelope.get_view(envelope_id, envelope_args, student,
                                   session)
    except ApiException as exc:
        return process_error(exc)
    return jsonify({'envelope_id': envelope_id, 'redirect_url': result.url})
示例#2
0
def buy_new_insurance():
    """Request for the purchase of a new insurance"""
    try:
        req_json = request.get_json(force=True)
        insurance_info = req_json['insurance']
        user = req_json['user']

        envelope_args = {
            'signer_client_id': 1000,
            'ds_return_url': req_json['callback-url'],
            'gateway_account_id': DsConfig.gateway_id(),
            'gateway_name': DsConfig.gateway_name(),
            'gateway_display_name': DsConfig.gateway_display_name()
        }
    except TypeError:
        return jsonify(message='Invalid JSON input'), 400

    try:
        # Create envelope with payment
        envelope = DsDocument.create_with_payment('new-insurance.html', user,
                                                  insurance_info,
                                                  envelope_args)
        # Submit envelope to the Docusign
        envelope_id = Envelope.send(envelope)
        user_documents = session.get('ds_documents')
        if not user_documents:
            session['ds_documents'] = [envelope_id]
        else:
            user_documents.append(envelope_id)
            session['ds_documents'] = user_documents
        # Get the recipient view
        result = Envelope.get_view(envelope_id, envelope_args, user)
    except ApiException as ex:
        return process_error(ex)
    return jsonify({'envelope_id': envelope_id, 'redirect_url': result.url})
def submit_claim():
    """Submit a claim"""
    try:
        req_json = request.get_json(force=True)
    except TypeError:
        return jsonify(message='Invalid JSON input'), 400

    claim = req_json['claim']
    envelope_args = {
        'signer_client_id': 1000,
        'ds_return_url': req_json['callback-url'],
    }

    try:
        # Create envelope
        envelope = DsDocument.create_claim('submit-claim.html', claim, envelope_args)
        # Submit envelope to the Docusign
        envelope_id = Envelope.send(envelope, session)
    except ApiException as exc:
        return process_error(exc)

    SessionData.set_ds_documents(envelope_id)

    try:
        # Get the recipient view
        result = Envelope.get_view(envelope_id, envelope_args, claim, session)
    except ApiException as exc:
        return process_error(exc)
    return jsonify({'envelope_id': envelope_id, 'redirect_url': result.url})
示例#4
0
def submit_claim():
    """Submit a claim"""
    try:
        req_json = request.get_json(force=True)
        claim = req_json['claim']
        envelope_args = {
            'signer_client_id': 1000,
            'ds_return_url': req_json['callback-url'],
        }
    except TypeError:
        return jsonify(message='Invalid JSON input'), 400

    try:
        # Create envelope
        envelope = DsDocument.create_claim('submit-claim.html', claim,
                                           envelope_args)
        # Submit envelope to the Docusign
        envelope_id = Envelope.send(envelope)
        user_documents = session.get('ds_documents')
        if not user_documents:
            session['ds_documents'] = [envelope_id]
        else:
            user_documents.append(envelope_id)
            session['ds_documents'] = user_documents

        # Get the recipient view
        result = Envelope.get_view(envelope_id, envelope_args, claim)
    except ApiException as ex:
        return process_error(ex)
    return jsonify({'envelope_id': envelope_id, 'redirect_url': result.url})
def payment_activity():
    """Request for extra-curricular activity"""
    try:
        req_json = request.get_json(force=True)
        activity_info = req_json['activity']
        student = req_json['student']
        envelope_args = {
            'signer_client_id': 1000,
            'ds_return_url': req_json['callback-url'],
            'gateway_account_id': DsConfig.gateway_id(),
            'gateway_name': DsConfig.gateway_name(),
            'gateway_display_name': DsConfig.gateway_display_name()
        }
    except TypeError:
        return jsonify(message='Invalid json input'), 400

    try:
        # Create envelope with payment
        envelope = DsDocument.create_with_payment('payment-activity.html',
                                                  student, activity_info,
                                                  envelope_args)
        # Submit envelope to Docusign
        envelope_id = Envelope.send(envelope)
        user_documents = session.get('ds_documents')
        if not user_documents:
            session['ds_documents'] = [envelope_id]
        else:
            user_documents.append(envelope_id)
            session['ds_documents'] = user_documents
        # Get the recipient view
        result = Envelope.get_view(envelope_id, envelope_args, student)
    except ApiException as ex:
        return process_error(ex)
    return jsonify({'envelope_id': envelope_id, 'redirect_url': result.url})
示例#6
0
def multi_signers():
    try:
        req_json = request.get_json(force=True)
        student = req_json['student']
        envelope_args = {
            "signer_client_id":
            1000,
            "ds_return_url":
            req_json['callback-url'],
            "account_id":
            req_json['account-id'],
            "base_path":
            req_json['base-path'],
            'access_token':
            request.headers.get('Authorization').replace('Bearer ', '')
        }
    except TypeError:
        return jsonify(message="Invalid JSON input"), 400

    try:
        envelope = Envelope.create('multi-sign.html', student, envelope_args)
        envelope_id = Envelope.send(envelope, envelope_args)
        result = Envelope.get_view(envelope_id, envelope_args, student)
    except ApiException as e:
        return jsonify({'error': e.body.decode('utf-8')}), 400
    return jsonify({"envelope_id": envelope_id, "redirect_url": result.url})
示例#7
0
def envelope_download():
    """Request for document download from the envelope"""
    try:
        envelope_args = {
            'envelope_id': request.args['envelope-id'],
            "document_id": request.args['document-id'],
        }
    except TypeError:
        return jsonify(message="Invalid JSON input"), 400
    try:
        envelope_file = Envelope.download(envelope_args)
    except ApiException as e:
        return process_error(e)
    return envelope_file
def buy_new_insurance():
    """Request for the purchase of a new insurance"""
    try:
        req_json = request.get_json(force=True)
    except TypeError:
        return jsonify(message='Invalid JSON input'), 400

    insurance_info = req_json['insurance']
    user = req_json['user']

    envelope_args = {
        'signer_client_id': 1000,
        'ds_return_url': req_json['callback-url'],
        'gateway_account_id': session.get('payment_gateway_account_id'),
        'gateway_name': session.get('payment_gateway'),
        'gateway_display_name': session.get('payment_display_name')
    }

    try:
        # Create envelope with payment
        envelope = DsDocument.create_with_payment(
            'new-insurance.html', user, insurance_info, envelope_args
        )
        # Submit envelope to the Docusign
        envelope_id = Envelope.send(envelope, session)
    except ApiException as exc:
        return process_error(exc)

    SessionData.set_ds_documents(envelope_id)

    try:
        # Get the recipient view
        result = Envelope.get_view(envelope_id, envelope_args, user, session)
    except ApiException as exc:
        return process_error(exc)
    return jsonify({'envelope_id': envelope_id, 'redirect_url': result.url})
示例#9
0
def envelope_list():
    """Request for envelope list"""
    try:
        envelope_args = {'from_date': request.args.get('from-date')}
    except TypeError:
        return jsonify(message='Invalid JSON input'), 400

    try:
        user_documents = session.get('ds_documents')
        if not user_documents:
            user_documents = []
        envelopes = Envelope.list(envelope_args, user_documents)
    except ApiException as ex:
        return process_error(ex)
    return jsonify({'envelopes': envelopes})
示例#10
0
def envelope_list():
    try:
        req_json = request.get_json(force=True)
        envelope_args = {
            'account_id': req_json['account-id'],
            'from_date': req_json['from-date'],
            "base_path": req_json['base-path'],
            'access_token': request.headers.get('Authorization').replace('Bearer ', '')
        }
    except TypeError:
        return jsonify(message="Invalid json input"), 400

    try:
        envelopes_information = Envelope.list(envelope_args)
    except ApiException as e:
        return jsonify({'error': e.body.decode('utf-8')}), 400
    return jsonify({"envelopes": envelopes_information.to_dict()})