Customers
The Cleverbridge GraphQL API is a powerful resource you can use in different ways. Following is a list of common scenarios and code examples to help you integrate and utilize the API.
Delete Personal Data of a Customer
A customer asks Shieldware to delete their personal data. Shieldware uses the deletePersonalCustomerData(purchaseId: Int!)
mutation to delete the customer data related to a given purchase.
The following examples show a customer data query before anonymizing the data, the mutation deleting the personal data, and the mutation result. After the mutation, personal data is replaced by XXX
and the customer's email address is changed to [email protected]
. Only the country data and all the "null" values stay unchanged.
Note
Before you delete a customer's data, deactivate all the active subscriptions of the customer.
Compare the responses before and after the mutation to understand how the personal data of the customer is anonymized.
Example Request - Query Customer Data Related to a Purchase
query FindPurchase {
purchase(id: 356018965) {
customer {
id
}
customerCountry {
id
}
billingContact {
id
company
firstName
lastName
email
addressLine1
addressLine2
postalCode
city
country {
id
name
}
state {
id
name
country {
id
name
}
}
}
}
}
The API call returns the purchase object with the values you requested.
Example Response - Customer Data Related to a Purchase
{
"data": {
"purchase": {
"customer": {
"id": 131355826
},
"customerCountry": {
"id": "MT"
},
"billingContact": {
"id": 380127817,
"company": null,
"firstName": "Han",
"lastName": "Solo",
"email": "[email protected]",
"addressLine1": "123 Test Ave",
"addressLine2": null,
"postalCode": "1234",
"city": "Tatooine",
"country": {
"id": "MT",
"name": "Malta"
},
"state": null
}
}
}
}
To delete the data of the customer, use the deletePersonalCustomerData(purchaseId: Int!)
mutation object with the relevant purchase ID.
Example Request - Mutation Delete Customer Data Related to a Purchase
mutation MyMutation {
deletePersonalCustomerData(purchaseId: 356018965) {
updatedPurchase {
id
customer {
id
}
customerCountry {
id
}
billingContact {
id
company
firstName
lastName
email
addressLine1
addressLine2
postalCode
city
country {
id
name
}
state {
id
name
country {
id
name
}
}
}
}
}
}
The mutation anonymizes the customer data related to the given purchase and returns the ID of the updated purchase and all the fields requested in the mutation.
Example Response - Anonymized Customer Data Related to a Purchase
{
"data": {
"deletePersonalCustomerData": {
"updatedPurchase": {
"id": 356018965,
"customer": {
"id": 131355826
},
"customerCountry": {
"id": "MT"
},
"billingContact": {
"id": 380127817,
"company": null,
"firstName": "XXX",
"lastName": "XXX",
"email": "[email protected]",
"addressLine1": "XXX",
"addressLine2": null,
"postalCode": "XXX",
"city": "XXX",
"country": {
"id": "MT",
"name": "Malta"
},
"state": null
}
}
}
}
}
Update Customers Contact Information
Shieldware, Inc. offers security software for small and medium-sized businesses on the basis of annual subscriptions. They sell their software through Cleverbridge and use Salesforce as their CRM tool. To manage customer purchases, their development department updates customer data, using the GraphQL API, and pushes them to Salesforce. As a result, their CRM becomes the single point of truth for communication with customers.
You can use the GraphQL API to update the contact information for a customer or a purchase. To use the updateContact
mutation object, you must provide the Id
of the contact and the fields you would like to update in the request.
Example Request
mutation {
updateContact(
input: {
id: 208269856
lastName: "Solo"
firstName: "Han"
email: "[email protected]"
countryId: US
languageId: EN
addressLine1: "123 Falcon Way"
postalCode: "30033"
city: "Atlanta"
stateId: US_GA
}
) {
updatedContact {
lastName
firstName
email
addressLine1
postalCode
city
state {
id
}
}
}
}
Example Response
The API call returns the updateContact
object with the requested fields.
{
"data": {
"updateContact": {
"updatedContact": {
"lastName": "Solo",
"firstName": "Han",
"email": "[email protected]",
"addressLine1": "123 Falcon Way",
"postalCode": "30033",
"city": "Atlanta",
"state": {
"id": "US_GA"
}
}
}
}
}
View Customer Emails
Shieldware, Inc. offers security software for small and medium-sized businesses on the basis of annual subscriptions. They sell their software through Cleverbridge and use Salesforce as their CRM tool. To increase the visibility of all emails sent for new opportunities, their development department fetches all emails sent by Cleverbridge, using the GraphQL API, and pushes them to Salesforce. As a result, their CRM becomes the single point of truth for communication with customers.
You can use the GraphQL API to get all emails a customer has received for a specific purchase and display the emails in another system. To do so, use the purchase
query object and request the emails
payload object. You must provide the id
of the purchase in the request and specify the email fields that you would like to return.
Example Request
query {
purchase(id: 123805998) {
emails {
bodyPlain
bounceReason
creationTime
deliveryTime
fromAddress
id
mailType {
id
name
}
status {
id
name
}
toAddress
}
}
}
The API call returns an array of emails
objects with the requested fields, for example, bodyPlain
or deliveryTime
.
Example Response
{
"data": {
"purchase": {
"emails": [
{
"bodyPlain": "Sehr geehrte(r) Han Solo,\r\n\r\nERFOLGREICHE ZAHLUNG FÜR IHR ABONNEMENT\r\n\r\nSie haben ein Abonnement für Internet Security Basic. Eine weitere\r\nerfolgreiche Zahlung für dieses Abonnement ist erfolgt.\r\n\r\n\r\nINFORMATIONEN ZUR PRODUKTLIEFERUNG\r\n\r\nWeitere Informationen zur Auslieferung von Internet Security Basic\r\nerhalten Sie auf dieser Webseite:\r\n\r\nhttps://www.cleverbridge.com/864/p/126083636-XaKx3EwSgdicckjJMWQ1?\r\n\r\n\r\nIHRE RECHNUNG\r\n\r\nIm Anhang dieser E-Mail finden Sie die Rechnung zu Ihrer Bestellung. Sie\r\nkönnen die Rechung auch über folgenden Link herunterladen:\r\n\r\nhttps://www.cleverbridge.com/864/p/126083636-XaKx3EwSgdicckjJMWQ1?\r\n\r\nEin PDF mit den allgemeinen Geschäftsbedingungen der Cleverbridge GmbH\r\nfinden Sie im Anhang dieser E-Mail.\r\n\r\n\r\nIHR ABONNEMENT\r\n\r\nIhr Abonnement für \"Internet Security Basic\" begann am 17.11.2017. Unter\r\ndiesem Link finden Sie weitere Informationen zu Ihrer Bestellung:\r\n\r\nhttps://www.cleverbridge.com/864/p/123849279-TRo7lgfBwxJYtc4KlMIt?\r\n\r\n\r\nABONNEMENT KÜNDIGEN\r\n\r\nWenn Sie Ihr Abonnement kündigen möchten, finden Sie die Möglichkeit\r\nhierzu auf der folgenden Seite:\r\n\r\nhttps://www.cleverbridge.com/864/p/126083636-XaKx3EwSgdicckjJMWQ1?\r\n\r\n\r\nKUNDENSERVICE\r\n\r\n\r\nFragen zu Produkten und technischer Support\r\n\r\nWenn Sie technische Fragen oder Fragen zu Produkten haben, wenden Sie\r\nsich bitte an Shieldware (Example Company):\r\n\r\nWebseite: http://www.shieldwareexamplecompany.com\r\nE-Mail: [email protected]\r\nTelefon: 18005551212\r\nFax: 18005551213\r\n\r\n\r\nFragen zur Zahlung und Bestellung\r\n\r\nWenn Sie Fragen zu Ihrer Zahlung oder Bestellung haben, wenden Sie sich\r\nbitte an den Cleverbridge Kundenservice:\r\n\r\nhttps://www.cleverbridge.com/864/ma/cuseco/126083636-XaKx3EwSgdicckjJMWQ1?\r\n\r\nVielen Dank, dass Sie Ihre Online-Einkäufe über Cleverbridge getätigt\r\nhaben.\r\n\r\n\r\nMit freundlichen Grüßen\r\nIhr Cleverbridge Kundenserviceteam\r\n\r\n\r\nCleverbridge GmbH\r\nGereonstr. 43-65 - 50670 Köln - Deutschland\r\n\r\nVorstand: Christian Blume, Reinhard Wille, Martin Trzaskalik, Craig\r\nVodnik\r\nVorsitzender des Aufsichtsrats: Dr. Michael Inhester\r\nRegistergericht: HRB 58900 - Amtsgericht Köln",
"bounceReason": "",
"creationTime": "2017-12-21T11:09:20.177572Z",
"deliveryTime": "2017-12-21T11:09:20.387385Z",
"fromAddress": "[email protected]",
"id": 224927486,
"mailType": {
"id": "RECEIPT",
"name": "Customer -> Invoice (Receipt)"
},
"status": {
"id": "SENT",
"name": "Sent"
},
"toAddress": "[email protected]"
}
]
}
}
}
You can now push this information to the application of your choice.
Updated over 1 year ago