InquiryBuilder
The `InquiryBuilder` is a fluent builder for creating requests for contract-based Generic Inquiries. These are specific inquiry "forms" that require parameters to be sent in the body of a `PUT` request, rather than in the URL.
Importing the Builder
To get started, import the `InquiryBuilder` from the `easy_acumatica.models` module.
from easy_acumatica.models.inquiry_builder import InquiryBuilder
Builder Methods
.param(field, value)
Adds a parameter to the request body. These parameters correspond to the fields on the inquiry form in Acumatica.
builder = (
InquiryBuilder()
.param("InventoryID", "SIMCARD")
.param("WarehouseID", "YOGI")
)
.expand(*entities)
Specifies one or more detail entities to expand in the response. For most inquiries, you will need to expand the `Results` entity to get the actual data rows.
builder.expand("Results", "Totals")
# This will generate a query string like: ?$expand=Results,Totals
.to_body()
and .to_query_params()
These methods generate the final dictionaries used by the `InquiriesService`. `.to_body()` creates the JSON body for the `PUT` request, and `.to_query_params()` creates the URL query string (for the `$expand` parameter).
Complete Example
Here is a complete example showing how to use the `InquiryBuilder` with the `InquiriesService` to fetch data from the `InventorySummaryInquiry` form.
# 1. Build the inquiry options
opts = (
InquiryBuilder()
.param("InventoryID", "SIMCARD")
.expand("Results")
)
# 2. Use the builder with the InquiriesService
inventory_summary = client.inquiries.get_data_from_inquiry_form(
"24.200.001",
"InventorySummaryInquiry",
opts
)
# 3. Process the results
for row in inventory_summary.get("Results", []):
print(row)