Module veryfi.cli.w9s
CLI commands for W-9 documents.
Wraps :class:veryfi.w9s.W9s.
View Source
"""CLI commands for W-9 documents.
Wraps :class:`veryfi.w9s.W9s`.
"""
from __future__ import annotations
from typing import List, Optional
import typer
from veryfi.cli._common import (
emit,
get_client,
handle_errors,
merge_body,
parse_kv,
read_file_arg,
)
app = typer.Typer(
help="W-9 forms.",
no_args_is_help=True,
rich_markup_mode=None,
)
@app.command("process")
@handle_errors
def process(
ctx: typer.Context,
file: str = typer.Option(..., "--file", "-f"),
file_name: Optional[str] = typer.Option(None, "--file-name"),
fields: Optional[List[str]] = typer.Option(None, "--field"),
json_body: Optional[str] = typer.Option(None, "--json-body"),
) -> None:
"""Process a W-9 from a local file."""
client = get_client(ctx)
emit(
ctx,
client.process_w9_document(
file_path=read_file_arg(file),
file_name=file_name,
**merge_body(fields, json_body),
),
)
@app.command("process-url")
@handle_errors
def process_url(
ctx: typer.Context,
file_url: str = typer.Option(..., "--file-url"),
file_name: Optional[str] = typer.Option(None, "--file-name"),
fields: Optional[List[str]] = typer.Option(None, "--field"),
json_body: Optional[str] = typer.Option(None, "--json-body"),
) -> None:
"""Process a W-9 from a URL."""
client = get_client(ctx)
emit(
ctx,
client.process_w9_document_url(
file_url=file_url,
file_name=file_name,
**merge_body(fields, json_body),
),
)
@app.command("list")
@handle_errors
def list_w9s(
ctx: typer.Context,
created_date_gt: Optional[str] = typer.Option(None, "--created-gt"),
created_date_gte: Optional[str] = typer.Option(None, "--created-gte"),
created_date_lt: Optional[str] = typer.Option(None, "--created-lt"),
created_date_lte: Optional[str] = typer.Option(None, "--created-lte"),
extra: Optional[List[str]] = typer.Option(None, "--param"),
) -> None:
"""List previously processed W-9s."""
client = get_client(ctx)
emit(
ctx,
client.get_w9s(
created_date_gt=created_date_gt,
created_date_gte=created_date_gte,
created_date_lt=created_date_lt,
created_date_lte=created_date_lte,
**parse_kv(extra),
),
)
@app.command("get")
@handle_errors
def get_w9(
ctx: typer.Context,
document_id: int = typer.Argument(...),
extra: Optional[List[str]] = typer.Option(None, "--param"),
) -> None:
"""Fetch a single W-9 by ID."""
client = get_client(ctx)
emit(ctx, client.get_w9(document_id=document_id, **parse_kv(extra)))
@app.command("delete")
@handle_errors
def delete_w9(
ctx: typer.Context,
document_id: int = typer.Argument(...),
) -> None:
"""Delete a W-9."""
client = get_client(ctx)
client.delete_w9(document_id=document_id)
emit(ctx, {"deleted": document_id})
Variables
app
Functions
delete_w9
def delete_w9(
ctx: 'typer.Context',
document_id: 'int' = <typer.models.ArgumentInfo object at 0x7f078bb866d0>
) -> 'None'
Delete a W-9.
View Source
@app.command("delete")
@handle_errors
def delete_w9(
ctx: typer.Context,
document_id: int = typer.Argument(...),
) -> None:
"""Delete a W-9."""
client = get_client(ctx)
client.delete_w9(document_id=document_id)
emit(ctx, {"deleted": document_id})
get_w9
def get_w9(
ctx: 'typer.Context',
document_id: 'int' = <typer.models.ArgumentInfo object at 0x7f078bb865b0>,
extra: 'Optional[List[str]]' = <typer.models.OptionInfo object at 0x7f078bb86610>
) -> 'None'
Fetch a single W-9 by ID.
View Source
@app.command("get")
@handle_errors
def get_w9(
ctx: typer.Context,
document_id: int = typer.Argument(...),
extra: Optional[List[str]] = typer.Option(None, "--param"),
) -> None:
"""Fetch a single W-9 by ID."""
client = get_client(ctx)
emit(ctx, client.get_w9(document_id=document_id, **parse_kv(extra)))
list_w9s
def list_w9s(
ctx: 'typer.Context',
created_date_gt: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb86340>,
created_date_gte: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb863a0>,
created_date_lt: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb86400>,
created_date_lte: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb86460>,
extra: 'Optional[List[str]]' = <typer.models.OptionInfo object at 0x7f078bb864c0>
) -> 'None'
List previously processed W-9s.
View Source
@app.command("list")
@handle_errors
def list_w9s(
ctx: typer.Context,
created_date_gt: Optional[str] = typer.Option(None, "--created-gt"),
created_date_gte: Optional[str] = typer.Option(None, "--created-gte"),
created_date_lt: Optional[str] = typer.Option(None, "--created-lt"),
created_date_lte: Optional[str] = typer.Option(None, "--created-lte"),
extra: Optional[List[str]] = typer.Option(None, "--param"),
) -> None:
"""List previously processed W-9s."""
client = get_client(ctx)
emit(
ctx,
client.get_w9s(
created_date_gt=created_date_gt,
created_date_gte=created_date_gte,
created_date_lt=created_date_lt,
created_date_lte=created_date_lte,
**parse_kv(extra),
),
)
process
def process(
ctx: 'typer.Context',
file: 'str' = <typer.models.OptionInfo object at 0x7f078bb86d00>,
file_name: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb86cd0>,
fields: 'Optional[List[str]]' = <typer.models.OptionInfo object at 0x7f078bb86ca0>,
json_body: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb86c70>
) -> 'None'
Process a W-9 from a local file.
View Source
@app.command("process")
@handle_errors
def process(
ctx: typer.Context,
file: str = typer.Option(..., "--file", "-f"),
file_name: Optional[str] = typer.Option(None, "--file-name"),
fields: Optional[List[str]] = typer.Option(None, "--field"),
json_body: Optional[str] = typer.Option(None, "--json-body"),
) -> None:
"""Process a W-9 from a local file."""
client = get_client(ctx)
emit(
ctx,
client.process_w9_document(
file_path=read_file_arg(file),
file_name=file_name,
**merge_body(fields, json_body),
),
)
process_url
def process_url(
ctx: 'typer.Context',
file_url: 'str' = <typer.models.OptionInfo object at 0x7f078bb86040>,
file_name: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb86130>,
fields: 'Optional[List[str]]' = <typer.models.OptionInfo object at 0x7f078bb861f0>,
json_body: 'Optional[str]' = <typer.models.OptionInfo object at 0x7f078bb86250>
) -> 'None'
Process a W-9 from a URL.
View Source
@app.command("process-url")
@handle_errors
def process_url(
ctx: typer.Context,
file_url: str = typer.Option(..., "--file-url"),
file_name: Optional[str] = typer.Option(None, "--file-name"),
fields: Optional[List[str]] = typer.Option(None, "--field"),
json_body: Optional[str] = typer.Option(None, "--json-body"),
) -> None:
"""Process a W-9 from a URL."""
client = get_client(ctx)
emit(
ctx,
client.process_w9_document_url(
file_url=file_url,
file_name=file_name,
**merge_body(fields, json_body),
),
)