Badge Type Report

This example works like the windows client. In this example we also return metadata which is used for custom form information storage on the individual in our solution.

Example in C#

var currentInstance  = await client.GetCurrentInstanceAsync();
var operations = 
	new BsonDocument[] 
	{ 
	    new BsonDocument("$match", 
	    new BsonDocument
	        {
	            { "InstanceScopeId", 
	    new ObjectId(currentInstance.Key) }, 
	            { "$or", 
	    new BsonArray
	            {
	                new BsonDocument("_t", "Person"),
	                new BsonDocument("_t", "Attendee")
	            } }
	        }),
	    new BsonDocument("$unwind", 
	    new BsonDocument
	        {
	            { "path", "$CardAssignments" }, 
	            { "preserveNullAndEmptyArrays", true }
	        }),
	    new BsonDocument("$match", 
	    new BsonDocument("$or", 
	    new BsonArray
	            {
	                new BsonDocument("CardAssignments", 
	                new BsonDocument("$exists", true)),
	                new BsonDocument("Card", 
	                new BsonDocument("$exists", true))
	            })),
	    new BsonDocument("$project", 
	    new BsonDocument
	        {
	            { "_id", 0 }, 
	            { "CommonName", 1 }, 
	            { "Card", 1 }, 
	            { "CardAssignments", 1 }, 
	            { "ObjectLinks", 1 }, 
	            { "Metadata", 1 }
	        })
	};

var BadgeType = await client.AggregateAsync(currentInstance, "KeepObjects", operations);

Example in CURL

curl -X POST \
  'https://keepapi.feenicshosting.com/api/f/INSTANCE_KEY_HERE/aggregate/KeepObjects?queryTimeout=30&jsonStrict=False%20' \
  -H 'Accept: */*' \
  -H 'Authorization: Bearer TOKEN_GOES_HERE'  \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Host: keepapi.feenicshosting.com' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache' \
  -H 'content-length: 497' \
  -d '["
        { 
            \"$match\" : 
            { 
                \"InFolderId\" : ObjectId(\"INSTANCE_KEY_HERE\"), 
                \"$or\" : 
                [
                    { \"_t\" : \"Person\" },
                    { \"_t\" : \"Attendee\" }
                ] 
            } 
        }","
        { \"$unwind\" : { \"path\" : \"$CardAssignments\", \"preserveNullAndEmptyArrays\" : true } }","
        { 
            \"$match\" : 
            { 
                \"$or\" : 
                [
                    { \"CardAssignments\" : { \"$exists\" : true } },
                    { \"Card\" : { \"$exists\" : true } }
                ] 
            } 
        }","
        { 
            \"$project\" : 
            { 
                \"_id\" : 0, 
                \"CommonName\" : 1, 
                \"Card\" : 1, 
                \"CardAssignments\" : 1, 
                \"ObjectLinks\" : 1, 
                \"Metadata\" : 1 
            } 
        }"
    ]'

Example Of Aggregate Used in JSON

[
        { 
            "$match" : 
            { 
                "InFolderId" : ObjectId("INSTANCE_KEY_HERE"), 
                "$or" : 
                [
                    { "_t" : "Person" },
                    { "_t" : "Attendee" }
                ] 
            } 
        },
        { "$unwind" : { "path" : "$CardAssignments", "preserveNullAndEmptyArrays" : true } },
        { 
            "$match" : 
            { 
                "$or" : 
                [
                    { "CardAssignments" : { "$exists" : true } },
                    { "Card" : { "$exists" : true } }
                ] 
            } 
        },
        { 
            "$project" : 
            { 
                "_id" : 0, 
                "CommonName" : 1, 
                "Card" : 1, 
                "CardAssignments" : 1, 
                "ObjectLinks" : 1, 
                "Metadata" : 1 
            } 
        }
    ]

Badge Type Report - Using Aggregate

This returns only objects that have a badgetype.

Example in C#

var currentInstance  = await client.GetCurrentInstanceAsync();
var operations = 
	new BsonDocument[] 
	{ 
	 	new BsonDocument("$match", 
	    	new BsonDocument
	        {
	            { "InstanceScopeId", 
	    			new ObjectId(currentInstance.Key }, 
	            { "$or", 
	    			new BsonArray
	            	{
	                	new BsonDocument("_t", "Person"),
	                	new BsonDocument("_t", "Attendee")
	            	} 
				}, 
	            { "ObjectLinks.Relation", "BadgeType" }
	        }
		),
	    new BsonDocument("$unwind", 
	    new BsonDocument
	        {
	            { "path", "$CardAssignments" }, 
	            { "preserveNullAndEmptyArrays", true }
	        }),
	    new BsonDocument("$project", 
	    	new BsonDocument
	        {
	            { "_id", 0 }, 
	            { "CommonName", 1 }, 
	            { "Card", 1 }, 
	            { "CardAssignments", 1 }, 
	            { "ObjectLinks", 1 }
	    })
	};

var BadgeType = await client.AggregateAsync(currentInstance, "KeepObjects", operations);

Example in CURL

curl -X POST \
  'https://keepapi.feenicshosting.com/api/f/INSTANCE_KEY_HERE/aggregate/KeepObjects?queryTimeout=30&jsonStrict=False%20' \
  -H 'Accept: */*' \
  -H 'Authorization: Bearer TOKEN_GOES_HERE'  \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Host: keepapi.feenicshosting.com' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache' \
  -H 'content-length: 398' \
  -d '["
        { 
            \"$match\" : 
            { 
                \"InFolderId\" : ObjectId(\"INSTANCE_KEY_HERE\"), 
                \"$or\" : 
                [
                    { \"_t\" : \"Person\" }, 
                    { \"_t\" : \"Attendee\" }
                ], 
                \"ObjectLinks.Relation\" : \"BadgeType\" 
            } 
        }","
        { \"$unwind\" : { \"path\" : \"$CardAssignments\", \"preserveNullAndEmptyArrays\" : true } }","
        { 
            \"$project\" : 
            { 
                \"_id\" : 0, 
                \"CommonName\" : 1, 
                \"Card\" : 1, 
                \"CardAssignments\" : 1, 
                \"ObjectLinks\" : 1 
            } 
        }"
    ]'

Example Of Aggregate Used in JSON

[
    { 
        "$match" : 
        { 
            "InFolderId" : ObjectId("INSTANCE_KEY_HERE"), 
            "$or" : 
            [
                { "_t" : "Person" }, 
                { "_t" : "Attendee" }
            ], 
            "ObjectLinks.Relation" : "BadgeType" 
        } 
    },
    { "$unwind" : { "path" : "$CardAssignments", "preserveNullAndEmptyArrays" : true } },
    { 
        "$project" : 
        { 
            "_id" : 0, 
            "CommonName" : 1, 
            "Card" : 1, 
            "CardAssignments" : 1, 
            "ObjectLinks" : 1 
        } 
    }
]