本文整理匯總了Golang中github.com/ninnemana/API/models/cart.Customer.Insert方法的典型用法代碼示例。如果您正苦於以下問題:Golang Customer.Insert方法的具體用法?Golang Customer.Insert怎麽用?Golang Customer.Insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ninnemana/API/models/cart.Customer
的用法示例。
在下文中一共展示了Customer.Insert方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddAccount
// Create a customer for a
// given shop.
func AddAccount(w http.ResponseWriter, req *http.Request, params martini.Params, enc encoding.Encoder, shop *cart.Shop) string {
var c cart.Customer
defer req.Body.Close()
data, err := ioutil.ReadAll(req.Body)
if err != nil {
apierror.GenerateError(err.Error(), err, w, req)
return ""
}
if err = json.Unmarshal(data, &c); err != nil {
apierror.GenerateError(err.Error(), err, w, req)
return ""
}
c.ShopId = shop.Id
if err = c.Insert(req.Referer()); err != nil {
apierror.GenerateError(err.Error(), err, w, req)
return ""
}
return encoding.Must(enc.Encode(c))
}
示例2: BenchmarkGetCustomerAddresses
func BenchmarkGetCustomerAddresses(b *testing.B) {
shopID := cart.InsertTestData()
if shopID == nil {
b.Error("failed to create a shop")
b.Fail()
}
val := shopID.Hex()
qs := make(url.Values, 0)
qs.Add("shop", val)
cust := cart.Customer{
ShopId: *shopID,
FirstName: "Alex",
LastName: "Ninneman",
Email: time.Now().Format(time.RFC3339Nano) + "@gmail.com",
Password: "password",
}
if err := cust.Insert("http://www.example.com"); err != nil {
b.Error(err.Error())
b.Fail()
}
(&httprunner.BenchmarkOptions{
Method: "GET",
Route: "/shopify/customers/" + cust.Id.Hex() + "/addresses",
ParameterizedRoute: "/shopify/customers/:id/addresses",
Handler: GetAddresses,
QueryString: &qs,
Runs: b.N,
}).RequestBenchmark()
}