Guide to adding an object with the API
Prerequistites
This guide assumes you are authenticated and have a valid token.
The simplified steps you need to take are:
- Add a company with the mutation
addCompany
. - Fetch categories to find out the
id
of the category the object should be placed in, with the querycategoryGroups
. - Add an object with the mutation
addObject
. - When the object is sold, call the mutation
deleteObject
.
The examples in this guide do not take error handling into account.
Adding a company
If you act as an intermediary for multiple companies that want to push equipment, you need to call the mutation addCompany
for each company. If you only manage your own company, you should just call it once.
The mutation addCompany
expects information about the company and its location. The mutation should look something like this:
mutation AddCompany {
addCompany(
input: {
chamberOfCommerceNumber: "63204258"
name: "Beequip"
street: "Willemskade"
houseNumber: "18"
postalCode: "3016 DL"
city: "Rotterdam"
telephoneNumber: "010 340 0844"
website: "https://beequip.com"
emailAddress: "info@example.com"
}
) {
... on AddCompanySuccess {
company {
id
url
}
}
}
}
When this example mutation is executed, it wil return the id
and url
of the newly created company.
Since GraphQL gives you control of what data you request, you can select more fields of the company to be returned.
We will be notified if you add a new company, and will review if we want them on our marketplace.
Fetching categories
When adding an object, we need an id
of the category the object belongs to. You can fetch a list of categories we use:
query Categories {
categoryGroups {
id
name
categories {
id
name
}
}
}
The result is a list of categories, for example:
{
"data": {
"categoryGroups": [
{
"id": "1",
"name": "Agrarisch",
"categories": [
{
"id": "1",
"name": "Agrarisch transport"
}
]
},
{
"id": "9",
"name": "Kranen",
"categories": [
{
"id": "19",
"name": "Mobiele telescoopkraan"
}
]
}
]
}
}
You can use these id
’s to make an internal mapping of your categories to our categories.
Adding an object
To publish a piece of equipment on our marketplace, call the mutation addObject
. An example:
mutation AddObject {
addObject(
input: {
companyId: 1
brand: "DAF"
type: "XF 480"
categoryId: 9
purchasePrice: { publicPurchasePrice: 40000 }
used: true
yearOfConstruction: 2022
}
) {
... on AddObjectSuccess {
object {
id
url
}
}
}
}
addObject
accepts loads more properties than this example shows. The more
properties you send, the better the conversion rate on our marketplace. Use
your GraphQL tool to find the input type AddObjectInput
and see what data
you can send.
Deleting an object
When an object is sold or no longer in the company’s inventory, you need to call deleteObject
. This will soft-delete the object: the URL will still be accessible, but the object will no longer appear in searches and overviews on our marketplace.
mutation DeleteObject {
deleteObject(input: { id: 1 }) {
... on DeleteObjectSuccess {
company {
url
}
}
}
}