@simpleview/sv-crm3-api-client
v1.0.0
Published
Client for communicating with sv-crm3-api
Maintainers
Keywords
Readme
sv-crm3-api-client
Client library for interacting with the sv-crm3-api GraphQL system.
It is built in TypeScript and has one peer dependency of @simpleview/sv-graphql-client.
OS Support
The expectation is that this application will be installed in Linux using sv-kubernetes.
Prerequisites
Install
Using npm:
npm install @simpleview/sv-crm3-api-clientUsing yarn:
yarn install @simpleview/sv-crm3-api-clientUpdate
To update to the latest version, rerun the install command:
Authentication Requirements
Interactions with sv-crm3-api require authentication as a Simpleview user or a user of the account.
Use a Google Service Account when interacting with the service on behalf of a product.
const { AuthPrefix } = require("@simpleview/sv-auth-client");
const { GraphServer } = require("@simpleview/sv-graphql-client");
async function serviceAccountToken() {
const service_account = JSON.parse(SERVICE_ACCOUNT_JSON);
const { auth } = new GraphServer({
graphUrl: AUTH_GRAPHQL_URL,
prefixes: [AuthPrefix]
});
// authorize the service_account return the token
const { token } = await auth.login_service_account({
input: {
email: service_account.client_email,
private_key: service_account.private_key
},
fields: `
success
token
`
});
return token;
}The token should be added to the context for each function call.
Implementation & Usage
To see the input parameters and output fields of an endpoint, view the Schema in the GraphQL Explorer at https://graphql.simpleviewinc.com/ for the corresponding GraphQL query
Crm3Prefix
Crm3Prefix can be loaded into the sv-graphql-client GraphServer to use as a client library for accessing crm3 in GraphQL.
JavaScript:
const { Crm3Prefix } = require("@simpleview/sv-crm3-api-client");
const { GraphServer } = require("@simpleview/sv-graphql-client");
module.exports = new GraphServer({ graphUrl: GRAPHQL_URL, prefixes: [Crm3Prefix] });TypeScript:
import { Crm3Prefix } from "@simpleview/sv-crm3-api-client";
import { GraphServer } from "@simpleview/sv-graphql-client";
export default new GraphServer({ graphUrl: GRAPHQL_URL, prefixes: [Crm3Prefix] });Where you are making server requests:
JavaScript:
const { crm3 } = require("./crm3GraphServer");TypeScript:
import { crm3 } from "./crm3GraphServer";Crm3Prefix.eei_types
This method Wraps the crm3.eei_types GraphQL query.
const result = await crm3.eei_types({
fields: `
count
docs {
id
label
group_id
active
sort_order
}
`,
context: {
acct_id: "your_acct_id",
token // from login or serviceAccountToken call
}
});Crm3Prefix.lead_statuses
This method wraps the crm3.lead_statuses GraphQL query.
const result = await crm3.lead_statuses({
fields: `
count
docs {
id
group_id
label
type
show_on_extranet
postponed
active
sort_order
}
`,
context: {
acct_id: "your_acct_id",
token // from login or serviceAccountToken call
}
});Crm3Prefix.listing_categories
This method wraps the crm3.listing_categories GraphQL query.
const result = await crm3.listing_categories({
fields: `
count
docs {
id
type_id
label
active
sort_order
}
`,
context: {
acct_id: "your_acct_id",
token // from login or serviceAccountToken call
}
});Crm3Prefix.listing_ranks
This method wraps the crm3.listing_ranks GraphQL query.
const result = await crm3.listing_ranks({
fields: `
count
docs {
id
label
group_id
active
character_count
sort_order
}
`,
context: {
acct_id: "your_acct_id",
token // from login or serviceAccountToken call
}
});Crm3Prefix.listing_sub_categories
This method wraps the crm3.listing_sub_categories GraphQL query.
const result = await crm3.listing_sub_categories({
fields: `
count
docs {
id
label
category_id
description
active
sort_order
}
`,
context: {
acct_id: "your_acct_id",
token // from login or serviceAccountToken call
}
});Crm3Prefix.listing_types
This method wraps the crm3.listing_types GraphQL query.
const result = await crm3.listing_types({
fields: `
count
docs {
id
label
group_id
active
show_on_website
show_on_referrals
show_on_benefits_summary
allow_media
show_on_extranet
sort_order
}
`,
context: {
acct_id: "your_acct_id",
token // from login or serviceAccountToken call
}
});Crm3Prefix.listings
This method wraps the crm3.listings GraphQL query.
const result = await crm3.listings({
filter: {
id: 123,
company: "Acme Corp",
created_date: {
gte: "2024-01-01T00:00:00.000Z",
lte: "2024-12-31T00:00:00.000Z"
}
},
options: {
limit: 50,
skip: 0
},
fields: `
count
docs {
id
type_id
category_id
sub_category_id
account_id
contact_id
company
address_line_1
address_line_2
city
state
zip
country
email
website
primary_phone
description
created_date
}
`,
context: {
acct_id: "your_acct_id",
token // from login or serviceAccountToken call
}
});Crm3Prefix.leads
This method wraps the crm3.leads GraphQL query.
const result = await crm3.leads({
filter: {
id: 12,
status_id: 5,
hotel_response_date: {
gte: "2024-01-01",
lte: "2024-12-31"
}
created_date: {
gte: "2024-01-01T00:00:00.000Z",
lte: "2024-12-31T00:00:00.000Z"
}
},
options: {
limit: 50,
skip: 100
},
fields: `
count
docs {
id
meeting_name
account_id
account_name
contact_id
contact_name
eei_type_id
eei_type
status_id
status_name
hotel_response_date
room_attendees
show_attendees
block_start
block_end
requested_room_nights
sales_manager
created_date
}
`,
context: {
acct_id: "149",
token // from login or serviceAccountToken call
}
});Crm3Prefix.leads_insert
This method wraps the crm3.leads_insert GraphQL mutation.
const result = await crm3.leads_insert({
input: {
data: {
meeting_name: "New Lead",
account_id: 149,
contact_id: 84626,
status_id: 6, # "Lead" status type. Currently the only status type supported.
eei_type_id: 279,
sales_manager_id: 1,
room_attendees: 200,
show_attendees: 400,
meeting_dates: {
start: "2026-01-01T00:00:00Z",
end: "2026-01-02T00:00:00Z",
is_primary: true
},
hotel_response_due: "2026-01-01"
}
},
fields: `
success
message
doc {
lead_id
}
`,
context: {
acct_id: "149",
token // from login or serviceAccountToken call
}
});Crm3Prefix.leads_update
This method wraps the crm3.leads_update GraphQL mutation.
const result = await crm3.leads_update({
input: {
input: {
filter: { lead_id: 14500 },
set: {
meeting_name: "New Lead (Updated)",
contact_id: 84626,
status_id: 6, # "Lead" status type. Currently the only status type supported.
eei_type_id: 279,
sales_manager_id: 1,
room_attendees: 1234,
show_attendees: 4567,
meeting_dates: [
{
start: "2026-01-01T00:00:00Z",
end: "2026-01-03T00:00:00Z",
is_primary: true
},
{
start: "2026-01-12T00:00:00Z",
end: "2026-01-14T00:00:00Z"
}
],
room_block: [
{
date: "2026-01-01T00:00:00Z",
quantity: 1
},
{
date: "2026-01-02T00:00:00Z",
quantity: 2
},
{
date: "2026-01-03T00:00:00Z",
quantity: 3
}
],
hotel_response_due: "2026-01-16"
}
}
},
fields: `
success
message
doc {
lead_id
}
`,
context: {
acct_id: "149",
token // from login or serviceAccountToken call
}
});Note: All fields within set are optional. Omitting a field results in that field not being updated, rather than that field being blanked out. The only instance when fields are required is when meeting_dates is provided, when you must also provide room_block, and vice versa.
Related Documentation
Troubleshooting
For any assistance please reach out on the Microservices Support Teams channel.
