本文整理汇总了Golang中github.com/soundtrackyourbrand/utils/key.Key.Encode方法的典型用法代码示例。如果您正苦于以下问题:Golang Key.Encode方法的具体用法?Golang Key.Encode怎么用?Golang Key.Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/soundtrackyourbrand/utils/key.Key
的用法示例。
在下文中一共展示了Key.Encode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateDoc
func UpdateDoc(c ElasticConnector, index string, id key.Key, groovyCode string, params map[string]interface{}) (err error) {
index = processIndexName(index)
url := fmt.Sprintf("%s/%s/%s/%s/_update?retry_on_conflict=%v",
c.GetElasticService(),
index,
id.Kind(),
id.Encode(),
UpdateConflictRetries)
json, err := json.Marshal(UpdateRequest{
Script: groovyCode,
Params: params,
})
if err != nil {
return
}
request, err := http.NewRequest("POST", url, bytes.NewBuffer(json))
if err != nil {
return
}
if c.GetElasticUsername() != "" {
request.SetBasicAuth(c.GetElasticUsername(), c.GetElasticPassword())
}
response, err := c.Client().Do(request)
if err != nil {
return
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(response.Body)
err = errors.Errorf("Bad status code from elasticsearch %v: %v, %v", url, response.Status, string(body))
return
}
return
}
示例2: DeactivateSpotifyAccount
func DeactivateSpotifyAccount(c ServiceConnector, soundZone key.Key, token AccessToken) (err error) {
request, response, err := DoRequest(c, "POST", c.GetPaymentService(), fmt.Sprintf("sound_zones/%v/spotify_account/deactivate", soundZone.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
示例3: GetSpotifyAccounts
func GetSpotifyAccounts(c ServiceConnector, account key.Key, token AccessToken) (result RemoteSpotifyAccounts, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("accounts/%v/payment_method/spotify_accounts", account.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = RemoteSpotifyAccounts{}
err = json.NewDecoder(response.Body).Decode(&result)
return
}
示例4: GetSpotifyAccount
func GetSpotifyAccount(c ServiceConnector, soundZone key.Key, token AccessToken) (result *RemoteSpotifyAccount, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("sound_zones/%v/spotify_account", soundZone.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteSpotifyAccount{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
示例5: GetSoundZones
func GetSoundZones(c ServiceConnector, account_id key.Key, token AccessToken) (result RemoteSoundZones, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("accounts/%v/sound_zones", account_id.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = RemoteSoundZones{}
err = json.NewDecoder(response.Body).Decode(&result)
return
}
示例6: CreateBusinessAccount
func CreateBusinessAccount(c ServiceConnector, token AccessToken, account RemoteAccount, owner key.Key) (result *RemoteAccount, err error) {
request, response, err := DoRequest(c, "POST", c.GetAuthService(), fmt.Sprintf("users/%v/accounts/business", owner.Encode()), token, account)
if err != nil {
return
}
if response.StatusCode != 201 {
err = errorFor(request, response)
return
}
result = &RemoteAccount{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
示例7: CountSoundZonesForSchedule
func CountSoundZonesForSchedule(c ServiceConnector, schedule key.Key, token AccessToken) (result int, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("schedules/%v/sound_zone_count", schedule.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
container := &CountContainer{}
if err = json.NewDecoder(response.Body).Decode(container); err != nil {
return
}
result = container.Count
return
}
示例8: GetProductQueue
func GetProductQueue(c ServiceConnector, productQueueId key.Key, token AccessToken) (result *RemoteProductQueue, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("product_queues/%v", productQueueId.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteProductQueue{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
示例9: DeactivatePaymentMethodAsync
func DeactivatePaymentMethodAsync(c ServiceConnector, accountId key.Key, token AccessToken) (err error) {
request, response, err := DoRequest(c, "POST", c.GetPaymentService(), fmt.Sprintf("accounts/%v/payment_method/deactivate_async", accountId.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
示例10: UpdatePaymentMethodByAccountId
func UpdatePaymentMethodByAccountId(c ServiceConnector, account key.Key, paymentMethod RemotePaymentMethod, token AccessToken) (err error) {
request, response, err := DoRequest(c, "PUT", c.GetPaymentService(), fmt.Sprintf("accounts/%v/payment_method", account.Encode()), token, paymentMethod)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}
示例11: GetBillingGroupsByAccountId
func GetBillingGroupsByAccountId(c ServiceConnector, account key.Key, token AccessToken) (result RemoteBillingGroups, err error) {
request, response, err := DoRequest(c, "GET", c.GetPaymentService(), fmt.Sprintf("accounts/%v/billing_groups", account.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = RemoteBillingGroups{}
err = json.NewDecoder(response.Body).Decode(&result)
return
}
示例12: CreateSoundZoneError
func CreateSoundZoneError(c ServiceConnector, token AccessToken, e RemoteSoundZoneError, soundZoneId key.Key) (result *RemoteSoundZoneError, err error) {
request, response, err := DoRequest(c, "POST", c.GetAuthService(), fmt.Sprintf("sound_zones/%v/sound_zone_errors", soundZoneId.Encode()), token, e)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteSoundZoneError{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
示例13: GetAccountContact
func GetAccountContact(c ServiceConnector, account key.Key, token AccessToken) (result *RemoteUser, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("accounts/%v/contact", account.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteUser{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
示例14: GetLocation
func GetLocation(c ServiceConnector, location key.Key, token AccessToken) (result *RemoteLocation, err error) {
request, response, err := DoRequest(c, "GET", c.GetAuthService(), fmt.Sprintf("locations/%v", location.Encode()), token, nil)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
result = &RemoteLocation{}
err = json.NewDecoder(response.Body).Decode(result)
return
}
示例15: ReplaceScheduleForSoundZones
func ReplaceScheduleForSoundZones(c ServiceConnector, oldSchedule, newSchedule key.Key, token AccessToken) (err error) {
scheduleRef := &ScheduleRef{
Schedule: newSchedule,
}
request, response, err := DoRequest(c, "PUT", c.GetAuthService(), fmt.Sprintf("schedules/%v/sound_zones", oldSchedule.Encode()), token, scheduleRef)
if err != nil {
return
}
if response.StatusCode != 200 {
err = errorFor(request, response)
return
}
return
}