Get a list of products

Content

Resource URL

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

Example

Request

 1use Ticketmatic\Endpoints\Settings\Products;
 2
 3$result = Products::getlist($client, array(
 4    "typeid" => 26001,
 5    "filter" => "SELECT id FROM tm.product WHERE saleschannels @> '[1]' OR saleschannels @> '[2]'",
 6    "includearchived" => true,
 7    "lastupdatesince" => "2014-09-26 15:24:36",
 8));
 9
10// The parameters array is optional, it can be omitted when empty.
11$result = Products::getlist($client);

Response

  1object(Ticketmatic\Endpoints\Settings\ProductsList) (1) {
  2  ["data"]=>
  3  array(1) {
  4    [0]=>
  5    object(\Ticketmatic\Model\Product) (15) {
  6      ["id"]=>
  7      int(0)
  8      ["typeid"]=>
  9      int(0)
 10      ["categoryid"]=>
 11      int(0)
 12      ["layoutid"]=>
 13      int(0)
 14      ["name"]=>
 15      string(7) "T-shirt"
 16      ["code"]=>
 17      string(12) "123412341234"
 18      ["description"]=>
 19      string(38) "The new t-shirt is made of 100% cotton"
 20      ["instancevalues"]=>
 21      object(\Ticketmatic\Model\ProductInstancevalues) (2) {
 22        ["default"]=>
 23        object(\Ticketmatic\Model\ProductInstanceValue) (2) {
 24          ["price"]=>
 25          float(25.000000)
 26          ["voucher"]=>
 27          object(\Ticketmatic\Model\ProductVoucherValue) (2) {
 28            ["amount"]=>
 29            float(10.000000)
 30            ["voucherid"]=>
 31            int(0)
 32          }
 33        }
 34        ["exceptions"]=>
 35        array(2) {
 36          [0]=>
 37          object(\Ticketmatic\Model\ProductInstanceException) (2) {
 38            ["properties"]=>
 39            array(2) {
 40              ["colour"]=>
 41                array(1) {
 42                  [0]=>
 43                  string(3) "red"
 44                }
 45              ["size"]=>
 46                array(1) {
 47                  [0]=>
 48                  string(1) "S"
 49                }
 50            }
 51            ["value"]=>
 52            object(\Ticketmatic\Model\ProductInstanceValue) (2) {
 53              ["price"]=>
 54              float(15.000000)
 55              ["voucher"]=>
 56              object(\Ticketmatic\Model\ProductVoucherValue) (2) {
 57                ["amount"]=>
 58                float(10.000000)
 59                ["voucherid"]=>
 60                int(0)
 61              }
 62            }
 63          }
 64          [1]=>
 65          object(\Ticketmatic\Model\ProductInstanceException) (2) {
 66            ["properties"]=>
 67            array(2) {
 68              ["colour"]=>
 69                array(1) {
 70                  [0]=>
 71                  string(3) "red"
 72                }
 73              ["size"]=>
 74                array(1) {
 75                  [0]=>
 76                  string(1) "M"
 77                }
 78            }
 79            ["value"]=>
 80            object(\Ticketmatic\Model\ProductInstanceValue) (2) {
 81              ["price"]=>
 82              float(17.000000)
 83              ["voucher"]=>
 84              object(\Ticketmatic\Model\ProductVoucherValue) (2) {
 85                ["amount"]=>
 86                float(30.000000)
 87                ["voucherid"]=>
 88                int(0)
 89              }
 90            }
 91          }
 92        }
 93      }
 94      ["printtickets"]=>
 95      bool(true)
 96      ["properties"]=>
 97      array(2) {
 98        [0]=>
 99        object(\Ticketmatic\Model\ProductProperty) (4) {
100          ["name"]=>
101          string(4) "Size"
102          ["description"]=>
103          string(19) "Size of the t-shirt"
104          ["key"]=>
105          string(4) "size"
106          ["values"]=>
107          array(3) {
108            [0]=>
109            object(\Ticketmatic\Model\KeyValueItem) (2) {
110              ["key"]=>
111              string(1) "S"
112              ["value"]=>
113              string(5) "Small"
114            }
115            [1]=>
116            object(\Ticketmatic\Model\KeyValueItem) (2) {
117              ["key"]=>
118              string(1) "M"
119              ["value"]=>
120              string(6) "Medium"
121            }
122            [2]=>
123            object(\Ticketmatic\Model\KeyValueItem) (2) {
124              ["key"]=>
125              string(1) "L"
126              ["value"]=>
127              string(5) "Large"
128            }
129          }
130        }
131        [1]=>
132        object(\Ticketmatic\Model\ProductProperty) (4) {
133          ["name"]=>
134          string(6) "Colour"
135          ["description"]=>
136          string(21) "Colour of the t-shirt"
137          ["key"]=>
138          string(6) "colour"
139          ["values"]=>
140          array(2) {
141            [0]=>
142            object(\Ticketmatic\Model\KeyValueItem) (2) {
143              ["key"]=>
144              string(3) "red"
145              ["value"]=>
146              string(3) "Red"
147            }
148            [1]=>
149            object(\Ticketmatic\Model\KeyValueItem) (2) {
150              ["key"]=>
151              string(5) "green"
152              ["value"]=>
153              string(5) "Green"
154            }
155          }
156        }
157      }
158      ["saleendts"]=>
159      object(\DateTime) (3) {
160        ["date"]=>
161        string(26) "2016-01-01 00:00:00.000000"
162        ["timezone_type"]=>
163        int(3)
164        ["timezone"]=>
165        string(3) "UTC"
166      }
167      ["salestartts"]=>
168      object(\DateTime) (3) {
169        ["date"]=>
170        string(26) "2016-01-01 00:00:00.000000"
171        ["timezone_type"]=>
172        int(3)
173        ["timezone"]=>
174        string(3) "UTC"
175      }
176      ["isarchived"]=>
177      bool(false)
178      ["createdts"]=>
179      object(\DateTime) (3) {
180        ["date"]=>
181        string(26) "2014-09-26 15:24:36.000000"
182        ["timezone_type"]=>
183        int(3)
184        ["timezone"]=>
185        string(3) "UTC"
186      }
187      ["lastupdatets"]=>
188      object(\DateTime) (3) {
189        ["date"]=>
190        string(26) "2014-09-26 15:24:36.000000"
191        ["timezone_type"]=>
192        int(3)
193        ["timezone"]=>
194        string(3) "UTC"
195      }
196    }
197  }
198}

Request

 1import (
 2    "github.com/ticketmatic/tm-go/ticketmatic"
 3    "github.com/ticketmatic/tm-go/ticketmatic/settings/products"
 4)
 5
 6result, err := products.Getlist(client, &ticketmatic.ProductQuery{
 7    Typeid: 26001,
 8    Filter: "SELECT id FROM tm.product WHERE saleschannels @> '[1]' OR saleschannels @> '[2]'",
 9    Includearchived: true,
10    Lastupdatesince: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
11})
12
13// The query object is optional, it can be omitted when empty.
14result, err := products.Getlist(client, nil)

Response

  1result := products.&List{
  2    Data: []*ticketmatic.Product{
  3        &ticketmatic.Product{
  4            Id: 123,
  5            Typeid: 26001,
  6            Categoryid: 1,
  7            Layoutid: 1,
  8            Name: "T-shirt",
  9            Code: "123412341234",
 10            Description: "The new t-shirt is made of 100% cotton",
 11            Instancevalues: &ticketmatic.ProductInstancevalues{
 12                Default: &ticketmatic.ProductInstanceValue{
 13                    Price: 25,
 14                    Voucher: &ticketmatic.ProductVoucherValue{
 15                        Amount: 10,
 16                        Voucherid: 123,
 17                    },
 18                },
 19                Exceptions: []*ticketmatic.ProductInstanceException{
 20                    &ticketmatic.ProductInstanceException{
 21                        Properties: map[string][]string{
 22                            "colour": []string{
 23                                "red",
 24                            },
 25                            "size": []string{
 26                                "S",
 27                            },
 28                        },
 29                        Value: &ticketmatic.ProductInstanceValue{
 30                            Price: 15,
 31                            Voucher: &ticketmatic.ProductVoucherValue{
 32                                Amount: 10,
 33                                Voucherid: 123,
 34                            },
 35                        },
 36                    },
 37                    &ticketmatic.ProductInstanceException{
 38                        Properties: map[string][]string{
 39                            "colour": []string{
 40                                "red",
 41                            },
 42                            "size": []string{
 43                                "M",
 44                            },
 45                        },
 46                        Value: &ticketmatic.ProductInstanceValue{
 47                            Price: 17,
 48                            Voucher: &ticketmatic.ProductVoucherValue{
 49                                Amount: 30,
 50                                Voucherid: 124,
 51                            },
 52                        },
 53                    },
 54                },
 55            },
 56            Printtickets: true,
 57            Properties: []*ticketmatic.ProductProperty{
 58                &ticketmatic.ProductProperty{
 59                    Name: "Size",
 60                    Description: "Size of the t-shirt",
 61                    Key: "size",
 62                    Values: []*ticketmatic.KeyValueItem{
 63                        &ticketmatic.KeyValueItem{
 64                            Key: "S",
 65                            Value: "Small",
 66                        },
 67                        &ticketmatic.KeyValueItem{
 68                            Key: "M",
 69                            Value: "Medium",
 70                        },
 71                        &ticketmatic.KeyValueItem{
 72                            Key: "L",
 73                            Value: "Large",
 74                        },
 75                    },
 76                },
 77                &ticketmatic.ProductProperty{
 78                    Name: "Colour",
 79                    Description: "Colour of the t-shirt",
 80                    Key: "colour",
 81                    Values: []*ticketmatic.KeyValueItem{
 82                        &ticketmatic.KeyValueItem{
 83                            Key: "red",
 84                            Value: "Red",
 85                        },
 86                        &ticketmatic.KeyValueItem{
 87                            Key: "green",
 88                            Value: "Green",
 89                        },
 90                    },
 91                },
 92            },
 93            Saleendts: ticketmatic.NewTime(ticketmatic.MustParseTime("2016-01-01 00:00:00")),
 94            Salestartts: ticketmatic.NewTime(ticketmatic.MustParseTime("2016-01-01 00:00:00")),
 95            Isarchived: false,
 96            Createdts: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
 97            Lastupdatets: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
 98        },
 99    },
100}

Request

1GET /api/1/{accountname}/settings/products HTTP/1.1

Response

  1HTTP/1.1 200 OK
  2Content-Type: application/json
  3
  4{
  5    "data": [
  6        {
  7            "id": 123,
  8            "typeid": 26001,
  9            "categoryid": 1,
 10            "layoutid": 1,
 11            "name": "T-shirt",
 12            "code": "123412341234",
 13            "description": "The new t-shirt is made of 100% cotton",
 14            "instancevalues": {
 15                "default": {
 16                    "price": 25.000000,
 17                    "voucher": {
 18                        "amount": 10.000000,
 19                        "voucherid": 123
 20                    }
 21                },
 22                "exceptions": [
 23                    {
 24                        "properties": {
 25                            "colour": [
 26                                "red"
 27                            ],
 28                            "size": [
 29                                "S"
 30                            ]
 31                        },
 32                        "value": {
 33                            "price": 15.000000,
 34                            "voucher": {
 35                                "amount": 10.000000,
 36                                "voucherid": 123
 37                            }
 38                        }
 39                    },
 40                    {
 41                        "properties": {
 42                            "colour": [
 43                                "red"
 44                            ],
 45                            "size": [
 46                                "M"
 47                            ]
 48                        },
 49                        "value": {
 50                            "price": 17.000000,
 51                            "voucher": {
 52                                "amount": 30.000000,
 53                                "voucherid": 124
 54                            }
 55                        }
 56                    }
 57                ]
 58            },
 59            "printtickets": true,
 60            "properties": [
 61                {
 62                    "name": "Size",
 63                    "description": "Size of the t-shirt",
 64                    "key": "size",
 65                    "values": [
 66                        {
 67                            "key": "S",
 68                            "value": "Small"
 69                        },
 70                        {
 71                            "key": "M",
 72                            "value": "Medium"
 73                        },
 74                        {
 75                            "key": "L",
 76                            "value": "Large"
 77                        }
 78                    ]
 79                },
 80                {
 81                    "name": "Colour",
 82                    "description": "Colour of the t-shirt",
 83                    "key": "colour",
 84                    "values": [
 85                        {
 86                            "key": "red",
 87                            "value": "Red"
 88                        },
 89                        {
 90                            "key": "green",
 91                            "value": "Green"
 92                        }
 93                    ]
 94                }
 95            ],
 96            "saleendts": "2016-01-01 00:00:00",
 97            "salestartts": "2016-01-01 00:00:00",
 98            "isarchived": false,
 99            "createdts": "2014-09-26 15:24:36",
100            "lastupdatets": "2014-09-26 15:24:36"
101        }
102    ]
103}

Parameters

FieldDescription
typeid
        </td>
        <td class="description">
            <p>Only return items with the given typeid.</p> 
            <strong>Example value:</strong><code>26001</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">filter</div>
            
        </td>
        <td class="description">
            <p>Filter the returned items by specifying a query on the public datamodel that returns the ids.</p> 
            <strong>Example value:</strong><code>&#34;SELECT id FROM tm.product WHERE saleschannels @&gt; &#39;[1]&#39; OR saleschannels @&gt; &#39;[2]&#39;&#34;</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">includearchived</div>
            
        </td>
        <td class="description">
            <p>If this parameter is true, archived items will be returned as well.</p> 
            <strong>Example value:</strong><code>true</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">lastupdatesince</div>
            
        </td>
        <td class="description">
            <p>All items that were updated since this timestamp will be returned. Timestamp should be passed in <code>YYYY-MM-DD hh:mm:ss</code> format.</p> 
            <strong>Example value:</strong><code>&#34;2014-09-26 15:24:36&#34;</code>
        </td>
    </tr>
</tbody>

Type reference: ProductQuery

Result fields

This call returns an object with an array of objects in the data field.

FieldDescription
id
int

Unique ID

Example value:123
typeid
int

Type ID

Example value:26001
categoryid
int

Category for the product. Categories can be managed in account parameters and indicate the labels for a single and multiple product and also what labels to use for the holders of the product. If not set, the UI will fallback to default labels.

Example value:1
layoutid
int

Optional layout for the product. If not specified, there will be no ticket generated for the product

Example value:1
name

Name for the product

Example value:"T-shirt"
code
string

Unique 12-digit for the product

Example value:"123412341234"
description

Description for the product

Example value:"The new t-shirt is made of 100% cotton"
instancevalues

Instancevalues control the price for a product and for non simple products it also controls the content of the product. All products should have a default instancevalue and a set of exceptions (if there are any). If no specific exception is found for the selected product, the default instancevalue is used.

Example value:{ "default": { "price": 25.000000, "voucher": { "amount": 10.000000, "voucherid": 123 } }, "exceptions": [ { "properties": { "colour": [ "red" ], "size": [ "S" ] }, "value": { "price": 15.000000, "voucher": { "amount": 10.000000, "voucherid": 123 } } }, { "properties": { "colour": [ "red" ], "size": [ "M" ] }, "value": { "price": 17.000000, "voucher": { "amount": 30.000000, "voucherid": 124 } } } ] }
printtickets
bool

If true, tickets for items that belong to the product will be printed when printing the product.

Example value:true
properties

Definition of possible properties for the product. A product can have one or more properties. Properties can be used to introduce variants of a product (sizes of a t-shirt for example).

Example value:[ { "name": "Size", "description": "Size of the t-shirt", "key": "size", "values": [ { "key": "S", "value": "Small" }, { "key": "M", "value": "Medium" }, { "key": "L", "value": "Large" } ] }, { "name": "Colour", "description": "Colour of the t-shirt", "key": "colour", "values": [ { "key": "red", "value": "Red" }, { "key": "green", "value": "Green" } ] } ]
saleendts
timestamp

End of sales

Example value:"2016-01-01 00:00:00"
salestartts
timestamp

Start of sales

Example value:"2016-01-01 00:00:00"
isarchived
bool

Whether or not this item is archived

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"

This type can have custom fields.

Type reference: Product[]