Get a list of vouchers

Content

Resource URL

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

Example

Request

 1use Ticketmatic\Endpoints\Settings\Vouchers;
 2
 3$result = Vouchers::getlist($client, array(
 4    "typeid" => 24001,
 5    "filter" => "SELECT id FROM tm.voucher WHERE nbrofcodes=0",
 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 = Vouchers::getlist($client);

Response

 1object(Ticketmatic\Endpoints\Settings\VouchersList) (1) {
 2  ["data"]=>
 3  array(1) {
 4    [0]=>
 5    object(\Ticketmatic\Model\Voucher) (11) {
 6      ["id"]=>
 7      int(0)
 8      ["typeid"]=>
 9      int(0)
10      ["name"]=>
11      string(12) "Gift voucher"
12      ["codeformatid"]=>
13      int(0)
14      ["description"]=>
15      string(24) "Gift voucher description"
16      ["nbrofcodes"]=>
17      int(0)
18      ["ordervalidationscript"]=>
19      string(29) "return order.tickets.count<5;"
20      ["paymentmethodid"]=>
21      int(0)
22      ["isarchived"]=>
23      bool(false)
24      ["createdts"]=>
25      object(\DateTime) (3) {
26        ["date"]=>
27        string(26) "2014-09-26 15:24:36.000000"
28        ["timezone_type"]=>
29        int(3)
30        ["timezone"]=>
31        string(3) "UTC"
32      }
33      ["lastupdatets"]=>
34      object(\DateTime) (3) {
35        ["date"]=>
36        string(26) "2014-09-26 15:24:36.000000"
37        ["timezone_type"]=>
38        int(3)
39        ["timezone"]=>
40        string(3) "UTC"
41      }
42    }
43  }
44}

Request

 1import (
 2    "github.com/ticketmatic/tm-go/ticketmatic"
 3    "github.com/ticketmatic/tm-go/ticketmatic/settings/vouchers"
 4)
 5
 6result, err := vouchers.Getlist(client, &ticketmatic.VoucherQuery{
 7    Typeid: 24001,
 8    Filter: "SELECT id FROM tm.voucher WHERE nbrofcodes=0",
 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 := vouchers.Getlist(client, nil)

Response

 1result := vouchers.&List{
 2    Data: []*ticketmatic.Voucher{
 3        &ticketmatic.Voucher{
 4            Id: 123,
 5            Typeid: 24001,
 6            Name: "Gift voucher",
 7            Codeformatid: 27001,
 8            Description: "Gift voucher description",
 9            Nbrofcodes: 10000,
10            Ordervalidationscript: "return order.tickets.count<5;",
11            Paymentmethodid: 345,
12            Isarchived: false,
13            Createdts: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
14            Lastupdatets: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
15        },
16    },
17}

Request

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

Response

 1HTTP/1.1 200 OK
 2Content-Type: application/json
 3
 4{
 5    "data": [
 6        {
 7            "id": 123,
 8            "typeid": 24001,
 9            "name": "Gift voucher",
10            "codeformatid": 27001,
11            "description": "Gift voucher description",
12            "nbrofcodes": 10000,
13            "ordervalidationscript": "return order.tickets.count<5;",
14            "paymentmethodid": 345,
15            "isarchived": false,
16            "createdts": "2014-09-26 15:24:36",
17            "lastupdatets": "2014-09-26 15:24:36"
18        }
19    ]
20}

Parameters

FieldDescription
typeid

Only return items with the given typeid.

Example value:24001
filter

Filter the returned items by specifying a query on the public datamodel that returns the ids.

Example value:"SELECT id FROM tm.voucher WHERE nbrofcodes=0"
includearchived

If this parameter is true, archived items will be returned as well.

Example value:true
lastupdatesince

All items that were updated since this timestamp will be returned. Timestamp should be passed in YYYY-MM-DD hh:mm:ss format.

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

Type reference: VoucherQuery

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:24001
name

Name of the voucher

Example value:"Gift voucher"
codeformatid
int

Format used when generating codes for the voucher. Possible values:

  • 27001: 12 digits
  • 27002: 16 digits
  • 27003: 8 alphanumerical characters
  • 27004: 12 alphanumerical characters
  • 27005: 16 alphanumerical characters
  • 27099: Specified from list, not autogenerated
Example value:27001
description

Description of the voucher

Example value:"Gift voucher description"
nbrofcodes
int

The number of codes that were created for this voucher.

Example value:10000
ordervalidationscript
string

A validation script that is used for vouchers of type order. For each order with a voucher of this type attached, the script will be run to validate the contents

Example value:"return order.tickets.count<5;"
paymentmethodid
int

Paymentmethod to use when creating payments for vouchers of type payment. This field is required when a payment voucher is created. The paymentmethod that is referred to should be of a voucher type.

Example value:345
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"

Type reference: Voucher[]