Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvagni committed Nov 17, 2023
0 parents commit b631805
Show file tree
Hide file tree
Showing 179 changed files with 8,593 additions and 0 deletions.
34 changes: 34 additions & 0 deletions _snippets/browser/upload-attachment.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
```js
/**
* Upload an attachment.
*
* @param {Blob} fileBlob blob with the contents of the file to upload
* @param {string} uploadFormUrl The url to post the form to (from `createAttachmentUploadUrl.attachmentUploadUrl.uploadFormUrl`)
* @param {{ key: string; value: string }[]} uploadFormData Data to be added to the form along with the file contents (from `createAttachmentUploadUrl.attachmentUploadUrl.uploadFormData`)
*/
function uploadAttachment(fileBlob, uploadFormUrl, uploadFormData) {
const form = new FormData();
uploadFormData.forEach(({ key, value }) => {
form.append(key, value);
});

const file = new File([fileBlob], 'file');
form.append('file', file);

console.log(`Uploading attachment to ${uploadFormUrl}`);

fetch(uploadFormUrl, {
method: 'POST',
body: form,
})
.then((res) => {
if (!res.ok) {
throw new Error(response.statusText);
}
console.log(`File successfully uploaded! (code=${res.status})`);
})
.catch((err) => {
console.log(`There was an error uploading the file: %s`, err.message ? err.message : err);
});
}
```
38 changes: 38 additions & 0 deletions _snippets/graphql/add-customer-to-group-by-group-id.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
```json filename="Variables"
{
"input": {
"customerId": "c_01GTC6ZHCMAGR06FMPN9VY5J95",
"customerGroupIdentifiers": [
{
"customerGroupId": "cg_01GX8H2BWS7Z4EP9RRGMF9NXX2"
}
]
}
}
```

```json filename="Response"
{
"data": {
"customerGroupMemberships": [
{
"customerGroup": {
"id": "cg_01GX8H2BWS7Z4EP9RRGMF9NXX2",
"name": "Free Tier",
"key": "free-tier",
"color": "#1D4ED8"
}
},
{
"customerGroup": {
"id": "cg_05GXF4FGGS2Z7EW9RRGKL9NLL9",
"name": "Design partner",
"key": "design-partner",
"color": "#06B6D4"
}
}
],
"error": null
}
}
```
40 changes: 40 additions & 0 deletions _snippets/graphql/add-customer-to-group.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
```graphql filename="Mutation"
mutation addCustomerToCustomerGroup($input: AddCustomerToCustomerGroupsInput!) {
addCustomerToCustomerGroups(input: $input) {
customerGroupMemberships {
customerGroup {
id
name
key
color
}
}
error {
message
code
type
fields {
field
message
type
}
}
}
}
```

```json filename="Variables"
{
"input": {
"customerId": "c_01GTC6ZHCMAGR06FMPN9VY5J95",
"customerGroupIdentifiers": [
{
"customerGroupKey": "free-tier"
},
{
"customerGroupKey": "design-partner"
}
]
}
}
```
21 changes: 21 additions & 0 deletions _snippets/graphql/add-labels.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```graphql filename="Mutation"
mutation addLabels($input: AddLabelsInput!) {
addLabels(input: $input) {
labels {
id
createdAt {
iso8601
}
}
}
}
```

```json filename="Variables"
{
"input": {
"labelTypeIds": ["lt_01HB8BTNTZ58730MX8H5VMKFD5", "lt_01HB8BTNKSCF1FK5ETFVRSDC6G"],
"threadId": "th_01H8H46YPB2S4MAJM382FG9423"
}
}
```
22 changes: 22 additions & 0 deletions _snippets/graphql/assign-thread.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```graphql filename="Mutation"
mutation assignThread($input: AssignThreadInput!) {
markThreadAsDone(input: $input) {
thread {
id
status
}
}
}
```

```json filename="Variables"
{
"input": {
"threadId": "th_01H8H46YPB2S4MAJM382FG9423",
"userId": "u_01FSVKMHFDHJ3H5XFM20EMCBQN"

// You could instead assign to a machine user by doing:
// machineUserId: 'XXX'
}
}
```
86 changes: 86 additions & 0 deletions _snippets/graphql/create-attachment-url.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
```graphql filename="Mutation"
mutation createAttachmentUploadUrl($input: CreateAttachmentUploadUrlInput!) {
createAttachmentUploadUrl(input: $input) {
attachmentUploadUrl {
attachment {
id
# There are more fields here but we are just selecting
# the id for simplicity.
}
uploadFormUrl
uploadFormData {
key
value
}
}
error {
message
type
code
fields {
field
message
type
}
}
}
}
```

```json filename="Variables"
{
"input": {
"customerId": "c_XXXXXXXXXXXXXXXXXXXXXXXXXX",
"fileName": "bruce.jpeg",
"fileSizeBytes": 32318,
"attachmentType": "CUSTOM_TIMELINE_ENTRY"
}
}
```

```json filename="Response"
{
"data": {
"createAttachmentUploadUrl": {
"attachmentUploadUrl": {
"attachment": {
"id": "att_01H3970W7XG1716AVNGQ6FWYGD"
},
"uploadFormUrl": "https://prod-uk-services-attachm-attachmentsuploadbucket2-1l2e4906o2asm.s3.eu-west-2.amazonaws.com/",
"uploadFormData": [
{ "key": "acl", "value": "private" },
{ "key": "x-amz-server-side-encryption", "value": "AES256" },
{ "key": "Content-Type", "value": "application/octet-stream" },
{
"key": "bucket",
"value": "prod-uk-services-attachm-attachmentsuploadbucket2-1l2e4906o2asm"
},
{ "key": "X-Amz-Algorithm", "value": "AWS4-HMAC-SHA256" },
{
"key": "X-Amz-Credential",
"value": "ASIAWYWBOL266XVGRRM7/20230619/eu-west-2/s3/aws4_request"
},
{ "key": "X-Amz-Date", "value": "20230619T065604Z" },
{
"key": "X-Amz-Security-Token",
"value": "IQoJb3JpZ2luX2VjEC8aCWV1LXdlc3QtMiJIMEYCIQD6zKc5ZaobWAYgTZoWN62yv5+vXRwkAAZvRPOg51UevgIhAPFCm3pUv/StIqoxtC90G6kE0D9lqcRBlWdzA8FsErw+KpwDCIj//////////wEQARoMNDY1MzM1OTAxODg1Igz/lGT5c341L5ZjBZoq8AJjmuxX6/MR8uRmDH4BPh/6uuBoT2IDRIFVqVpDlll5hOGDKmMMSqxFdJ0EdxI9oCLRlM+cd/oupHTOfvC+Jc0g6vQrABgvbi7PSVzZZrxWZRtaGmSzb6rI3it0xBGJf1c/Ec3dZzX2nJqhG7fY9jqXzFzSWF3B+GX4A6kwcrU3mv8nRFenxPZpXq75thb3w0C3wNbaee2TfZWtdwXB24f0qJhbDKZuu1S399Fj1/1AMQVRjIdUy8mbXKYHhN1cqGONaruN2ypLffB45IlHoJsquqwS8/a3/E+1so7ybkdPKUCMqS42Lss5YX4cKJX70wJzc2SanyJhaBlTW93V/lBYCjlhtR5muAr9Gabybi5lSu1Am/SEymzKOYUWm2vqm/11ZfdgXofmgefaDlDPV+vckLo0lO4i11bS245waOW3bK9iIwX+m05DyzbUSy0zn5Hit1+z+R5VK/pnFR1pJ5fD/F9H5QlFO2I38DHQxpWBFTCq77+kBjqcATBd5fpX6yln9sw7UVlzy4eqyqP8asGiadpqiupsVygGahb1ZGS33XFqx0BClbvKBiO+gvQNZyicIgwvLvThQFxO4raEFqFZlVPVVZUe6vBsgb72CAwsGtV9chLm6C3AN3Ovb4ta/FNwVIc9sfXwOLIazLtAS0IpWuJi49FUw82725HvW5oY8pTl3NhWV60XFXmyuDUYsJlVfvtkWg=="
},
{
"key": "key",
"value": "w_01GZEA2KYR63P8E00JBMYQT58Z/pending/machineUser/mu_01GZEA2M91124MPFAVZEPKC2MY/att_01H3970W7XG1716AVNGQ6FWXGD"
},
{
"key": "Policy",
"value": "eyJleHBpcmF0aW9uIjoiMjA3Ni0xMi0wNFQxNTo1MjowOFoiLCJjb25kaXRpb25zIjpbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMzIzMTgsMzIzMThdLHsiYWNsIjoicHJpdmF0ZSJ9LHsieC1hbXotc2VydmVyLXNpZGUtZW5jcnlwdGlvbiI6IkFFUzI1NiJ9LHsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtIn0seyJidWNrZXQiOiJwcm9kLXVrLXNlcnZpY2VzLWF0dGFjaG0tYXR0YWNobWVudHN1cGxvYWRidWNrZXQyLTFsMmU0OTA2bzJhc20ifSx7IlgtQW16LUFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IlgtQW16LUNyZWRlbnRpYWwiOiJBU0lBV1lXQk9MMjY2WFZHUlJNNy8yMDIzMDYxOS9ldS13ZXN0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Zsenk0ZXF5cVA4YXNHaWFkcHFpdXBzVnlnR2FoYjFaR1MzM1hGcXgwQkNsYnZLQmlPK2d2UU5aeWljSWd3dkx2VGhRRnhPNHJhRUZxRlpsVlBWVlpVZTZ2QnNnYjcyQ0F3c0d0VjljaExtNkMzQU4zT3ZiNHRhL0ZOd1ZJYzlzZlh3T0xJYXpMdEFTMElwV3VKaTQ5RlV3ODI3MjVIdlc1b1k4cFRsM05oV1Y2MFhGWG15dURVWXNKbFZmdnRrV2c9PSJ9LHsia2V5Ijoid18wMUdaRUEyS1lSNjNQOEUwMEpCTVlRVDU4Wi9wZW5kaW5nL21hY2hpbmVVc2VyL211XzAxR1pFQTJNOTExMjRNUEZBVlpFUEtDMk1ZL2F0dF8wMUgzOTcwVzdYRzE3MTZBVk5HUTZGV1hHRCJ9XX0="
},
{
"key": "X-Amz-Signature",
"value": "a68a18898e654e072f80b052853b0722aa58aada15d3cd3e9cc937f929ff2433"
}
]
},
"error": null
}
}
}
```
75 changes: 75 additions & 0 deletions _snippets/graphql/create-customer-event.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
```graphql filename="Mutation"
mutation createCustomerEvent($input: CreateCustomerEventInput!) {
createCustomerEvent(input: $input) {
customerEvent {
__typename
id
title
createdAt {
__typename
iso8601
unixTimestamp
}
}
error {
__typename
message
type
code
fields {
field
message
type
}
}
}
}
```

```json filename="Variables"
{
"input": {
"title": "API key generated",

"customerIdentifier": {
// You can use the email:
"email": "[email protected]"

// ...or if you set external id on customers:
// externalId: 'YOUR_ID',

// ...or you can use the customer's id in Plain:
// customerId: 'c_123'
},

"components": [
{
"componentText": {
"text": "New API key was added with the fingerprint **3b7896975ee9fd15eeb7** with 4 associated roles."
}
},
{
"componentSpacer": {
"spacerSize": "M"
}
},
{
"componentLinkButton": {
"linkButtonLabel": "View in admin",
"linkButtonUrl": "https://admin.your-app.com"
}
}
],

// Optional - if provided, this will ensure that this event can only
// be created once and fail on the second time. This external id acts
// as an idempotency key while also letting you correlate an event to
// something your systems.
"externalId": "XXX",

// Optional - if provided then the event will only be shown
// in a single thread vs all threads from a customer
"threadId": "th_01HB924RWAW8H3Q8KZDFWYBJHZ"
}
}
```
53 changes: 53 additions & 0 deletions _snippets/graphql/create-thread.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
```graphql filename="Mutation"
mutation createThread($input: CreateThreadInput!) {
createThread(input: $input) {
thread {
__typename
id
externalId
customer {
id
}
status
statusChangedAt {
__typename
iso8601
unixTimestamp
}
title
previewText
priority
}
error {
__typename
message
type
code
fields {
field
message
type
}
}
}
}
```

```json filename="Variables"
{
"input": {
"title": "Bug Report",
"customerIdentifier": {
"customerId": "c_01H14DFQ4PDYBH398J1E99TWSS"
},
"components": [
{
"componentText": {
"text": "The login button is not working, it doesn't do anything."
}
}
],
"labelTypeIds": ["lt_01HB924PME9C0YWKW1N4AK3BZA"]
}
}
```
Loading

0 comments on commit b631805

Please sign in to comment.