Updates to /graph/betasdk/beta_service.go
Addition of constructor and serialize function.
This commit is contained in:
parent
97c6d631b5
commit
de5bc553d0
@ -1,7 +1,9 @@
|
||||
package betasdk
|
||||
|
||||
import (
|
||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Service wraps BetaClient's functionality.
|
||||
@ -18,3 +20,25 @@ func (s Service) Adapter() *msgraphsdk.GraphRequestAdapter {
|
||||
func (s Service) Client() *BetaClient {
|
||||
return s.client
|
||||
}
|
||||
|
||||
func NewService(adpt *msgraphsdk.GraphRequestAdapter) *Service {
|
||||
return &Service{
|
||||
client: NewBetaClient(adpt),
|
||||
}
|
||||
}
|
||||
|
||||
// Seraialize writes an M365 parsable object into a byte array using the built-in
|
||||
// application/json writer within the adapter.
|
||||
func (s Service) Serialize(object absser.Parsable) ([]byte, error) {
|
||||
writer, err := s.Adapter().GetSerializationWriterFactory().GetSerializationWriter("application/json")
|
||||
if err != nil || writer == nil {
|
||||
return nil, errors.Wrap(err, "creating json serialization writer")
|
||||
}
|
||||
|
||||
err = writer.WriteObjectValue("", object)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "writeObjecValue serialization")
|
||||
}
|
||||
|
||||
return writer.GetSerializedContent()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user