func (subscription *Subscription) Update(metadata map[string]interface{}) (*SubscriptionInfo, error) {
	client := NewHTTPClient(subscription.client)
	body, err := json.Marshal(metadata)
	if err != nil {
		return nil, err
	}
	conf := patchConfigHeaders(subscription.config, map[string]string{
		"Content-Type": "application/json",
	})
	if _, err := client.Update(subscription.endpoint, bytes.NewBuffer(body), conf); err != nil {
		return nil, err
	}
	return subscription.Get()
}
Update updates a subscription
package api
import (
	"bytes"
	"encoding/json"
	"fmt"
	"time"
	"github.com/koltyakov/gosip"
)
type Subscriptions struct {
	client   *gosip.SPClient
	config   *RequestConfig
	endpoint string
}
type Subscription struct {
	client   *gosip.SPClient
	config   *RequestConfig
	endpoint string
}
type SubscriptionInfo struct {
	ID string `json:"id"`
	NotificationURL string `json:"notificationUrl"`
	ExpirationDateTime time.Time `json:"expirationDateTime"`
	Resource string `json:"resource"`
	ClientState  string `json:"clientState"`
	ResourceData string `json:"resourceData"`
}
func NewSubscriptions(client *gosip.SPClient, endpoint string, config *RequestConfig) *Subscriptions {
	return &Subscriptions{
		client:   client,
		endpoint: endpoint,
		config:   config,
	}
}
func NewSubscription(client *gosip.SPClient, endpoint string, config *RequestConfig) *Subscription {
	return &Subscription{
		client:   client,
		endpoint: endpoint,
		config:   config,
	}
}
func (subscriptions *Subscriptions) Get() ([]*SubscriptionInfo, error) {
	client := NewHTTPClient(subscriptions.client)
	resp, err := client.Get(subscriptions.endpoint, subscriptions.config)
	if err != nil {
		return nil, err
	}
	data, _ := NormalizeODataCollection(resp)
	var subs []*SubscriptionInfo
	if err := json.Unmarshal(data, &subs); err != nil {
		return nil, err
	}
	return subs, nil
}
func (subscriptions *Subscriptions) GetByID(subscriptionID string) *Subscription {
	return NewSubscription(
		subscriptions.client,
		fmt.Sprintf("%s('%s')", subscriptions.endpoint, subscriptionID),
		subscriptions.config,
	)
}
func (subscriptions *Subscriptions) Add(notificationURL string, expiration time.Time, clientState string) (*SubscriptionInfo, error) {
	client := NewHTTPClient(subscriptions.client)
	payload := map[string]interface{}{
		"notificationUrl":    notificationURL,
		"expirationDateTime": expiration,
		"resource":           getPriorEndpoint(subscriptions.endpoint, "/subscriptions"),
		"clientState":        clientState,
	}
	body, err := json.Marshal(payload)
	if err != nil {
		return nil, err
	}
	conf := patchConfigHeaders(subscriptions.config, map[string]string{
		"Content-Type": "application/json",
	})
	resp, err := client.Post(subscriptions.endpoint, bytes.NewBuffer(body), conf)
	if err != nil {
		return nil, err
	}
	data := NormalizeODataItem(resp)
	var sub *SubscriptionInfo
	if err := json.Unmarshal(data, &sub); err != nil {
		return nil, err
	}
	return sub, nil
}
func (subscription *Subscription) Get() (*SubscriptionInfo, error) {
	client := NewHTTPClient(subscription.client)
	resp, err := client.Get(subscription.endpoint, subscription.config)
	if err != nil {
		return nil, err
	}
	return subscription.parseResponse(resp)
}
func (subscription *Subscription) Delete() error {
	client := NewHTTPClient(subscription.client)
	_, err := client.Delete(subscription.endpoint, subscription.config)
	return err
}