Skip to content

Instantly share code, notes, and snippets.

@moo2u2
moo2u2 / Program.cs
Created April 8, 2024 00:30
Log OrderCloud SDK HTTP calls through Flurl
FlurlHttp.Configure(settings => settings.BeforeCall = (FlurlCall call) =>
{
app.Logger.LogInformation($"Calling {call.Request.Url} with {call.RequestBody}");
});
FlurlHttp.Configure(settings => settings.OnError = (FlurlCall call) =>
{
app.Logger.LogError(call.Exception, $"Error calling {call.Request.Url}");
});
query MyQuery($datasource: String!, $language: String!) {
datasource: item(path: $datasource, language: $language) {
# List 20 children of given template under given datasource
children(
first: 20
includeTemplateIDs: "{A6DDAC75-7D24-4BDB-B3F6-5F47FBB21379}"
# after: "endCursor" (see endCursor below)
# hasLayout: true
)
{
@moo2u2
moo2u2 / basic_children.graphql
Created March 22, 2024 10:13
Simple way to fetch children of a given datasource
query MyQuery($datasource: String!, $language: String!) {
datasource: item(path: $datasource, language: $language) {
# List children of given datasource
children {
results {
id
name
field(name: "MyCustomField") {
jsonValue
}
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 2,
"TotalPages": 1,
"ItemRange": [
1,
2
],
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 3,
"TotalPages": 1,
"ItemRange": [
1,
3
],
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 2,
"TotalPages": 1,
"ItemRange": [
1,
2
],
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 3,
"TotalPages": 1,
"ItemRange": [
1,
3
],
@moo2u2
moo2u2 / oc_two_variants.json
Last active March 13, 2024 06:13
OrderCloud 2 variants created
{
"Meta": {
"Page": 1,
"PageSize": 20,
"TotalCount": 2,
"TotalPages": 1,
"ItemRange": [
1,
2
],
@moo2u2
moo2u2 / oc_product_sync_msg.json
Created March 7, 2024 04:26
OrderCloud Product Sync sample message
{
"Headers": {
"type": "sitecore.ordercloud.messages.product.updated",
"marketplace": "yourMarketplaceId",
"tenantid": "yourMarketplaceId"
},
"Payload": {
"UserContext": {
"ID": null,
"AnonymousID": null
const Inheritance = '!*';
export const securityFieldName = '__Security';
const permissionCanRead = '+read';
const permissionCannotRead = '-read';
enum ParseState { au, ar, pe, pd };
export type Permissions = {
[username: string]: {