Skip to content

Latest commit

 

History

History
417 lines (330 loc) · 13.9 KB

scripts.md

File metadata and controls

417 lines (330 loc) · 13.9 KB
layout title
default
Scripts

Script

This page defines the Script resource.

Scripts are collections of Questions, represented by the intermediate Script Questions resource, asked to a person during a Canvassing Effort.

Sections

{% include endpoints_and_url_structures.md %}

The link relation label for a Script resource is osdi:script for a single Script resource or osdi:scripts for a collection of Script resources.

Back to top...

Fields

{% include fields_intro.md %}

{% include global_fields.md %}

Back to top...

Script Fields

Name Type Description
origin_system string A human readable identifier of the system where this Script was created. (ex: "OSDI System")
name string The name of the Script. Intended for administrative display rather than a public title, though may be shown to a user.
title string The title of the Script. Intended for public display rather than administrative purposes.
description string A description of the Script, usually displayed publicly. May contain text and/or HTML.
summary string A text-only single paragraph summarizing the Script. Shown on listing pages that have more than titles, but not enough room for full description.

Back to top...

Links

{% include links_intro.md %}

Name Type Description
self Script* A self-referential link to the Script.
creator Person* A link to a single Person resource representing the creator of the Script.
modified_by Person* A link to a Person resource representing the last editor of this Script.
taggings Taggings[]* A link to a collection of taggings association with this Script.
script_questions Script Questions[]* A link to the collection of Script Question resources for this Script.
canvassing_effort Canvassing Effort* A link to the collection of Script Question resources for this Script.

Back to top...

Related Resources

Back to top...

Scenarios

{% include scenarios_intro.md %}

Scenario: Retrieving a collection of Script resources (GET)

Script resources are sometimes presented as collections of scripts. For example, calling the scripts endpoint will return a collection of all the scripts stored in the system's database associated with your api key.

Request

GET https://osdi-sample-system.org/api/v1/scripts/

Header:
OSDI-API-Token:[your api key here]

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate

{
    "total_pages": 10,
    "per_page": 25,
    "page": 1,
    "total_records": 250,
    "_links": {
        "next": {
            "href": "https://osdi-sample-system.org/api/v1/scripts?page=2"
        },
        "osdi:scripts": [
            {
                "href": "https://osdi-sample-system.org/api/v1/scipts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0bc3"
            },
            {
                "href": "https://osdi-sample-system.org/api/v1/scipts/a91b4b2e-ae0e-4cd3-9ed7-d0ec501b0bc3"
            },
            //(truncated for brevity)
        ],
        "curies": [
            {
                "name": "osdi",
                "href": "https://osdi-sample-system.org/docs/v1/{rel}",
                "templated": true
            }
        ],
        "self": {
            "href": "https://osdi-sample-system.org/api/v1/scipts"
        }
    },
    "_embedded": {
        "osdi:scipts": [
            {
                "identifiers": [
                    "osdi_sample_system:d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa",
                    "foreign_system:1"
                ],
                "origin_system": "OSDI Sample System",
                "created_date": "2014-03-20T21:04:31Z",
                "modified_date": "2014-03-20T21:04:31Z",
                "name": "Script 1",
                "title": "Persuasion Script",
                "description": "<p>Persuasion Script for Area A</p>",
                "summary": "Persuasion Script for Area A"
                "_links": {
                    "self": {
                        "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa"
                    },
                    "osdi:creator": {
                        "href": "https://osdi-sample-system.org/api/v1/people/65345d7d-cd24-466a-a698-4a7686ef684f"
                    },
                    "osdi:modified_by": {
                        "href": "https://osdi-sample-system.org/api/v1/people/c945d6fe-929e-11e3-a2e9-12313d316c29"
                    },
                    "osdi:script_questions" : {
                        "href": "https://osdi-sample-system.org/api/v1/script/c945d6fe-929e-11e3-a2e9/script_questions"
                    },
                    "osdi:canvassing_effort" : {
                        "href": "https://osdi-sample-system.org/api/v1/canvassing_efforts/c945d6fe-929e-11e3-a2e9"
                    }
                }
            },
            {
                {
                    "identifiers": [
                        "osdi_sample_system:d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa",
                        "foreign_system:1"
                    ],
                    "origin_system": "OSDI Sample System",
                    "created_date": "2014-03-20T21:04:31Z",
                    "modified_date": "2014-03-20T21:04:31Z",
                    "name": "Script 1",
                    "title": "Persuasion Script",
                    "description": "<p>Persuasion Script for Area A</p>",
                    "summary": "Persuasion Script for Area A",
                    "_links": {
                        "self": {
                            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa"
                        },
                        "osdi:creator": {
                            "href": "https://osdi-sample-system.org/api/v1/people/65345d7d-cd24-466a-a698-4a7686ef684f"
                        },
                        "osdi:modified_by": {
                            "href": "https://osdi-sample-system.org/api/v1/people/c945d6fe-929e-11e3-a2e9-12313d316c29"
                        },
                        "osdi:script_questions" : {
                            "href": "https://osdi-sample-system.org/api/v1/script/c945d6fe-929e-11e3-a2e9/script_questions"
                        },
                        "osdi:canvassing_effort" : {
                            "href": "https://osdi-sample-system.org/api/v1/canvassing_efforts/c945d6fe-929e-11e3-a2e9"
                        }
                    }
                }
            },
            //truncated for brevity
        ]
    }
}

Back to top...

Scenario: Retrieving an individual Script resource (GET)

Calling an individual Script resource will return the resource directly, along with all associated fields, embedded Questions and appropriate links to additional information about the script.

Request

GET https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa

Header:
OSDI-API-Token:[your api key here]

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate
{
    "identifiers": [
        "osdi_sample_system:d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa",
        "foreign_system:1"
    ],
    "origin_system": "OSDI Sample System",
    "created_date": "2014-03-20T21:04:31Z",
    "modified_date": "2014-03-20T21:04:31Z",
    "name": "Script 1",
    "title": "Persuasion Script",
    "description": "<p>Persuasion Script for Area A</p>",
    "summary": "Persuasion Script for Area A",
    "_links": {
        "self": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa"
        },
        "osdi:creator": {
            "href": "https://osdi-sample-system.org/api/v1/people/65345d7d-cd24-466a-a698-4a7686ef684f"
        },
        "osdi:modified_by": {
            "href": "https://osdi-sample-system.org/api/v1/people/c945d6fe-929e-11e3-a2e9-12313d316c29"
        },
        "osdi:script_questions" : {
            "href": "https://osdi-sample-system.org/api/v1/scripts/c945d6fe-929e-11e3-a2e9/script_questions"
        },
        "osdi:canvassing_effort" : {
            "href": "https://osdi-sample-system.org/api/v1/canvassing_efforts/c945d6fe-929e-11e3-a2e9"
        }   
    }
}

Back to top...

Scenario: Creating a new script (POST)

Posting to the script collection endpoint will allow you to create a new script. The response is the new script that was created. While each implementing system will require different fields, any optional fields not included in a post operation should not be set at all by the receiving system, or should be set to default values.

Request

POST https://osdi-sample-system.org/api/v1/scripts/

Header:
OSDI-API-Token:[your api key here]

{
    "identifiers": [
        "foreign_system:1"
    ],
    "name": "Script 1",
    "title": "Persuasion Script",
    "description": "<p>Persuasion Script for Area A</p>",
    "summary": "Persuasion Script for Area A",
}

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate
{
    "identifiers": [
        "osdi_sample_system:d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa",
        "foreign_system:1"
    ],
    "origin_system": "OSDI Sample System",
    "created_date": "2014-03-20T21:04:31Z",
    "modified_date": "2014-03-20T21:04:31Z",
    "name": "Script 1",
    "title": "Persuasion Script",
    "description": "<p>Persuasion Script for Area A</p>",
    "summary": "Persuasion Script for Area A",
    "_links": {
        "self": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa"
        },
        "osdi:creator": {
            "href": "https://osdi-sample-system.org/api/v1/people/65345d7d-cd24-466a-a698-4a7686ef684f"
        },
        "osdi:modified_by": {
            "href": "https://osdi-sample-system.org/api/v1/people/c945d6fe-929e-11e3-a2e9-12313d316c29"
        },
        "osdi:script_questions": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/c945d6fe-929e-11e3-a2e9/script_questions"
        }
    }
}

Back to top...

Scenario: Modifying a script (PUT)

You can update a script by calling a PUT operation on that script's endpoint. Your PUT should contain fields that you want to update. Missing fields will be ignored by the receiving system. Systems may also ignore PUT values, depending on whether fields you are trying to modify are read-only or not. You may set an attribute to nil by including the attribute using nil for value.

{% include array_warning.md %}

Request

PUT https://osdi-sample-system.org/api/v1/scipts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa

Header:
OSDI-API-Token:[your api key here]

{
    "name": "Script 1",
    "title": "Persuasion Script"
}

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate
{
    "identifiers": [
        "osdi_sample_system:d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa",
        "foreign_system:1"
    ],
    "origin_system": "OSDI Sample System",
    "created_date": "2014-03-20T21:04:31Z",
    "modified_date": "2014-03-20T21:04:31Z",
    "name": "Script 1",
    "title": "Persuasion Script",
    "description": "<p>Persuasion Script for Area A</p>",
    "summary": "Persuasion Script for Area A",
    "_links": {
        "self": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ec501b0baa"
        },
        "osdi:creator": {
            "href": "https://osdi-sample-system.org/api/v1/people/65345d7d-cd24-466a-a698-4a7686ef684f"
        },
        "osdi:modified_by": {
            "href": "https://osdi-sample-system.org/api/v1/people/c945d6fe-929e-11e3-a2e9-12313d316c29"
        },
        "osdi:script_questions": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/c945d6fe-929e-11e3-a2e9/script_questions"
        },
        "osdi:canvassing_effort" : {
            "href": "https://osdi-sample-system.org/api/v1/canvassing_efforts/c945d6fe-929e-11e3-a2e9"
        }
    }
}

Back to top...

Scenario: Deleting a script (DELETE)

You may delete a script by calling the DELETE command on the script's endpoint.

Request

DELETE https://osdi-sample-system.org/api/v1/scripts/d32fcdd6-7366-466d-a3b8-7e0d87c3cd8b

Header:
OSDI-API-Token:[your api key here]

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate

{
    "notice": "This script was successfully deleted."
}

Back to top...