Exemple #1
0
func TestGettickets(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	list, err := Getlist(c, &ticketmatic.EventQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(list.Data) <= 0 {
		t.Errorf("Unexpected list.Data length, got %#v, expected greater than %#v", len(list.Data), 0)
	}

	stream, err := Gettickets(c, list.Data[0].Id, &ticketmatic.EventTicketQuery{})
	if err != nil {
		t.Fatal(err)
	}

	tickets := make([]*ticketmatic.EventTicket, 0)
	for {
		n, err := stream.Next()
		if err != nil {
			t.Fatal(err)
		}
		if n == nil {
			break
		}
		tickets = append(tickets, n)
	}

}
Exemple #2
0
func TestGet(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Queries(c, &ticketmatic.QueryRequest{
		Limit: 2,
		Query: "SELECT * FROM tm.paymentscenario",
	})
	if err != nil {
		t.Fatal(err)
	}

	if req.Nbrofresults <= 1 {
		t.Errorf("Unexpected req.Nbrofresults, got %#v, expected > %#v", req.Nbrofresults, 1)
	}

	if len(req.Results) != 2 {
		t.Errorf("Unexpected req.Results length, got %#v, expected %#v", len(req.Results), 2)
	}

}
Exemple #3
0
func TestGet(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	list, err := Getlist(c, &ticketmatic.ContactQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(list.Data) <= 0 {
		t.Errorf("Unexpected list.Data length, got %#v, expected greater than %#v", len(list.Data), 0)
	}

	contact, err := Get(c, list.Data[0].Id)
	if err != nil {
		t.Fatal(err)
	}

	if contact.Id != list.Data[0].Id {
		t.Errorf("Unexpected contact.Id, got %#v, expected %#v", contact.Id, list.Data[0].Id)
	}

}
Exemple #4
0
func TestCreatecodes(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	codes, err := Createcodes(c, 2, &ticketmatic.AddVoucherCodes{
		Amount: 10,
		Count:  3,
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(codes) != 3 {
		t.Errorf("Unexpected codes length, got %#v, expected %#v", len(codes), 3)
	}

	if codes[0].Code == "" {
		t.Errorf("Unexpected codes[0].Code, got %#v, expected different value", codes[0].Code)
	}

}
Exemple #5
0
func TestGet(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Getlist(c)
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) <= 0 {
		t.Errorf("Unexpected req.Data length, got %#v, expected greater than %#v", len(req.Data), 0)
	}

	reqget, err := Get(c, req.Data[0].Id)
	if err != nil {
		t.Fatal(err)
	}

	if reqget.Id <= 0 {
		t.Errorf("Unexpected reqget.Id, got %#v, expected > %#v", reqget.Id, 0)
	}

	_, err = Translations(c, reqget.Id)
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #6
0
func TestGet(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	list, err := Getlist(c, &ticketmatic.OrderQuery{
		Output: "withlookup",
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(list.Data) <= 0 {
		t.Errorf("Unexpected list.Data length, got %#v, expected greater than %#v", len(list.Data), 0)
	}

	order, err := Get(c, list.Data[0].Orderid)
	if err != nil {
		t.Fatal(err)
	}

	if order.Orderid != list.Data[0].Orderid {
		t.Errorf("Unexpected order.Orderid, got %#v, expected %#v", order.Orderid, list.Data[0].Orderid)
	}

}
Exemple #7
0
func TestExport(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Export(c, &ticketmatic.QueryRequest{
		Query: "SELECT * FROM tm.contact LIMIT 3",
	})
	if err != nil {
		t.Fatal(err)
	}

	stream := make([]map[string]interface{}, 0)
	for {
		n, err := req.Next()
		if err != nil {
			t.Fatal(err)
		}
		if n == nil {
			break
		}
		stream = append(stream, n)
	}

	if len(stream) != 3 {
		t.Errorf("Unexpected stream length, got %#v, expected %#v", len(stream), 3)
	}

}
Exemple #8
0
func TestCreatequeued(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	_, err = Create(c, &ticketmatic.CreateOrder{
		Events: []int64{
			777714,
		},
		Saleschannelid: 1,
	})
	var exc *ticketmatic.QueueStatus
	if err != nil {
		if e, ok := err.(*ticketmatic.RateLimitError); ok {
			exc = e.Status
		} else {
			t.Fatal(err)
		}
	}

	if exc == nil {
		t.Fatal("Expected a rate limiting error")
	}

	if exc.Id == "" {
		t.Errorf("Unexpected exc.Id, got %#v, expected different value", exc.Id)
	}

}
Exemple #9
0
func TestGet(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Getlist(c, &ticketmatic.PriceTypeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) <= 0 {
		t.Errorf("Unexpected req.Data length, got %#v, expected greater than %#v", len(req.Data), 0)
	}

	req2, err := Getlist(c, &ticketmatic.PriceTypeQuery{
		Filter: "select id from conf.pricetype where typeid=2301",
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) <= len(req2.Data) {
		t.Errorf("Unexpected req.Data length, got %#v, expected greater than %#v", len(req.Data), len(req2.Data))
	}

}
Exemple #10
0
func TestArchived(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	contact, err := Create(c, &ticketmatic.Contact{
		Firstname: "John",
	})
	if err != nil {
		t.Fatal(err)
	}

	if contact.Id == 0 {
		t.Errorf("Unexpected contact.Id, got %#v, expected different value", contact.Id)
	}

	if contact.Firstname != "John" {
		t.Errorf("Unexpected contact.Firstname, got %#v, expected %#v", contact.Firstname, "John")
	}

	req, err := Getlist(c, &ticketmatic.ContactQuery{
		Includearchived: true,
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) <= 0 {
		t.Errorf("Unexpected req.Data length, got %#v, expected greater than %#v", len(req.Data), 0)
	}

	err = Delete(c, contact.Id)
	if err != nil {
		t.Fatal(err)
	}

	req2, err := Getlist(c, &ticketmatic.ContactQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) <= len(req2.Data) {
		t.Errorf("Unexpected req.Data length, got %#v, expected greater than %#v", len(req.Data), len(req2.Data))
	}

	req3, err := Getlist(c, &ticketmatic.ContactQuery{
		Includearchived: true,
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) != len(req3.Data) {
		t.Errorf("Unexpected req.Data length, got %#v, expected %#v", len(req.Data), len(req3.Data))
	}

}
Exemple #11
0
func TestCreate(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	event, err := Create(c, &ticketmatic.Event{
		Name: "Example",
		Contingents: []*ticketmatic.EventContingent{
			&ticketmatic.EventContingent{
				Amount: 100,
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if event.Name != "Example" {
		t.Errorf("Unexpected event.Name, got %#v, expected %#v", event.Name, "Example")
	}

	if event.Contingents[0].Amount != 100 {
		t.Errorf("Unexpected event.Contingents[0].Amount, got %#v, expected %#v", event.Contingents[0].Amount, 100)
	}

}
Exemple #12
0
func TestAddticketsqueued(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	order, err := Create(c, &ticketmatic.CreateOrder{
		Saleschannelid: 1,
	})
	if err != nil {
		t.Fatal(err)
	}

	if order.Orderid == 0 {
		t.Errorf("Unexpected order.Orderid, got %#v, expected different value", order.Orderid)
	}

	if order.Saleschannelid != 1 {
		t.Errorf("Unexpected order.Saleschannelid, got %#v, expected %#v", order.Saleschannelid, 1)
	}

	ttps, err := events.Get(c, 777713)
	if err != nil {
		t.Fatal(err)
	}

	if ttps.Id == 0 {
		t.Errorf("Unexpected ttps.Id, got %#v, expected different value", ttps.Id)
	}

	_, err = Addtickets(c, order.Orderid, &ticketmatic.AddTickets{
		Tickets: []*ticketmatic.CreateTicket{
			&ticketmatic.CreateTicket{
				Tickettypepriceid: ttps.Prices.Contingents[0].Pricetypes[0].Tickettypepriceid,
			},
		},
	})
	var exc *ticketmatic.QueueStatus
	if err != nil {
		if e, ok := err.(*ticketmatic.RateLimitError); ok {
			exc = e.Status
		} else {
			t.Fatal(err)
		}
	}

	if exc == nil {
		t.Fatal("Expected a rate limiting error")
	}

	if exc.Id == "" {
		t.Errorf("Unexpected exc.Id, got %#v, expected different value", exc.Id)
	}

}
Exemple #13
0
func TestCreateunicode(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	contact, err := Create(c, &ticketmatic.Contact{
		Firstname: "JØhñ",
		Lastname:  "ポテト 👌 ไก่",
	})
	if err != nil {
		t.Fatal(err)
	}

	if contact.Id == 0 {
		t.Errorf("Unexpected contact.Id, got %#v, expected different value", contact.Id)
	}

	if contact.Firstname != "JØhñ" {
		t.Errorf("Unexpected contact.Firstname, got %#v, expected %#v", contact.Firstname, "JØhñ")
	}

	if contact.Lastname != "ポテト 👌 ไก่" {
		t.Errorf("Unexpected contact.Lastname, got %#v, expected %#v", contact.Lastname, "ポテト 👌 ไก่")
	}

	contact2, err := Get(c, contact.Id)
	if err != nil {
		t.Fatal(err)
	}

	if contact2.Id == 0 {
		t.Errorf("Unexpected contact2.Id, got %#v, expected different value", contact2.Id)
	}

	if contact2.Firstname != "JØhñ" {
		t.Errorf("Unexpected contact2.Firstname, got %#v, expected %#v", contact2.Firstname, "JØhñ")
	}

	if contact2.Lastname != "ポテト 👌 ไก่" {
		t.Errorf("Unexpected contact2.Lastname, got %#v, expected %#v", contact2.Lastname, "ポテト 👌 ไก่")
	}

	err = Delete(c, contact.Id)
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #14
0
func TestDeletefixedbundleevent(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	err = Delete(c, 777704)

	if err == nil {
		t.Fatal("Expected an error!")
	}

}
Exemple #15
0
func TestCreate(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	contact, err := Create(c, &ticketmatic.Contact{
		Firstname: "John",
	})
	if err != nil {
		t.Fatal(err)
	}

	if contact.Id == 0 {
		t.Errorf("Unexpected contact.Id, got %#v, expected different value", contact.Id)
	}

	if contact.Firstname != "John" {
		t.Errorf("Unexpected contact.Firstname, got %#v, expected %#v", contact.Firstname, "John")
	}

	updated, err := Update(c, contact.Id, &ticketmatic.Contact{
		Lastname: "Doe",
	})
	if err != nil {
		t.Fatal(err)
	}

	if updated.Id != contact.Id {
		t.Errorf("Unexpected updated.Id, got %#v, expected %#v", updated.Id, contact.Id)
	}

	if updated.Firstname != "John" {
		t.Errorf("Unexpected updated.Firstname, got %#v, expected %#v", updated.Firstname, "John")
	}

	if updated.Lastname != "Doe" {
		t.Errorf("Unexpected updated.Lastname, got %#v, expected %#v", updated.Lastname, "Doe")
	}

	err = Delete(c, contact.Id)
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #16
0
func TestCreate(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	paymentscenario, err := Create(c, &ticketmatic.PaymentScenario{
		Typeid: 2705,
		Name:   "Payment scenario test",
		Availability: &ticketmatic.PaymentscenarioAvailability{
			Saleschannels: []int64{
				1,
			},
			Usescript: false,
		},
		Expiryparameters: &ticketmatic.PaymentscenarioExpiryParameters{
			Daysaftercreation: 24,
		},
		Internalremark: "Testing",
		Overdueparameters: &ticketmatic.PaymentscenarioOverdueParameters{
			Daysaftercreation: 12,
		},
		Paymentmethods: []int64{
			1,
			2,
		},
		Shortdescription: "Short test",
	})
	if err != nil {
		t.Fatal(err)
	}

	if paymentscenario.Id == 0 {
		t.Errorf("Unexpected paymentscenario.Id, got %#v, expected different value", paymentscenario.Id)
	}

	if paymentscenario.Typeid != 2705 {
		t.Errorf("Unexpected paymentscenario.Typeid, got %#v, expected %#v", paymentscenario.Typeid, 2705)
	}

	if paymentscenario.Name != "Payment scenario test" {
		t.Errorf("Unexpected paymentscenario.Name, got %#v, expected %#v", paymentscenario.Name, "Payment scenario test")
	}

}
Exemple #17
0
func TestCreate(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	fee, err := Create(c, &ticketmatic.TicketFee{
		Name: "Fee",
		Rules: &ticketmatic.TicketfeeRules{
			Default: []*ticketmatic.TicketfeeSaleschannelRule{
				&ticketmatic.TicketfeeSaleschannelRule{
					Saleschannelid: 1,
					Status:         "fixedfee",
					Value:          1,
				},
			},
			Exceptions: []*ticketmatic.TicketfeeException{
				&ticketmatic.TicketfeeException{
					Pricetypeid: 2,
					Saleschannels: []*ticketmatic.TicketfeeSaleschannelRule{
						&ticketmatic.TicketfeeSaleschannelRule{
							Saleschannelid: 1,
							Status:         "percentagefee",
							Value:          3.5,
						},
					},
				},
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if fee.Name != "Fee" {
		t.Errorf("Unexpected fee.Name, got %#v, expected %#v", fee.Name, "Fee")
	}

	if fee.Id == 0 {
		t.Errorf("Unexpected fee.Id, got %#v, expected different value", fee.Id)
	}

}
Exemple #18
0
func TestGetTime(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Time(c)
	if err != nil {
		t.Fatal(err)
	}

	if time.Since(req.Systemtime.Time()) > 24*time.Hour {
		t.Errorf("Unexpected req.Systemtime time, should be recent, got %s", req.Systemtime.Time())
	}

}
Exemple #19
0
func TestGet(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Getlist(c, &ticketmatic.RelationTypeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) <= 0 {
		t.Errorf("Unexpected req.Data length, got %#v, expected greater than %#v", len(req.Data), 0)
	}

}
Exemple #20
0
func TestSync(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	err = Sync(c, []*ticketmatic.SubscriberSync{
		&ticketmatic.SubscriberSync{
			Email:      "*****@*****.**",
			Subscribed: true,
		},
	})
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #21
0
func TestGetdraft(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	event, err := Create(c, &ticketmatic.Event{
		Name: "Draft",
	})
	if err != nil {
		t.Fatal(err)
	}

	if event.Name != "Draft" {
		t.Errorf("Unexpected event.Name, got %#v, expected %#v", event.Name, "Draft")
	}

	list, err := Getlist(c, &ticketmatic.EventQuery{
		Filter: "select id from tm.event where nameen='Draft'",
		Simplefilter: &ticketmatic.EventFilter{
			Status: []int64{
				19001,
				19002,
				19003,
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(list.Data) <= 0 {
		t.Errorf("Unexpected list.Data length, got %#v, expected greater than %#v", len(list.Data), 0)
	}

	err = Delete(c, event.Id)
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #22
0
func TestCommunications(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	err = Communications(c, &ticketmatic.SubscriberCommunication{
		Name: "test1",
		Addresses: []string{
			"*****@*****.**",
			"*****@*****.**",
		},
		Ts: ticketmatic.NewTime(ticketmatic.MustParseTime("2015-02-02")),
	})
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #23
0
func TestCreateAndDelete(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	orderfee, err := Create(c, &ticketmatic.OrderFee{
		Typeid: 2401,
		Name:   "Order fee test",
		Rule: &ticketmatic.OrderfeeRule{
			Auto: []*ticketmatic.OrderfeeAutoRule{
				&ticketmatic.OrderfeeAutoRule{
					Deliveryscenarioids: []int64{
						1,
					},
					Paymentscenarioids: []int64{
						1,
					},
					Saleschannelids: []int64{
						1,
					},
					Status: "fixedfee",
					Value:  1,
				},
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if orderfee.Id == 0 {
		t.Errorf("Unexpected orderfee.Id, got %#v, expected different value", orderfee.Id)
	}

	if orderfee.Typeid != 2401 {
		t.Errorf("Unexpected orderfee.Typeid, got %#v, expected %#v", orderfee.Typeid, 2401)
	}

	if orderfee.Name != "Order fee test" {
		t.Errorf("Unexpected orderfee.Name, got %#v, expected %#v", orderfee.Name, "Order fee test")
	}

	orderfeescript, err := Create(c, &ticketmatic.OrderFee{
		Typeid: 2402,
		Name:   "Order fee script test",
		Rule: &ticketmatic.OrderfeeRule{
			Context: []*ticketmatic.OrderfeeScriptContext{
				&ticketmatic.OrderfeeScriptContext{
					Cacheable: true,
					Key:       "test",
					Query:     "select 27 as nbroftickets",
				},
			},
			Script: "return 2;",
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if orderfeescript.Id == 0 {
		t.Errorf("Unexpected orderfeescript.Id, got %#v, expected different value", orderfeescript.Id)
	}

	if orderfeescript.Typeid != 2402 {
		t.Errorf("Unexpected orderfeescript.Typeid, got %#v, expected %#v", orderfeescript.Typeid, 2402)
	}

	if orderfeescript.Name != "Order fee script test" {
		t.Errorf("Unexpected orderfeescript.Name, got %#v, expected %#v", orderfeescript.Name, "Order fee script test")
	}

	if orderfeescript.Rule.Script != "return 2;" {
		t.Errorf("Unexpected orderfeescript.Rule.Script, got %#v, expected %#v", orderfeescript.Rule.Script, "return 2;")
	}

	if orderfeescript.Rule.Context[0].Key != "test" {
		t.Errorf("Unexpected orderfeescript.Rule.Context[0].Key, got %#v, expected %#v", orderfeescript.Rule.Context[0].Key, "test")
	}

	if orderfeescript.Rule.Context[0].Query != "select 27 as nbroftickets" {
		t.Errorf("Unexpected orderfeescript.Rule.Context[0].Query, got %#v, expected %#v", orderfeescript.Rule.Context[0].Query, "select 27 as nbroftickets")
	}

	list, err := Getlist(c, &ticketmatic.OrderFeeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(list.Data) <= 1 {
		t.Errorf("Unexpected list.Data length, got %#v, expected greater than %#v", len(list.Data), 1)
	}

	err = Delete(c, orderfee.Id)
	if err != nil {
		t.Fatal(err)
	}

	err = Delete(c, orderfeescript.Id)
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #24
0
func TestCreatecustom(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	titles, err := contacttitles.Getlist(c, &ticketmatic.ContactTitleQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(titles.Data) <= 0 {
		t.Errorf("Unexpected titles.Data length, got %#v, expected greater than %#v", len(titles.Data), 0)
	}

	addrtypes, err := contactaddresstypes.Getlist(c, &ticketmatic.ContactAddressTypeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(addrtypes.Data) <= 0 {
		t.Errorf("Unexpected addrtypes.Data length, got %#v, expected greater than %#v", len(addrtypes.Data), 0)
	}

	ptypes, err := phonenumbertypes.Getlist(c, &ticketmatic.PhoneNumberTypeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(ptypes.Data) <= 1 {
		t.Errorf("Unexpected ptypes.Data length, got %#v, expected greater than %#v", len(ptypes.Data), 1)
	}

	contact, err := Create(c, &ticketmatic.Contact{
		Addresses: []*ticketmatic.Address{
			&ticketmatic.Address{
				Typeid:      addrtypes.Data[0].Id,
				City:        "Nieuwerkerk Aan Den Ijssel",
				Countrycode: "NL",
				Street1:     "Kerkstraat",
				Street2:     "1",
				Zip:         "2914 AH",
			},
		},
		Birthdate:       ticketmatic.NewTime(ticketmatic.MustParseTime("1959-09-21")),
		Customertitleid: titles.Data[0].Id,
		Email:           "*****@*****.**",
		Firstname:       "John",
		Lastname:        "Johns",
		Middlename:      "J",
		Phonenumbers: []*ticketmatic.Phonenumber{
			&ticketmatic.Phonenumber{
				Typeid: ptypes.Data[0].Id,
				Number: "+31222222222",
			},
			&ticketmatic.Phonenumber{
				Typeid: ptypes.Data[1].Id,
				Number: "+31222222222",
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if contact.Id == 0 {
		t.Errorf("Unexpected contact.Id, got %#v, expected different value", contact.Id)
	}

	if contact.Firstname != "John" {
		t.Errorf("Unexpected contact.Firstname, got %#v, expected %#v", contact.Firstname, "John")
	}

	if contact.Addresses[0].Countrycode != "NL" {
		t.Errorf("Unexpected contact.Addresses[0].Countrycode, got %#v, expected %#v", contact.Addresses[0].Countrycode, "NL")
	}

	if contact.Addresses[0].Country != "Netherlands" {
		t.Errorf("Unexpected contact.Addresses[0].Country, got %#v, expected %#v", contact.Addresses[0].Country, "Netherlands")
	}

	err = Delete(c, contact.Id)
	if err != nil {
		t.Fatal(err)
	}

}
Exemple #25
0
func TestCreate(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	order, err := Create(c, &ticketmatic.CreateOrder{
		Saleschannelid: 1,
	})
	if err != nil {
		t.Fatal(err)
	}

	if order.Orderid == 0 {
		t.Errorf("Unexpected order.Orderid, got %#v, expected different value", order.Orderid)
	}

	if order.Saleschannelid != 1 {
		t.Errorf("Unexpected order.Saleschannelid, got %#v, expected %#v", order.Saleschannelid, 1)
	}

	updated, err := Update(c, order.Orderid, &ticketmatic.UpdateOrder{
		Customerid:         777701,
		Deliveryscenarioid: 2,
		Paymentscenarioid:  3,
	})
	if err != nil {
		t.Fatal(err)
	}

	if updated.Orderid != order.Orderid {
		t.Errorf("Unexpected updated.Orderid, got %#v, expected %#v", updated.Orderid, order.Orderid)
	}

	if updated.Deliveryscenarioid != 2 {
		t.Errorf("Unexpected updated.Deliveryscenarioid, got %#v, expected %#v", updated.Deliveryscenarioid, 2)
	}

	if updated.Paymentscenarioid != 3 {
		t.Errorf("Unexpected updated.Paymentscenarioid, got %#v, expected %#v", updated.Paymentscenarioid, 3)
	}

	if updated.Customerid != 777701 {
		t.Errorf("Unexpected updated.Customerid, got %#v, expected %#v", updated.Customerid, 777701)
	}

	ttps, err := events.Get(c, 777701)
	if err != nil {
		t.Fatal(err)
	}

	if ttps.Id == 0 {
		t.Errorf("Unexpected ttps.Id, got %#v, expected different value", ttps.Id)
	}

	ticketsadded, err := Addtickets(c, order.Orderid, &ticketmatic.AddTickets{
		Tickets: []*ticketmatic.CreateTicket{
			&ticketmatic.CreateTicket{
				Tickettypepriceid: ttps.Prices.Contingents[0].Pricetypes[0].Tickettypepriceid,
			},
			&ticketmatic.CreateTicket{
				Tickettypepriceid: ttps.Prices.Contingents[0].Pricetypes[0].Tickettypepriceid,
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(ticketsadded.Order.Tickets) != 2 {
		t.Errorf("Unexpected ticketsadded.Order.Tickets length, got %#v, expected %#v", len(ticketsadded.Order.Tickets), 2)
	}

	_, err = Confirm(c, order.Orderid)
	if err != nil {
		t.Fatal(err)
	}

	ticketids := []int64{
		ticketsadded.Order.Tickets[0].Id,
	}

	updated2, err := Updatetickets(c, order.Orderid, &ticketmatic.UpdateTickets{
		Operation: "setticketholders",
		Params: map[string]interface{}{
			"ticketholderids": []interface{}{777701},
		},
		Tickets: ticketids,
	})
	if err != nil {
		t.Fatal(err)
	}

	if updated2.Tickets[0].Ticketholderid != 777701 {
		t.Errorf("Unexpected updated2.Tickets[0].Ticketholderid, got %#v, expected %#v", updated2.Tickets[0].Ticketholderid, 777701)
	}

	deleted, err := Deletetickets(c, order.Orderid, &ticketmatic.DeleteTickets{
		Tickets: ticketids,
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(deleted.Tickets) != 1 {
		t.Errorf("Unexpected deleted.Tickets length, got %#v, expected %#v", len(deleted.Tickets), 1)
	}

}
Exemple #26
0
func TestTranslations(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Get(c, 4)
	if err != nil {
		t.Fatal(err)
	}

	if req.Name != "Free ticket" {
		t.Errorf("Unexpected req.Name, got %#v, expected %#v", req.Name, "Free ticket")
	}

	c.Language = "nl"
	req2, err := Get(c, 4)
	if err != nil {
		t.Fatal(err)
	}

	if req2.Name != "Gratis ticket" {
		t.Errorf("Unexpected req2.Name, got %#v, expected %#v", req2.Name, "Gratis ticket")
	}

	updated, err := Update(c, 4, &ticketmatic.PriceType{
		Name: "Vrijkaart",
	})
	if err != nil {
		t.Fatal(err)
	}

	if updated.Name != "Vrijkaart" {
		t.Errorf("Unexpected updated.Name, got %#v, expected %#v", updated.Name, "Vrijkaart")
	}

	c.Language = "en"
	req3, err := Get(c, 4)
	if err != nil {
		t.Fatal(err)
	}

	if req3.Name != "Free ticket" {
		t.Errorf("Unexpected req3.Name, got %#v, expected %#v", req3.Name, "Free ticket")
	}

	c.Language = "nl"
	updated2, err := Update(c, 4, &ticketmatic.PriceType{
		Name: "Gratis ticket",
	})
	if err != nil {
		t.Fatal(err)
	}

	if updated2.Name != "Gratis ticket" {
		t.Errorf("Unexpected updated2.Name, got %#v, expected %#v", updated2.Name, "Gratis ticket")
	}

	translations, err := Translations(c, 4)
	if err != nil {
		t.Fatal(err)
	}

	if translations["nameen"] != "Free ticket" {
		t.Errorf(`Unexpected translations["nameen"], got %#v, expected %#v`, translations["nameen"], "Free ticket")
	}

	if translations["namenl"] != "Gratis ticket" {
		t.Errorf(`Unexpected translations["namenl"], got %#v, expected %#v`, translations["namenl"], "Gratis ticket")
	}

}
Exemple #27
0
func TestCreatedelete(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	req, err := Getlist(c, &ticketmatic.PriceTypeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) <= 0 {
		t.Errorf("Unexpected req.Data length, got %#v, expected greater than %#v", len(req.Data), 0)
	}

	req2, err := Create(c, &ticketmatic.PriceType{
		Typeid: 2301,
		Name:   "test",
	})
	if err != nil {
		t.Fatal(err)
	}

	if req2.Name != "test" {
		t.Errorf("Unexpected req2.Name, got %#v, expected %#v", req2.Name, "test")
	}

	if time.Since(req2.Createdts.Time()) > 24*time.Hour {
		t.Errorf("Unexpected req2.Createdts time, should be recent, got %s", req2.Createdts.Time())
	}

	req3, err := Getlist(c, &ticketmatic.PriceTypeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(req3.Data) <= len(req.Data) {
		t.Errorf("Unexpected req3.Data length, got %#v, expected greater than %#v", len(req3.Data), len(req.Data))
	}

	req4, err := Get(c, req2.Id)
	if err != nil {
		t.Fatal(err)
	}

	if req4.Name != "test" {
		t.Errorf("Unexpected req4.Name, got %#v, expected %#v", req4.Name, "test")
	}

	err = Delete(c, req2.Id)
	if err != nil {
		t.Fatal(err)
	}

	req6, err := Getlist(c, &ticketmatic.PriceTypeQuery{})
	if err != nil {
		t.Fatal(err)
	}

	if len(req.Data) != len(req6.Data) {
		t.Errorf("Unexpected req.Data length, got %#v, expected %#v", len(req.Data), len(req6.Data))
	}

}
Exemple #28
0
func TestLockunlocktickets(t *testing.T) {
	var err error

	accountcode := os.Getenv("TM_TEST_ACCOUNTCODE")
	accesskey := os.Getenv("TM_TEST_ACCESSKEY")
	secretkey := os.Getenv("TM_TEST_SECRETKEY")
	c := ticketmatic.NewClient(accountcode, accesskey, secretkey)

	list, err := Getlist(c, &ticketmatic.EventQuery{
		Filter:  "select id from tm.event where seatingplanid is not null",
		Limit:   1,
		Orderby: "name",
		Output:  "ids",
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(list.Data) <= 0 {
		t.Errorf("Unexpected list.Data length, got %#v, expected greater than %#v", len(list.Data), 0)
	}

	stream, err := Gettickets(c, list.Data[0].Id, &ticketmatic.EventTicketQuery{})
	if err != nil {
		t.Fatal(err)
	}

	tickets := make([]*ticketmatic.EventTicket, 0)
	for {
		n, err := stream.Next()
		if err != nil {
			t.Fatal(err)
		}
		if n == nil {
			break
		}
		tickets = append(tickets, n)
	}

	if len(tickets) <= 0 {
		t.Errorf("Unexpected tickets length, got %#v, expected greater than %#v", len(tickets), 0)
	}

	err = Locktickets(c, list.Data[0].Id, &ticketmatic.EventLockTickets{
		Locktypeid: 1,
		Ticketids: []int64{
			tickets[0].Id,
			tickets[1].Id,
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	err = Unlocktickets(c, list.Data[0].Id, &ticketmatic.EventUnlockTickets{
		Ticketids: []int64{
			tickets[0].Id,
			tickets[1].Id,
		},
	})
	if err != nil {
		t.Fatal(err)
	}

}