Schema Querying
The DealCloud API allows you to query the schema of a given site. The DealCloud
class provides access to the schema endpoints through the following methods:
The schema models are defined using Pydantic (opens in a new tab), for clear validation, straightforward attribute access and IDE assistance.
Get Users
DealCloud.get_users()
will return all users in the site. Specifically, an array of User
objects. The argument: active_only
is a boolean that can be passed, if true, the function will only return active users.
Example:
from dealcloud_sdk import DealCloud
dc = DealCloud.from_yaml("path/to/yaml_config_file.json")
users = dc.get_users()
for user in users:
print(f"{user.name}: {user.email}")
Will output:
User 1: user1@email.com
User 2: user2@email.com
User 3: user3@email.com
User 4: user4@email.com
...etc
Get Currencies
DealCloud.get_currencies()
will return the currency codes of all enabled currencies in the site.
Example:
from dealcloud_sdk import DealCloud
dc = DealCloud.from_yaml("path/to/yaml_config_file.json")
currencies = dc.get_currencies()
for ccy in currencies:
print(ccy)
Will output:
GBP
USD
EUR
...etc
Get Objects
DealCloud.get_object()
will return all configured objects in the site. Specifically, an array of Object
objects.
Example:
from dealcloud_sdk import DealCloud
dc = DealCloud.from_yaml("path/to/yaml_config_file.json")
objects = dc.get_objects()
for obj in objects:
print(f"{obj.apiName}: {obj.pluralName}, {obj.singularName}")
Will output:
Company: Companies, Company
Contact: Contacts, Contact
CompanyAddress: Company Addresses, Company Address
...etc
Get Fields
DealCloud.get_fields()
provides the ability to return fields configured in the site. Specifically, an array of Field
objects.
There are three ways to query for fields:
- All Fields: call
DealCloud.get_fields()
with no arguments to return all fields.
from dealcloud_sdk import DealCloud
dc = DealCloud.from_yaml("path/to/yaml_config_file.json")
fields = dc.get_fields()
fields
will contain a list of Field
objects containing all configured fields in the site.
- All Fields for an Object: call
DealCloud.get_fields(object_id="ObjectName")
withobject_id
set to the desired object api name, or object id, to return all fields configured for that object.
from dealcloud_sdk import DealCloud
dc = DealCloud.from_yaml("path/to/yaml_config_file.json")
fields = dc.get_fields("Company")
fields
will contain a list of Field
objects, containing all fields configured in the "Company" object.
- A Field by Field ID: call
DealCloud.get_fields(field_id=1234)
withfield_id
set to the ID of the desired field.
from dealcloud_sdk import DealCloud
dc = DealCloud.from_yaml("path/to/yaml_config_file.json")
field = dc.get_fields(field_id=1234)
field
will contain a single Field
object, describing the field with ID 1234
.
Get Schema
DealCloud.get_schema()
is a method that will return the full DealCloud schema in a single object.
The method takes the argument: key_type
, which describes which field will be used as keys in the nested object structure describing the schema.
The options are:
api
- The API namedisplay
- The display nameid
- The object/field ID
Usage Example:
from dealcloud_sdk import DealCloud
dc = DealCloud.from_yaml("path/to/yaml_config_file.json")
schema = dc.get_schema("api")
schema
will contain the a Schema
object with the API names as keys, as below:
api
Example:
{
"CompanyAPIName": {
"CompanyObjectMetaData": "...",
"CompanyObjectFields": {
"Field1APIName": {
"Field1MetaData": "..."
}
}
}
}
display
Example:
{
"Company Display Name": {
"CompanyObjectMetaData": "...",
"CompanyObjectFields": {
"Field 1 Display Name": {
"Field1MetaData": "..."
}
}
}
}
id
Example:
Note the ID of the "Company" object is 12345 and the ID of the "Field 1" field is 123456
{
12345: {
"CompanyObjectMetaData": "...",
"CompanyObjectFields": {
123456: {
"Field1MetaData": "..."
}
}
}
}