github.com/yaegashi/msgraph.go@v0.1.4/v1.0/ActionCall.go (about)

     1  // Code generated by msgraph.go/gen DO NOT EDIT.
     2  
     3  package msgraph
     4  
     5  import (
     6  	"context"
     7  	"fmt"
     8  	"io/ioutil"
     9  	"net/http"
    10  
    11  	"github.com/yaegashi/msgraph.go/jsonx"
    12  )
    13  
    14  // CallAnswerRequestParameter undocumented
    15  type CallAnswerRequestParameter struct {
    16  	// CallbackURI undocumented
    17  	CallbackURI *string `json:"callbackUri,omitempty"`
    18  	// MediaConfig undocumented
    19  	MediaConfig *MediaConfig `json:"mediaConfig,omitempty"`
    20  	// AcceptedModalities undocumented
    21  	AcceptedModalities []Modality `json:"acceptedModalities,omitempty"`
    22  }
    23  
    24  // CallChangeScreenSharingRoleRequestParameter undocumented
    25  type CallChangeScreenSharingRoleRequestParameter struct {
    26  	// Role undocumented
    27  	Role *ScreenSharingRole `json:"role,omitempty"`
    28  }
    29  
    30  // CallKeepAliveRequestParameter undocumented
    31  type CallKeepAliveRequestParameter struct {
    32  }
    33  
    34  // CallMuteRequestParameter undocumented
    35  type CallMuteRequestParameter struct {
    36  	// ClientContext undocumented
    37  	ClientContext *string `json:"clientContext,omitempty"`
    38  }
    39  
    40  // CallPlayPromptRequestParameter undocumented
    41  type CallPlayPromptRequestParameter struct {
    42  	// Prompts undocumented
    43  	Prompts []Prompt `json:"prompts,omitempty"`
    44  	// ClientContext undocumented
    45  	ClientContext *string `json:"clientContext,omitempty"`
    46  }
    47  
    48  // CallRecordResponseRequestParameter undocumented
    49  type CallRecordResponseRequestParameter struct {
    50  	// Prompts undocumented
    51  	Prompts []Prompt `json:"prompts,omitempty"`
    52  	// BargeInAllowed undocumented
    53  	BargeInAllowed *bool `json:"bargeInAllowed,omitempty"`
    54  	// InitialSilenceTimeoutInSeconds undocumented
    55  	InitialSilenceTimeoutInSeconds *int `json:"initialSilenceTimeoutInSeconds,omitempty"`
    56  	// MaxSilenceTimeoutInSeconds undocumented
    57  	MaxSilenceTimeoutInSeconds *int `json:"maxSilenceTimeoutInSeconds,omitempty"`
    58  	// MaxRecordDurationInSeconds undocumented
    59  	MaxRecordDurationInSeconds *int `json:"maxRecordDurationInSeconds,omitempty"`
    60  	// PlayBeep undocumented
    61  	PlayBeep *bool `json:"playBeep,omitempty"`
    62  	// StopTones undocumented
    63  	StopTones []string `json:"stopTones,omitempty"`
    64  	// ClientContext undocumented
    65  	ClientContext *string `json:"clientContext,omitempty"`
    66  }
    67  
    68  // CallRedirectRequestParameter undocumented
    69  type CallRedirectRequestParameter struct {
    70  	// Targets undocumented
    71  	Targets []InvitationParticipantInfo `json:"targets,omitempty"`
    72  	// Timeout undocumented
    73  	Timeout *int `json:"timeout,omitempty"`
    74  	// CallbackURI undocumented
    75  	CallbackURI *string `json:"callbackUri,omitempty"`
    76  }
    77  
    78  // CallRejectRequestParameter undocumented
    79  type CallRejectRequestParameter struct {
    80  	// Reason undocumented
    81  	Reason *RejectReason `json:"reason,omitempty"`
    82  	// CallbackURI undocumented
    83  	CallbackURI *string `json:"callbackUri,omitempty"`
    84  }
    85  
    86  // CallSubscribeToToneRequestParameter undocumented
    87  type CallSubscribeToToneRequestParameter struct {
    88  	// ClientContext undocumented
    89  	ClientContext *string `json:"clientContext,omitempty"`
    90  }
    91  
    92  // CallTransferRequestParameter undocumented
    93  type CallTransferRequestParameter struct {
    94  	// TransferTarget undocumented
    95  	TransferTarget *InvitationParticipantInfo `json:"transferTarget,omitempty"`
    96  }
    97  
    98  // CallUnmuteRequestParameter undocumented
    99  type CallUnmuteRequestParameter struct {
   100  	// ClientContext undocumented
   101  	ClientContext *string `json:"clientContext,omitempty"`
   102  }
   103  
   104  // Operations returns request builder for CommsOperation collection
   105  func (b *CallRequestBuilder) Operations() *CallOperationsCollectionRequestBuilder {
   106  	bb := &CallOperationsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   107  	bb.baseURL += "/operations"
   108  	return bb
   109  }
   110  
   111  // CallOperationsCollectionRequestBuilder is request builder for CommsOperation collection
   112  type CallOperationsCollectionRequestBuilder struct{ BaseRequestBuilder }
   113  
   114  // Request returns request for CommsOperation collection
   115  func (b *CallOperationsCollectionRequestBuilder) Request() *CallOperationsCollectionRequest {
   116  	return &CallOperationsCollectionRequest{
   117  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   118  	}
   119  }
   120  
   121  // ID returns request builder for CommsOperation item
   122  func (b *CallOperationsCollectionRequestBuilder) ID(id string) *CommsOperationRequestBuilder {
   123  	bb := &CommsOperationRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   124  	bb.baseURL += "/" + id
   125  	return bb
   126  }
   127  
   128  // CallOperationsCollectionRequest is request for CommsOperation collection
   129  type CallOperationsCollectionRequest struct{ BaseRequest }
   130  
   131  // Paging perfoms paging operation for CommsOperation collection
   132  func (r *CallOperationsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]CommsOperation, error) {
   133  	req, err := r.NewJSONRequest(method, path, obj)
   134  	if err != nil {
   135  		return nil, err
   136  	}
   137  	if ctx != nil {
   138  		req = req.WithContext(ctx)
   139  	}
   140  	res, err := r.client.Do(req)
   141  	if err != nil {
   142  		return nil, err
   143  	}
   144  	var values []CommsOperation
   145  	for {
   146  		if res.StatusCode != http.StatusOK {
   147  			b, _ := ioutil.ReadAll(res.Body)
   148  			res.Body.Close()
   149  			errRes := &ErrorResponse{Response: res}
   150  			err := jsonx.Unmarshal(b, errRes)
   151  			if err != nil {
   152  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   153  			}
   154  			return nil, errRes
   155  		}
   156  		var (
   157  			paging Paging
   158  			value  []CommsOperation
   159  		)
   160  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   161  		res.Body.Close()
   162  		if err != nil {
   163  			return nil, err
   164  		}
   165  		err = jsonx.Unmarshal(paging.Value, &value)
   166  		if err != nil {
   167  			return nil, err
   168  		}
   169  		values = append(values, value...)
   170  		if n >= 0 {
   171  			n--
   172  		}
   173  		if n == 0 || len(paging.NextLink) == 0 {
   174  			return values, nil
   175  		}
   176  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   177  		if ctx != nil {
   178  			req = req.WithContext(ctx)
   179  		}
   180  		res, err = r.client.Do(req)
   181  		if err != nil {
   182  			return nil, err
   183  		}
   184  	}
   185  }
   186  
   187  // GetN performs GET request for CommsOperation collection, max N pages
   188  func (r *CallOperationsCollectionRequest) GetN(ctx context.Context, n int) ([]CommsOperation, error) {
   189  	var query string
   190  	if r.query != nil {
   191  		query = "?" + r.query.Encode()
   192  	}
   193  	return r.Paging(ctx, "GET", query, nil, n)
   194  }
   195  
   196  // Get performs GET request for CommsOperation collection
   197  func (r *CallOperationsCollectionRequest) Get(ctx context.Context) ([]CommsOperation, error) {
   198  	return r.GetN(ctx, 0)
   199  }
   200  
   201  // Add performs POST request for CommsOperation collection
   202  func (r *CallOperationsCollectionRequest) Add(ctx context.Context, reqObj *CommsOperation) (resObj *CommsOperation, err error) {
   203  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   204  	return
   205  }
   206  
   207  // Participants returns request builder for Participant collection
   208  func (b *CallRequestBuilder) Participants() *CallParticipantsCollectionRequestBuilder {
   209  	bb := &CallParticipantsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   210  	bb.baseURL += "/participants"
   211  	return bb
   212  }
   213  
   214  // CallParticipantsCollectionRequestBuilder is request builder for Participant collection
   215  type CallParticipantsCollectionRequestBuilder struct{ BaseRequestBuilder }
   216  
   217  // Request returns request for Participant collection
   218  func (b *CallParticipantsCollectionRequestBuilder) Request() *CallParticipantsCollectionRequest {
   219  	return &CallParticipantsCollectionRequest{
   220  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   221  	}
   222  }
   223  
   224  // ID returns request builder for Participant item
   225  func (b *CallParticipantsCollectionRequestBuilder) ID(id string) *ParticipantRequestBuilder {
   226  	bb := &ParticipantRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   227  	bb.baseURL += "/" + id
   228  	return bb
   229  }
   230  
   231  // CallParticipantsCollectionRequest is request for Participant collection
   232  type CallParticipantsCollectionRequest struct{ BaseRequest }
   233  
   234  // Paging perfoms paging operation for Participant collection
   235  func (r *CallParticipantsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]Participant, error) {
   236  	req, err := r.NewJSONRequest(method, path, obj)
   237  	if err != nil {
   238  		return nil, err
   239  	}
   240  	if ctx != nil {
   241  		req = req.WithContext(ctx)
   242  	}
   243  	res, err := r.client.Do(req)
   244  	if err != nil {
   245  		return nil, err
   246  	}
   247  	var values []Participant
   248  	for {
   249  		if res.StatusCode != http.StatusOK {
   250  			b, _ := ioutil.ReadAll(res.Body)
   251  			res.Body.Close()
   252  			errRes := &ErrorResponse{Response: res}
   253  			err := jsonx.Unmarshal(b, errRes)
   254  			if err != nil {
   255  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   256  			}
   257  			return nil, errRes
   258  		}
   259  		var (
   260  			paging Paging
   261  			value  []Participant
   262  		)
   263  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   264  		res.Body.Close()
   265  		if err != nil {
   266  			return nil, err
   267  		}
   268  		err = jsonx.Unmarshal(paging.Value, &value)
   269  		if err != nil {
   270  			return nil, err
   271  		}
   272  		values = append(values, value...)
   273  		if n >= 0 {
   274  			n--
   275  		}
   276  		if n == 0 || len(paging.NextLink) == 0 {
   277  			return values, nil
   278  		}
   279  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   280  		if ctx != nil {
   281  			req = req.WithContext(ctx)
   282  		}
   283  		res, err = r.client.Do(req)
   284  		if err != nil {
   285  			return nil, err
   286  		}
   287  	}
   288  }
   289  
   290  // GetN performs GET request for Participant collection, max N pages
   291  func (r *CallParticipantsCollectionRequest) GetN(ctx context.Context, n int) ([]Participant, error) {
   292  	var query string
   293  	if r.query != nil {
   294  		query = "?" + r.query.Encode()
   295  	}
   296  	return r.Paging(ctx, "GET", query, nil, n)
   297  }
   298  
   299  // Get performs GET request for Participant collection
   300  func (r *CallParticipantsCollectionRequest) Get(ctx context.Context) ([]Participant, error) {
   301  	return r.GetN(ctx, 0)
   302  }
   303  
   304  // Add performs POST request for Participant collection
   305  func (r *CallParticipantsCollectionRequest) Add(ctx context.Context, reqObj *Participant) (resObj *Participant, err error) {
   306  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   307  	return
   308  }