mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-11 11:42:00 -08:00
516 lines
18 KiB
Go
516 lines
18 KiB
Go
|
// Code generated by msgraph-generate.go DO NOT EDIT.
|
||
|
|
||
|
package msgraph
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"io/ioutil"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/yaegashi/msgraph.go/jsonx"
|
||
|
)
|
||
|
|
||
|
// ApprovalWorkflowProviderRequestBuilder is request builder for ApprovalWorkflowProvider
|
||
|
type ApprovalWorkflowProviderRequestBuilder struct{ BaseRequestBuilder }
|
||
|
|
||
|
// Request returns ApprovalWorkflowProviderRequest
|
||
|
func (b *ApprovalWorkflowProviderRequestBuilder) Request() *ApprovalWorkflowProviderRequest {
|
||
|
return &ApprovalWorkflowProviderRequest{
|
||
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderRequest is request for ApprovalWorkflowProvider
|
||
|
type ApprovalWorkflowProviderRequest struct{ BaseRequest }
|
||
|
|
||
|
// Get performs GET request for ApprovalWorkflowProvider
|
||
|
func (r *ApprovalWorkflowProviderRequest) Get(ctx context.Context) (resObj *ApprovalWorkflowProvider, err error) {
|
||
|
var query string
|
||
|
if r.query != nil {
|
||
|
query = "?" + r.query.Encode()
|
||
|
}
|
||
|
err = r.JSONRequest(ctx, "GET", query, nil, &resObj)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Update performs PATCH request for ApprovalWorkflowProvider
|
||
|
func (r *ApprovalWorkflowProviderRequest) Update(ctx context.Context, reqObj *ApprovalWorkflowProvider) error {
|
||
|
return r.JSONRequest(ctx, "PATCH", "", reqObj, nil)
|
||
|
}
|
||
|
|
||
|
// Delete performs DELETE request for ApprovalWorkflowProvider
|
||
|
func (r *ApprovalWorkflowProviderRequest) Delete(ctx context.Context) error {
|
||
|
return r.JSONRequest(ctx, "DELETE", "", nil, nil)
|
||
|
}
|
||
|
|
||
|
// BusinessFlows returns request builder for BusinessFlow collection
|
||
|
func (b *ApprovalWorkflowProviderRequestBuilder) BusinessFlows() *ApprovalWorkflowProviderBusinessFlowsCollectionRequestBuilder {
|
||
|
bb := &ApprovalWorkflowProviderBusinessFlowsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/businessFlows"
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderBusinessFlowsCollectionRequestBuilder is request builder for BusinessFlow collection
|
||
|
type ApprovalWorkflowProviderBusinessFlowsCollectionRequestBuilder struct{ BaseRequestBuilder }
|
||
|
|
||
|
// Request returns request for BusinessFlow collection
|
||
|
func (b *ApprovalWorkflowProviderBusinessFlowsCollectionRequestBuilder) Request() *ApprovalWorkflowProviderBusinessFlowsCollectionRequest {
|
||
|
return &ApprovalWorkflowProviderBusinessFlowsCollectionRequest{
|
||
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ID returns request builder for BusinessFlow item
|
||
|
func (b *ApprovalWorkflowProviderBusinessFlowsCollectionRequestBuilder) ID(id string) *BusinessFlowRequestBuilder {
|
||
|
bb := &BusinessFlowRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/" + id
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderBusinessFlowsCollectionRequest is request for BusinessFlow collection
|
||
|
type ApprovalWorkflowProviderBusinessFlowsCollectionRequest struct{ BaseRequest }
|
||
|
|
||
|
// Paging perfoms paging operation for BusinessFlow collection
|
||
|
func (r *ApprovalWorkflowProviderBusinessFlowsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]BusinessFlow, error) {
|
||
|
req, err := r.NewJSONRequest(method, path, obj)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err := r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var values []BusinessFlow
|
||
|
for {
|
||
|
defer res.Body.Close()
|
||
|
if res.StatusCode != http.StatusOK {
|
||
|
b, _ := ioutil.ReadAll(res.Body)
|
||
|
errRes := &ErrorResponse{Response: res}
|
||
|
err := jsonx.Unmarshal(b, errRes)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
|
||
|
}
|
||
|
return nil, errRes
|
||
|
}
|
||
|
var (
|
||
|
paging Paging
|
||
|
value []BusinessFlow
|
||
|
)
|
||
|
err := jsonx.NewDecoder(res.Body).Decode(&paging)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = jsonx.Unmarshal(paging.Value, &value)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
values = append(values, value...)
|
||
|
if len(paging.NextLink) == 0 {
|
||
|
return values, nil
|
||
|
}
|
||
|
req, err = http.NewRequest("GET", paging.NextLink, nil)
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err = r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Get performs GET request for BusinessFlow collection
|
||
|
func (r *ApprovalWorkflowProviderBusinessFlowsCollectionRequest) Get(ctx context.Context) ([]BusinessFlow, error) {
|
||
|
var query string
|
||
|
if r.query != nil {
|
||
|
query = "?" + r.query.Encode()
|
||
|
}
|
||
|
return r.Paging(ctx, "GET", query, nil)
|
||
|
}
|
||
|
|
||
|
// Add performs POST request for BusinessFlow collection
|
||
|
func (r *ApprovalWorkflowProviderBusinessFlowsCollectionRequest) Add(ctx context.Context, reqObj *BusinessFlow) (resObj *BusinessFlow, err error) {
|
||
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// BusinessFlowsWithRequestsAwaitingMyDecision returns request builder for BusinessFlow collection
|
||
|
func (b *ApprovalWorkflowProviderRequestBuilder) BusinessFlowsWithRequestsAwaitingMyDecision() *ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequestBuilder {
|
||
|
bb := &ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/businessFlowsWithRequestsAwaitingMyDecision"
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequestBuilder is request builder for BusinessFlow collection
|
||
|
type ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequestBuilder struct{ BaseRequestBuilder }
|
||
|
|
||
|
// Request returns request for BusinessFlow collection
|
||
|
func (b *ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequestBuilder) Request() *ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequest {
|
||
|
return &ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequest{
|
||
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ID returns request builder for BusinessFlow item
|
||
|
func (b *ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequestBuilder) ID(id string) *BusinessFlowRequestBuilder {
|
||
|
bb := &BusinessFlowRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/" + id
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequest is request for BusinessFlow collection
|
||
|
type ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequest struct{ BaseRequest }
|
||
|
|
||
|
// Paging perfoms paging operation for BusinessFlow collection
|
||
|
func (r *ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]BusinessFlow, error) {
|
||
|
req, err := r.NewJSONRequest(method, path, obj)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err := r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var values []BusinessFlow
|
||
|
for {
|
||
|
defer res.Body.Close()
|
||
|
if res.StatusCode != http.StatusOK {
|
||
|
b, _ := ioutil.ReadAll(res.Body)
|
||
|
errRes := &ErrorResponse{Response: res}
|
||
|
err := jsonx.Unmarshal(b, errRes)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
|
||
|
}
|
||
|
return nil, errRes
|
||
|
}
|
||
|
var (
|
||
|
paging Paging
|
||
|
value []BusinessFlow
|
||
|
)
|
||
|
err := jsonx.NewDecoder(res.Body).Decode(&paging)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = jsonx.Unmarshal(paging.Value, &value)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
values = append(values, value...)
|
||
|
if len(paging.NextLink) == 0 {
|
||
|
return values, nil
|
||
|
}
|
||
|
req, err = http.NewRequest("GET", paging.NextLink, nil)
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err = r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Get performs GET request for BusinessFlow collection
|
||
|
func (r *ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequest) Get(ctx context.Context) ([]BusinessFlow, error) {
|
||
|
var query string
|
||
|
if r.query != nil {
|
||
|
query = "?" + r.query.Encode()
|
||
|
}
|
||
|
return r.Paging(ctx, "GET", query, nil)
|
||
|
}
|
||
|
|
||
|
// Add performs POST request for BusinessFlow collection
|
||
|
func (r *ApprovalWorkflowProviderBusinessFlowsWithRequestsAwaitingMyDecisionCollectionRequest) Add(ctx context.Context, reqObj *BusinessFlow) (resObj *BusinessFlow, err error) {
|
||
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// PolicyTemplates returns request builder for GovernancePolicyTemplate collection
|
||
|
func (b *ApprovalWorkflowProviderRequestBuilder) PolicyTemplates() *ApprovalWorkflowProviderPolicyTemplatesCollectionRequestBuilder {
|
||
|
bb := &ApprovalWorkflowProviderPolicyTemplatesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/policyTemplates"
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderPolicyTemplatesCollectionRequestBuilder is request builder for GovernancePolicyTemplate collection
|
||
|
type ApprovalWorkflowProviderPolicyTemplatesCollectionRequestBuilder struct{ BaseRequestBuilder }
|
||
|
|
||
|
// Request returns request for GovernancePolicyTemplate collection
|
||
|
func (b *ApprovalWorkflowProviderPolicyTemplatesCollectionRequestBuilder) Request() *ApprovalWorkflowProviderPolicyTemplatesCollectionRequest {
|
||
|
return &ApprovalWorkflowProviderPolicyTemplatesCollectionRequest{
|
||
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ID returns request builder for GovernancePolicyTemplate item
|
||
|
func (b *ApprovalWorkflowProviderPolicyTemplatesCollectionRequestBuilder) ID(id string) *GovernancePolicyTemplateRequestBuilder {
|
||
|
bb := &GovernancePolicyTemplateRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/" + id
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderPolicyTemplatesCollectionRequest is request for GovernancePolicyTemplate collection
|
||
|
type ApprovalWorkflowProviderPolicyTemplatesCollectionRequest struct{ BaseRequest }
|
||
|
|
||
|
// Paging perfoms paging operation for GovernancePolicyTemplate collection
|
||
|
func (r *ApprovalWorkflowProviderPolicyTemplatesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]GovernancePolicyTemplate, error) {
|
||
|
req, err := r.NewJSONRequest(method, path, obj)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err := r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var values []GovernancePolicyTemplate
|
||
|
for {
|
||
|
defer res.Body.Close()
|
||
|
if res.StatusCode != http.StatusOK {
|
||
|
b, _ := ioutil.ReadAll(res.Body)
|
||
|
errRes := &ErrorResponse{Response: res}
|
||
|
err := jsonx.Unmarshal(b, errRes)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
|
||
|
}
|
||
|
return nil, errRes
|
||
|
}
|
||
|
var (
|
||
|
paging Paging
|
||
|
value []GovernancePolicyTemplate
|
||
|
)
|
||
|
err := jsonx.NewDecoder(res.Body).Decode(&paging)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = jsonx.Unmarshal(paging.Value, &value)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
values = append(values, value...)
|
||
|
if len(paging.NextLink) == 0 {
|
||
|
return values, nil
|
||
|
}
|
||
|
req, err = http.NewRequest("GET", paging.NextLink, nil)
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err = r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Get performs GET request for GovernancePolicyTemplate collection
|
||
|
func (r *ApprovalWorkflowProviderPolicyTemplatesCollectionRequest) Get(ctx context.Context) ([]GovernancePolicyTemplate, error) {
|
||
|
var query string
|
||
|
if r.query != nil {
|
||
|
query = "?" + r.query.Encode()
|
||
|
}
|
||
|
return r.Paging(ctx, "GET", query, nil)
|
||
|
}
|
||
|
|
||
|
// Add performs POST request for GovernancePolicyTemplate collection
|
||
|
func (r *ApprovalWorkflowProviderPolicyTemplatesCollectionRequest) Add(ctx context.Context, reqObj *GovernancePolicyTemplate) (resObj *GovernancePolicyTemplate, err error) {
|
||
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Requests returns request builder for RequestObject collection
|
||
|
func (b *ApprovalWorkflowProviderRequestBuilder) Requests() *ApprovalWorkflowProviderRequestsCollectionRequestBuilder {
|
||
|
bb := &ApprovalWorkflowProviderRequestsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/requests"
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderRequestsCollectionRequestBuilder is request builder for RequestObject collection
|
||
|
type ApprovalWorkflowProviderRequestsCollectionRequestBuilder struct{ BaseRequestBuilder }
|
||
|
|
||
|
// Request returns request for RequestObject collection
|
||
|
func (b *ApprovalWorkflowProviderRequestsCollectionRequestBuilder) Request() *ApprovalWorkflowProviderRequestsCollectionRequest {
|
||
|
return &ApprovalWorkflowProviderRequestsCollectionRequest{
|
||
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ID returns request builder for RequestObject item
|
||
|
func (b *ApprovalWorkflowProviderRequestsCollectionRequestBuilder) ID(id string) *RequestObjectRequestBuilder {
|
||
|
bb := &RequestObjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/" + id
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderRequestsCollectionRequest is request for RequestObject collection
|
||
|
type ApprovalWorkflowProviderRequestsCollectionRequest struct{ BaseRequest }
|
||
|
|
||
|
// Paging perfoms paging operation for RequestObject collection
|
||
|
func (r *ApprovalWorkflowProviderRequestsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]RequestObject, error) {
|
||
|
req, err := r.NewJSONRequest(method, path, obj)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err := r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var values []RequestObject
|
||
|
for {
|
||
|
defer res.Body.Close()
|
||
|
if res.StatusCode != http.StatusOK {
|
||
|
b, _ := ioutil.ReadAll(res.Body)
|
||
|
errRes := &ErrorResponse{Response: res}
|
||
|
err := jsonx.Unmarshal(b, errRes)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
|
||
|
}
|
||
|
return nil, errRes
|
||
|
}
|
||
|
var (
|
||
|
paging Paging
|
||
|
value []RequestObject
|
||
|
)
|
||
|
err := jsonx.NewDecoder(res.Body).Decode(&paging)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = jsonx.Unmarshal(paging.Value, &value)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
values = append(values, value...)
|
||
|
if len(paging.NextLink) == 0 {
|
||
|
return values, nil
|
||
|
}
|
||
|
req, err = http.NewRequest("GET", paging.NextLink, nil)
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err = r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Get performs GET request for RequestObject collection
|
||
|
func (r *ApprovalWorkflowProviderRequestsCollectionRequest) Get(ctx context.Context) ([]RequestObject, error) {
|
||
|
var query string
|
||
|
if r.query != nil {
|
||
|
query = "?" + r.query.Encode()
|
||
|
}
|
||
|
return r.Paging(ctx, "GET", query, nil)
|
||
|
}
|
||
|
|
||
|
// Add performs POST request for RequestObject collection
|
||
|
func (r *ApprovalWorkflowProviderRequestsCollectionRequest) Add(ctx context.Context, reqObj *RequestObject) (resObj *RequestObject, err error) {
|
||
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// RequestsAwaitingMyDecision returns request builder for RequestObject collection
|
||
|
func (b *ApprovalWorkflowProviderRequestBuilder) RequestsAwaitingMyDecision() *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequestBuilder {
|
||
|
bb := &ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/requestsAwaitingMyDecision"
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequestBuilder is request builder for RequestObject collection
|
||
|
type ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequestBuilder struct{ BaseRequestBuilder }
|
||
|
|
||
|
// Request returns request for RequestObject collection
|
||
|
func (b *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequestBuilder) Request() *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest {
|
||
|
return &ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest{
|
||
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ID returns request builder for RequestObject item
|
||
|
func (b *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequestBuilder) ID(id string) *RequestObjectRequestBuilder {
|
||
|
bb := &RequestObjectRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
||
|
bb.baseURL += "/" + id
|
||
|
return bb
|
||
|
}
|
||
|
|
||
|
// ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest is request for RequestObject collection
|
||
|
type ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest struct{ BaseRequest }
|
||
|
|
||
|
// Paging perfoms paging operation for RequestObject collection
|
||
|
func (r *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}) ([]RequestObject, error) {
|
||
|
req, err := r.NewJSONRequest(method, path, obj)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err := r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var values []RequestObject
|
||
|
for {
|
||
|
defer res.Body.Close()
|
||
|
if res.StatusCode != http.StatusOK {
|
||
|
b, _ := ioutil.ReadAll(res.Body)
|
||
|
errRes := &ErrorResponse{Response: res}
|
||
|
err := jsonx.Unmarshal(b, errRes)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("%s: %s", res.Status, string(b))
|
||
|
}
|
||
|
return nil, errRes
|
||
|
}
|
||
|
var (
|
||
|
paging Paging
|
||
|
value []RequestObject
|
||
|
)
|
||
|
err := jsonx.NewDecoder(res.Body).Decode(&paging)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = jsonx.Unmarshal(paging.Value, &value)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
values = append(values, value...)
|
||
|
if len(paging.NextLink) == 0 {
|
||
|
return values, nil
|
||
|
}
|
||
|
req, err = http.NewRequest("GET", paging.NextLink, nil)
|
||
|
if ctx != nil {
|
||
|
req = req.WithContext(ctx)
|
||
|
}
|
||
|
res, err = r.client.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Get performs GET request for RequestObject collection
|
||
|
func (r *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest) Get(ctx context.Context) ([]RequestObject, error) {
|
||
|
var query string
|
||
|
if r.query != nil {
|
||
|
query = "?" + r.query.Encode()
|
||
|
}
|
||
|
return r.Paging(ctx, "GET", query, nil)
|
||
|
}
|
||
|
|
||
|
// Add performs POST request for RequestObject collection
|
||
|
func (r *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest) Add(ctx context.Context, reqObj *RequestObject) (resObj *RequestObject, err error) {
|
||
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
||
|
return
|
||
|
}
|