Create a new document

Content

Resource URL

https://apps.ticketmatic.com/api/1/{accountname}/settings/communicationanddesign/documents

Example

Request

 1use Ticketmatic\Endpoints\Settings\Communicationanddesign\Documents;
 2
 3$result = Documents::create($client, array(
 4    "typeid" => 10001,
 5    "name" => "Invoice",
 6    "css" => "@page {\r\n    padding: 0;\r\n    margin: 0pt 0pt 0pt 0pt;\r\n    size: 152mm 82mm;\r\n}",
 7    "description" => "Invoice document",
 8    "enabled" => true,
 9    "htmltemplate" => "<html><head><meta charset=\"UTF-8\"><\\/head><body><\\/body><\\/html>",
10    "options" => array(
11        "nbrperpage" => 4,
12    ),
13    "translations" => array(
14        "en" => "...",
15        "nl" => "...",
16    ),
17));

Response

 1object(\Ticketmatic\Model\Document) (11) {
 2  ["id"]=>
 3  int(0)
 4  ["typeid"]=>
 5  int(0)
 6  ["name"]=>
 7  string(7) "Invoice"
 8  ["css"]=>
 9  string(80) "@page {
10    padding: 0;
11    margin: 0pt 0pt 0pt 0pt;
12    size: 152mm 82mm;
13}"
14  ["description"]=>
15  string(16) "Invoice document"
16  ["enabled"]=>
17  bool(true)
18  ["htmltemplate"]=>
19  string(64) "<html><head><meta charset="UTF-8"><\/head><body><\/body><\/html>"
20  ["options"]=>
21  object(\Ticketmatic\Model\DocumentOptions) (1) {
22    ["nbrperpage"]=>
23    int(0)
24  }
25  ["translations"]=>
26  array(2) {
27    ["en"]=>
28    string(3) "..."
29    ["nl"]=>
30    string(3) "..."
31  }
32  ["createdts"]=>
33  object(\DateTime) (3) {
34    ["date"]=>
35    string(26) "2014-09-26 15:24:36.000000"
36    ["timezone_type"]=>
37    int(3)
38    ["timezone"]=>
39    string(3) "UTC"
40  }
41  ["lastupdatets"]=>
42  object(\DateTime) (3) {
43    ["date"]=>
44    string(26) "2014-09-26 15:24:36.000000"
45    ["timezone_type"]=>
46    int(3)
47    ["timezone"]=>
48    string(3) "UTC"
49  }
50}
51

Request

 1import (
 2    "github.com/ticketmatic/tm-go/ticketmatic"
 3    "github.com/ticketmatic/tm-go/ticketmatic/settings/communicationanddesign/documents"
 4)
 5
 6result, err := documents.Create(client, &ticketmatic.Document{
 7    Typeid: 10001,
 8    Name: "Invoice",
 9    Css: "@page {\r\n    padding: 0;\r\n    margin: 0pt 0pt 0pt 0pt;\r\n    size: 152mm 82mm;\r\n}",
10    Description: "Invoice document",
11    Enabled: true,
12    Htmltemplate: "<html><head><meta charset=\"UTF-8\"><\\/head><body><\\/body><\\/html>",
13    Options: &ticketmatic.DocumentOptions{
14        Nbrperpage: 4,
15    },
16    Translations: map[string]string{
17        "en": "...",
18        "nl": "...",
19    },
20})

Response

 1result := &ticketmatic.Document{
 2    Id: 123,
 3    Typeid: 10001,
 4    Name: "Invoice",
 5    Css: "@page {\r\n    padding: 0;\r\n    margin: 0pt 0pt 0pt 0pt;\r\n    size: 152mm 82mm;\r\n}",
 6    Description: "Invoice document",
 7    Enabled: true,
 8    Htmltemplate: "<html><head><meta charset=\"UTF-8\"><\\/head><body><\\/body><\\/html>",
 9    Options: &ticketmatic.DocumentOptions{
10        Nbrperpage: 4,
11    },
12    Translations: map[string]string{
13        "en": "...",
14        "nl": "...",
15    },
16    Createdts: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
17    Lastupdatets: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
18}

Request

 1POST /api/1/{accountname}/settings/communicationanddesign/documents HTTP/1.1
 2Content-Type: application/json
 3
 4{
 5    "typeid": 10001,
 6    "name": "Invoice",
 7    "css": "@page {
 8    padding: 0;
 9    margin: 0pt 0pt 0pt 0pt;
10    size: 152mm 82mm;
11}",
12    "description": "Invoice document",
13    "enabled": true,
14    "htmltemplate": "<html><head><meta charset="UTF-8"><\/head><body><\/body><\/html>",
15    "options": {
16        "nbrperpage": 4
17    },
18    "translations": {
19        "en": "...",
20        "nl": "..."
21    }
22}

Response

 1HTTP/1.1 200 OK
 2Content-Type: application/json
 3
 4{
 5    "id": 123,
 6    "typeid": 10001,
 7    "name": "Invoice",
 8    "css": "@page {
 9    padding: 0;
10    margin: 0pt 0pt 0pt 0pt;
11    size: 152mm 82mm;
12}",
13    "description": "Invoice document",
14    "enabled": true,
15    "htmltemplate": "<html><head><meta charset="UTF-8"><\/head><body><\/body><\/html>",
16    "options": {
17        "nbrperpage": 4
18    },
19    "translations": {
20        "en": "...",
21        "nl": "..."
22    },
23    "createdts": "2014-09-26 15:24:36",
24    "lastupdatets": "2014-09-26 15:24:36"
25}

Request body fields

FieldDescription
typeid
int 
(required)

Type ID

Example value:10001
name
mlstring 
(required)

Name of the document

Example value:"Invoice"
css
string 
(required)

Css content for the document template

Example value:"@page { padding: 0; margin: 0pt 0pt 0pt 0pt; size: 152mm 82mm; }"
description
mlstring 
(required)

Description of the document

Example value:"Invoice document"
enabled
bool 
(required)

Translations for the document template

Example value:true
htmltemplate
string 
(required)

HTML content for the document template

Example value:"<html><head><meta charset="UTF-8"><\/head><body><\/body><\/html>"
options
DocumentOptions 
(required)

Key-value array of options. Can contain: nbrperpage

Example value:{ "nbrperpage": 4 }
translations
map<string, string> 
(required)

Translations for the document template

Example value:{ "en": "...", "nl": "..." }

Type reference: Document

Result fields

FieldDescription
id
int

Unique ID

Example value:123
typeid
int

Type ID

Example value:10001
name

Name of the document

Example value:"Invoice"
css
string

Css content for the document template

Example value:"@page { padding: 0; margin: 0pt 0pt 0pt 0pt; size: 152mm 82mm; }"
description

Description of the document

Example value:"Invoice document"
enabled
bool

Translations for the document template

Example value:true
htmltemplate
string

HTML content for the document template

Example value:"<html><head><meta charset="UTF-8"><\/head><body><\/body><\/html>"
options

Key-value array of options. Can contain: nbrperpage

Example value:{ "nbrperpage": 4 }
translations
map<string, string>

Translations for the document template

Example value:{ "en": "...", "nl": "..." }
createdts
timestamp

Created timestamp

Example value:"2014-09-26 15:24:36"
lastupdatets
timestamp

Last updated timestamp

Example value:"2014-09-26 15:24:36"

Type reference: Document