2021-03-24 07:10:26 +03:00
import * as React from "react" ;
import * as Constants from "~/common/constants" ;
import * as System from "~/components/system" ;
import CodeBlock from "~/components/system/CodeBlock" ;
import { css } from "@emotion/react" ;
2021-03-25 07:28:14 +03:00
const EXAMPLE _CODE _JS = ( key , slateId ) => {
return `
2021-03-24 07:10:26 +03:00
const SLATE _ID = "${slateId}"
const slateResponseData = getSlateById ( SLATE _ID ) ;
const slate = slateResponseData . data ;
slate . data . objects [ 0 ] . title = "Julie Was Here."
const response = await fetch ( 'https://slate.host/api/v1/update-slate' , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json' ,
// NOTE: your API key
Authorization : 'Basic ${key}' ,
} ,
body : JSON . stringify ( { data : slate } )
} ) ;
const json = await response . json ( ) ;
console . log ( json ) ; ` ;
} ;
const EXAMPLE _CODE _PY = ( key , slateId ) => ` # STILL BEING CODED AND TESTED ` ;
const DocPage = ( props ) => {
let language = props . language ;
let key = props . APIKey ;
let slateId = props . slateId ;
if ( language === "javascript" ) {
return (
< React . Fragment >
< System . DescriptionGroup
2021-03-25 07:28:14 +03:00
style = { { marginTop : 64 } }
2021-03-24 07:10:26 +03:00
label = "Update slate by ID"
description = "This API endpoint will allow you to update a slate by sending your current locally modified version. This API endpoint allows for full customization so be careful."
/ >
< CodeBlock
children = { EXAMPLE _CODE _JS ( key , slateId ) }
2021-03-25 07:28:14 +03:00
style = { { maxWidth : "840px" } }
2021-03-24 07:10:26 +03:00
language = { language }
2021-03-25 07:28:14 +03:00
topBar = "true"
title = "Update slate by ID"
2021-03-24 07:10:26 +03:00
/ >
< / R e a c t . F r a g m e n t >
) ;
}
if ( language === "python" ) {
return (
< React . Fragment >
< System . DescriptionGroup
2021-03-25 07:28:14 +03:00
style = { { marginTop : 64 } }
2021-03-24 07:10:26 +03:00
label = "Update slate by ID"
description = "This API endpoint will allow you to update a slate by sending your current locally modified version. This API endpoint allows for full customization so be careful."
/ >
< CodeBlock
children = { EXAMPLE _CODE _PY ( key , slateId ) }
2021-03-25 07:28:14 +03:00
style = { { maxWidth : "840px" } }
2021-03-24 07:10:26 +03:00
language = { language }
/ >
< / R e a c t . F r a g m e n t >
) ;
}
} ;
export default class APIDocsUpdateSlate extends React . Component {
render ( ) {
return (
< DocPage
language = { this . props . language }
APIKey = { this . props . APIKey }
slateId = { this . props . slateId }
/ >
) ;
}
}