def assign_form_to_form_group():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """

    # 1. Get required arguments
    args = Eg009Controller.get_args()

    try:
        # 2. Call the worker method to create a new form group
        results = Eg009Controller.worker(args)
        current_app.logger.info(
            f"""Form "{args['form_id']}" has been assigned to 
            Form Group "{args['form_group_id']}"!""")
        results = results.to_dict()
    except ApiException as err:
        return process_error(err)
    except ValueError as err:
        msg = ("Response is empty and could not be cast to"
               " FormGroupFormToAssign. Please contact DocuSign support.")
        current_app.logger.info(msg)
        results = {"error": msg}

    # 3. Render the response
    return render_template(
        "example_done.html",
        title="Assigning form a form group",
        h1="Creating a form group",
        message=f"""Form "{args['form_id']}" has been assigned to 
        Form Group "{args['form_group_id']}"!""",
        json=json.dumps(json.dumps(results, default=str)))
示例#2
0
def create_external_form_fill_session():
    """
    1. Get required arguments
    2. Call the worker method
    3. Show URL for a new external form fill session
    """
    # 1. Get required arguments
    args = Eg006Controller.get_args()

    try:
        # 2. Call the worker method
        results = Eg006Controller.worker(args)
    except ApiException as err:
        return process_error(err)

    # 3. Show URL for a new external form fill session
    return render_template(
        "example_done.html",
        title="Create an external form fill session",
        h1="URL for a new external form fill session",
        message="Results from the Forms::CreateExternalFormFillSession:",
        json=json.dumps(json.dumps(results.to_dict(), default=str)),
        link=results.url,
        link_text="Please fill the form"
    )
示例#3
0
def get_forms():
    """
    1. Get required arguments
    2. Get forms
    3. Get room name
    4. Render the response
    """
    # 1. Get required arguments
    args = Eg006Controller.get_args()
    try:
        # 2. Get forms
        forms = Eg006Controller.get_forms(args)

        # 3. Get room name
        room = Eg006Controller.get_room(args)
    except ApiException as err:
        return process_error(err)

    # 4. Render the response
    return render_template(
        "eg006_create_external_form_fill_session.html",
        title="Create an external form fill session",
        source_file=path.basename(path.dirname(__file__)) + "/controller.py",
        forms=forms,
        room_id=args["room_id"],
        room_name=room.name
    )
示例#4
0
def create_room_with_data():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """
    # 1. Get required arguments
    args = Eg001Controller.get_args()

    try:
        # 2. Call the worker method to create a new room
        results = Eg001Controller.worker(args)
        room_id = results.room_id
        current_app.logger.info(
            f"""Room "{args['room_name']}" has been created! Room ID: {room_id}"""
        )
    except ApiException as err:
        return process_error(err)

    # 3. Render the response
    return render_template(
        "example_done.html",
        title="Creating a room with data",
        h1="Creating a room with data",
        message=f"""The room "{args['room_name']}" has been created!<br/> 
                        Room ID: {room_id}.""",
        json=json.dumps(json.dumps(results.to_dict(), default=str))
    )
示例#5
0
def activate_clickwrap():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """
    # 1. Get required arguments
    args = Eg002Controller.get_args()

    try:
        # 2. Call the worker method to create a new clickwrap
        results = Eg002Controller.worker(args)
        current_app.logger.info(
            f"""The clickwrap "{args['clickwrap_name']}" has been activated!"""
        )
    except ApiException as err:
        return process_error(err)

    # Save for use by other examples which need an clickwrap params.
    session["clickwrap_is_active"] = True

    # 3. Render the response
    return render_template(
        "example_done.html",
        title="Activating a clickwrap",
        h1="Activating a clickwrap",
        message=
        f"""The clickwrap "{args['clickwrap_name']}" has been activated!""",
        json=json.dumps(json.dumps(results.to_dict(), default=str)))
示例#6
0
def create_new_clickwrap_version():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """
    # 1. Get required arguments
    args = Eg003Controller.get_args()

    try:
        # 2. Call the worker method to create a new clickwrap version
        results = Eg003Controller.worker(args)
        current_app.logger.info(
            f"""The 2nd version of clickwrap "{args['clickwrap_name']}" has been created!"""
        )
    except ApiException as err:
        return process_error(err)

    # 3. Render the response
    return render_template(
        "example_done.html",
        title="Creating a new clickwrap version",
        h1="Creating a new clickwrap version",
        message=
        f"""The 2nd version of clickwrap "{args['clickwrap_name']}" has been created!""",
        json=json.dumps(json.dumps(results.to_dict(), default=str)))
示例#7
0
def get_view():
    """
    1. Get required arguments
    2. Get room templates
    3. Set filtering parameters
    4. Render the response
    """
    # 1. Get required arguments
    args = Eg005Controller.get_args()

    try:
        # 2. Get room templates
        rooms = Eg005Controller.get_rooms(args)
    except ApiException as err:
        return process_error(err)

    # 3. Set filtering parameters
    start_date = datetime.today() - timedelta(days=10)
    end_date = datetime.today() + timedelta(days=1)

    # 4. Render the response
    return render_template("eg005_get_rooms_with_filters.html",
                           title="Getting rooms with filters",
                           source_file=path.basename(path.dirname(__file__)) +
                           "/controller.py",
                           rooms=rooms,
                           start=start_date.strftime("%Y-%m-%d"),
                           end=end_date.strftime("%Y-%m-%d"))
示例#8
0
def assign_office_to_form_group():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """

    args = Eg008Controller.get_args()

    try:
        # 2. Call the worker method to assign office to form group
        Eg008Controller.worker(args)
        current_app.logger.info(
            f"""Office {args['office_id']} has been assigned to Form Group
            {args['form_group_id']}!""")
    except ApiException as err:
        return process_error(err)

    # 3. Render the response
    return render_template(
        "example_done.html",
        title="Assign office to a form group",
        h1="Assign office to a form group",
        message=f"""Office "{args['office_id']}" has been assigned to 
        Form Group "{args['form_group_id']}" """,
    )
示例#9
0
def create_form_group():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """

    # 1. Get required arguments
    args = Eg007Controller.get_args()

    try:
        # 2. Call the worker method to create a new form group
        results = Eg007Controller.worker(args)
        form_id = results.form_group_id
        current_app.logger.info(
            f"""Form Group "{args['form_group_name']}" has been created! 
            Form Group ID: {form_id}""")
    except ApiException as err:
        return process_error(err)

    # 3. Render the response
    return render_template(
        "example_done.html",
        title="Creating a form group",
        h1="Creating a form group",
        message=
        f"""The Form Group "{args['form_group_name']}" has been created!<br/> 
                            Room ID: {form_id}.""",
        json=json.dumps(json.dumps(results.to_dict(), default=str)))
示例#10
0
def get_monitoring_data():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """

    # 1. Get required arguments
    args = Eg001Controller.get_args()
    try:
        # 2. Call the worker method to get your monitor data
        results = Eg001Controller.worker(args)
        current_app.logger.info(f"""Got your monitor data""")
    except ApiException as err:
        return process_error(err)

    return render_template("example_done.html",
                           title="Get monitoring data",
                           h1="Get monitoring data",
                           json=json.dumps(json.dumps(results, default=str)))
示例#11
0
def clickwrap_list():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """
    # 1. Get required arguments
    args = Eg004Controller.get_args()

    try:
        # 2. Call the worker method to get a list of clickwraps
        results = Eg004Controller.worker(args)
    except ApiException as err:
        return process_error(err)

    # 3. Render the response
    return render_template(
        "example_done.html",
        title="List clickwraps results",
        h1="List clickwraps results",
        message="Results from the ClickWraps::getClickwraps method:",
        json=json.dumps(json.dumps(results.to_dict(), default=str)))
def get_view():
    """
    1. Get required arguments
    2. Get rooms
    3. Render the response
    """
    # 1. Get required arguments
    args = Eg003Controller.get_args()

    try:
        # 2. Get rooms
        rooms = Eg003Controller.get_rooms(args)
    except ApiException as err:
        return process_error(err)

    # 3. Render the response
    return render_template(
        "eg003_export_data_from_room.html",
        title="Exporting data from a room",
        source_file=path.basename(path.dirname(__file__)) + "/controller.py",
        rooms=rooms,
    )
def get_field_data_from_room():
    """
    1. Get required arguments
    2. Call the worker method
    3. Render the response
    """
    # 1. Get required arguments
    args = Eg003Controller.get_args()

    try:
        # 2. Call the worker method
        results = Eg003Controller.worker(args)
    except ApiException as err:
        return process_error(err)

    # 3. Show field data
    return render_template(
        "example_done.html",
        title="Field data associated with a room",
        h1="Field data associated with a room",
        message="Results from the Rooms::GetRoomFieldData method:",
        json=json.dumps(json.dumps(results.to_dict())))
示例#14
0
def get_rooms_with_filters():
    """
    1. Get required arguments
    2. Call the worker method
    3. Show filtered rooms
    """
    # 1. Get required arguments
    args = Eg005Controller.get_args()

    try:
        # 2. Call the worker method
        results = Eg005Controller.worker(args)
    except ApiException as err:
        return process_error(err)

    # 3. Show filtered rooms
    return render_template(
        "example_done.html",
        title="Rooms filtered by date",
        h1=f"""Rooms that have had their field data, updated within the time 
            period between {args["start_date"]} and {args["end_date"]}""",
        message="Results from the Rooms::GetRooms method:",
        json=json.dumps(json.dumps(results.to_dict(), default=str)))