Skip to content

Instantly share code, notes, and snippets.

@JogoShugh
JogoShugh / 01 Specification and Automated API Test A.ts
Created January 9, 2019 05:36
VersionOne Bulk API automated test examples
import {test, assetApiPost} from '../../lib/asset-api-helper';
const types = ['yaml', 'json'];
for(const type of types) {
test(`Update Description LongText scalar Attribute on two Defects, replacing one exact match string with another by OIDToken (${type})`, async t => {
const setupCommand = `
AssetType: Scope
Name: Test - Update Description LongText scalar Attribute on two Defects with find and replace Scope
Parent: Scope:0
@JogoShugh
JogoShugh / Quintus Dev Notes.md
Last active June 7, 2018 21:23
SM New World Syntax
  • sprites.json formatting:
    • sx = starting X position relative to the top,left of the spritesheet image
    • sy = starting Y position relative to the top,left of the spritesheet image
    • modify sx when the spritesheet image (such as the native export for Piskelapp) is horizontal
    • modify sy when the spritesheet image is vertical
  • level.tmx files:
    • A gid attribute must be in the <data> element's <object> elements. Somehow a bunch of items lost this when we saved
fun score rolls =
case rolls of
[] => 0
| n1::n2::n3::[] => n1 + n2 + n3
| n1::n2::n3::rest =>
if n1 = 10 then 10 + n2 + n3 + score (n2::n3::rest)
else if n1 < 10 andalso n1 + n2 = 10 then n1 + n2 + n3 + score (n3::rest)
else if n1 + n2 < 10 then n1 + n2 + score (n3::rest)
else score rest
| n1::rest => n1 + score rest
@JogoShugh
JogoShugh / Tally by File Extension CommitStream.js
Last active March 5, 2018 17:08
Tally By File Extension CommitStream.js
function tally(root, prop) {
if (!root[prop]) root[prop] = 0;
root[prop]++;
}
function hasItems(array) {
return array && array.length > 0;
}
function tallyBy(state, key, length) {
@JogoShugh
JogoShugh / apiTest.ts
Created November 8, 2017 17:18
API Test
import {test, assetApiPost} from '../../lib/asset-api-helper';
const types = ['yaml', 'json'];
for(const type of types) {
test(`Update Description scalar Attribute on two Stories matching a where clause by Scope OIDToken (${type})`, async t => {
const setupCommand = `
AssetType: Scope
Name: Test - Update Description scalar Scope
Parent: Scope:0

Given this HTTP command using cURL or another client:

cURL command

curl -i -X POST \
   -H "Content-Type:text/yaml" \
   -H "Authorization:Bearer access-token-here" \
   -d \
'AssetType: Story
@JogoShugh
JogoShugh / 00 - Explanation.md
Last active October 31, 2017 15:54
YamlDotNet serialization with JSON.Net

Background

To process a Bulk API request in the most efficient and reliable manner, we need to be able to break it into multiple steps and process it on the background as a "Job", essentially. This Job will be capable of surviving App Domain failures or restarts. This means that if it has, for example, 1,000 discrete commands to process (creating assets, updating existing assets, executing operations against existing assets), it will resume where it left off when the application restarts and the Job processor notices that it is not finished.

Eventually, the entire process will look roughly like this:

  • Ingest the entire payload, convert it from YAML, XML, Excel or whatever into an easiest-to-work with Json.NET structure (Currently it's converting JSON into Yaml!)
  • Persist this to DB, return a URI to caller that indicates where to request status updates for the Bulk Job
  • On background, begin breaking down the payload into a linear and finite list of projected commands of the following types:
  • Creat
@JogoShugh
JogoShugh / Asset.xml
Last active October 17, 2017 16:16
Java XML Sax Error BWIN
<?xml version="1.0" encoding="UTF-8"?>
<Assets total="11166" pageSize="2147483647" pageStart="0">
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3286021" id="Epic:3286021">
<Attribute name="Name">MTT General requirments</Attribute>
</Asset>
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3220348" id="Epic:3220348">
<Attribute name="Name">GIT - a new SCM</Attribute>
</Asset>
<Asset href="/GVC-Sandbox/rest-1.v1/Data/Epic/3394297" id="Epic:3394297">
<Attribute name="Name">Sun Estate Refresh (Vienna) &#x13; Sun Maintenance</Attribute>
@JogoShugh
JogoShugh / V1Connector.cs
Created August 31, 2017 16:48
V1Connector.cs for fluent client
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
@JogoShugh
JogoShugh / 001.01 Legacy APIClient Create.cs
Last active August 22, 2017 16:46
VersionOne Code Structure WIP
V1Connector connector = V1Connector
.WithInstanceUrl("<Server Base URI>")
.WithUserAgentHeader("AppName", "1.0")
.WithAccessToken("1.rWM8lKLk+PnyFxkEWVX5Kl2u6Jk=")
.Build();
IServices services = new Services(connector);
Oid projectId = services.GetOid("Scope:1012");
IAssetType storyType = services.Meta.GetAssetType("Story");