当前位置: 首页>>代码示例>>Golang>>正文


Golang ticketmatic.NewClient函数代码示例

本文整理汇总了Golang中github.com/ticketmatic/tm-go/ticketmatic.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestGettickets

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:35,代码来源:operations_test.go

示例2: TestGet

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:25,代码来源:operations_test.go

示例3: TestCreatecodes

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:25,代码来源:operations_test.go

示例4: TestGet

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:32,代码来源:operations_test.go

示例5: TestExport

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:32,代码来源:operations_test.go

示例6: TestCreatequeued

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:32,代码来源:operations_test.go

示例7: TestGet

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))
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:29,代码来源:operations_test.go

示例8: TestArchived

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))
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:60,代码来源:operations_test.go

示例9: TestCreate

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:29,代码来源:operations_test.go

示例10: TestAddticketsqueued

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:57,代码来源:operations_test.go

示例11: TestCreateunicode

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:51,代码来源:operations_test.go

示例12: TestDeletefixedbundleevent

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!")
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:15,代码来源:operations_test.go

示例13: TestCreate

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")
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:47,代码来源:operations_test.go

示例14: TestCreate

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)
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:45,代码来源:operations_test.go

示例15: TestGetTime

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())
	}

}
开发者ID:ticketmatic,项目名称:tm-go,代码行数:18,代码来源:operations_test.go


注:本文中的github.com/ticketmatic/tm-go/ticketmatic.NewClient函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。