Skip to content

Commit

Permalink
Merge pull request #248 from skedify/develop
Browse files Browse the repository at this point in the history
release/next
  • Loading branch information
brechtdewinne authored May 10, 2021
2 parents c1ce13c + 2964863 commit 4fcc1f9
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 47 deletions.
163 changes: 129 additions & 34 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,139 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="icon"
type="image/png"
href="https://www.skedify.me/assets/img/favicons/favicon-16x16.png"
/>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Skedify SDK</title>
</head>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<head>
<style>
@import url('https://fonts.googleapis.com/css?family=Fira+Sans');

<body>
div.wrapper {
line-height: 1.5;
font-family: 'Fira Sans', sans-serif !important;
}
h1 {
color: #324983;
}
a {
color: #324983;
}
</style>
</head>
<title>Skedify SDK</title>
</head>

<h1>Documentation</h1>
<pre>Open devtools, so that you can play with `SDK`.</pre>
<body style="margin: 2rem">
<div class="wrapper">
<h1>Documentation</h1>
<pre>Open devtools, so that you can play with `SDK`.</pre>

<script src="./lib/skedify-sdk.js"></script>
<h2>Snippet</h2>
<p>Use the following snippet to easily test the SDK:</p>
<ul>
<li>
<a
href="https://developer.chrome.com/docs/devtools/javascript/snippets/"
target="_blank"
>Chrome snippets</a
>
</li>
<li>
<a
href="https://developer.mozilla.org/en-US/docs/Tools/Web_Console/The_command_line_interpreter"
target="_blank"
>Firefox JavaScript Interpreter</a
>
</li>
</ul>
</div>

<script>
const onDOMContentLoaded = () => {
window.document.removeEventListener('DOMContentLoaded', onDOMContentLoaded)
<pre>
(function() {
const client_id = ''
const realm = 'https://api.skedify.com/enterprises/development'
const username = ''
const password = ''
const enterprise_id = '1'
const locale = 'nl'
console.clear();


const SDK = new Skedify.API({
auth_provider: Skedify.API.createAuthProviderString('public_client_password', {
client_id,
username,
password,
enterprise_id,
realm
}),
locale: locale,
logger: {
trace() {
console.log('trace');
},
info(data) {
console.log('info', data);
},
warn() {
console.log('warn');
},
debug() {
console.log('debug');
},
error() {
console.log('error');
},
fatal() {
console.log('fatal');
}
}
})

window.SDK = SDK
console.log('window.SDK is available!')

})();
</pre>

<div class="wrapper">
<code>Example: SDK.appointments(2).then(console.log)</code>
</div>

const livereload = document.createElement('script')
<script src="./lib/skedify-sdk.js"></script>

livereload.src = `http://${
(location.host || 'localhost').split(':')[0]
<script>
const onDOMContentLoaded = () => {
window.document.removeEventListener(
'DOMContentLoaded',
onDOMContentLoaded
)

const livereload = document.createElement('script')

livereload.src = `http://${
(location.host || 'localhost').split(':')[0]
}:35729/livereload.js?snipver=1`
document.head.appendChild(livereload)
}

window.document.addEventListener('DOMContentLoaded', onDOMContentLoaded)
</script>

<script>
window.SDK = new Skedify.API({
locale: 'nl-BE',
auth_provider: Skedify.API.createAuthProviderString('public_client', {
client_id: 'client id goes here',
realm: 'https://api.example.com',
}),
})
</script>
</body>

</html>
document.head.appendChild(livereload)
}

window.document.addEventListener('DOMContentLoaded', onDOMContentLoaded)
</script>

<script>
window.SDK = new Skedify.API({
locale: 'nl-BE',
auth_provider: Skedify.API.createAuthProviderString('public_client', {
client_id: 'client id goes here',
realm: 'https://api.example.com',
}),
})
</script>
</body>
</html>
23 changes: 22 additions & 1 deletion src/resources/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,28 @@ Object {
},
"requires_domain_map": false,
"resource": "employees",
"sub_resources": Object {},
"sub_resources": Object {
"favoriteContacts": Object {
"allowed_includes": Array [],
"allowed_methods": Array [
"get",
"post",
"delete",
],
"deprecated": false,
"filters": Array [
"office_id",
"contact_id",
"page",
"per_page",
"id",
],
"headers": Object {},
"requires_domain_map": false,
"resource": "favorite_contacts",
"sub_resources": Object {},
},
},
},
"enterpriseSettings": Object {
"allowed_includes": Array [],
Expand Down
33 changes: 21 additions & 12 deletions src/resources/employees.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import createResourceDescription from './util/createResourceDescription'
import { HTTP_VERB_POST } from '../constants'
import { HTTP_VERB_DELETE, HTTP_VERB_GET, HTTP_VERB_POST } from '../constants'

export const employees = createResourceDescription('employees', {
includes: ['user', 'enterprise', 'roles'],
filters: ['email', 'external_id', 'state', 'roles', 'match'],
headers: {
[HTTP_VERB_POST]: {
suppress_activation_email: (value) => {
if (value !== undefined) {
return { 'X-suppress-activation-email': true }
}
export const employees = createResourceDescription(
'employees',
{
includes: ['user', 'enterprise', 'roles'],
filters: ['email', 'external_id', 'state', 'roles', 'match'],
headers: {
[HTTP_VERB_POST]: {
suppress_activation_email: (value) => {
if (value !== undefined) {
return { 'X-suppress-activation-email': true }
}

return undefined
return undefined
},
},
},
},
})
{
favoriteContacts: createResourceDescription('favorite_contacts', {
allowed_methods: [HTTP_VERB_GET, HTTP_VERB_POST, HTTP_VERB_DELETE],
filters: ['office_id', 'contact_id'],
}),
}
)

0 comments on commit 4fcc1f9

Please sign in to comment.