github.com/yaegashi/msgraph.go@v0.1.4/beta/ActionBooking.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  // BookingAppointmentCancelRequestParameter undocumented
    15  type BookingAppointmentCancelRequestParameter struct {
    16  	// CancellationMessage undocumented
    17  	CancellationMessage *string `json:"cancellationMessage,omitempty"`
    18  }
    19  
    20  // BookingBusinessPublishRequestParameter undocumented
    21  type BookingBusinessPublishRequestParameter struct {
    22  }
    23  
    24  // BookingBusinessUnpublishRequestParameter undocumented
    25  type BookingBusinessUnpublishRequestParameter struct {
    26  }
    27  
    28  // Appointments returns request builder for BookingAppointment collection
    29  func (b *BookingBusinessRequestBuilder) Appointments() *BookingBusinessAppointmentsCollectionRequestBuilder {
    30  	bb := &BookingBusinessAppointmentsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    31  	bb.baseURL += "/appointments"
    32  	return bb
    33  }
    34  
    35  // BookingBusinessAppointmentsCollectionRequestBuilder is request builder for BookingAppointment collection
    36  type BookingBusinessAppointmentsCollectionRequestBuilder struct{ BaseRequestBuilder }
    37  
    38  // Request returns request for BookingAppointment collection
    39  func (b *BookingBusinessAppointmentsCollectionRequestBuilder) Request() *BookingBusinessAppointmentsCollectionRequest {
    40  	return &BookingBusinessAppointmentsCollectionRequest{
    41  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
    42  	}
    43  }
    44  
    45  // ID returns request builder for BookingAppointment item
    46  func (b *BookingBusinessAppointmentsCollectionRequestBuilder) ID(id string) *BookingAppointmentRequestBuilder {
    47  	bb := &BookingAppointmentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
    48  	bb.baseURL += "/" + id
    49  	return bb
    50  }
    51  
    52  // BookingBusinessAppointmentsCollectionRequest is request for BookingAppointment collection
    53  type BookingBusinessAppointmentsCollectionRequest struct{ BaseRequest }
    54  
    55  // Paging perfoms paging operation for BookingAppointment collection
    56  func (r *BookingBusinessAppointmentsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingAppointment, error) {
    57  	req, err := r.NewJSONRequest(method, path, obj)
    58  	if err != nil {
    59  		return nil, err
    60  	}
    61  	if ctx != nil {
    62  		req = req.WithContext(ctx)
    63  	}
    64  	res, err := r.client.Do(req)
    65  	if err != nil {
    66  		return nil, err
    67  	}
    68  	var values []BookingAppointment
    69  	for {
    70  		if res.StatusCode != http.StatusOK {
    71  			b, _ := ioutil.ReadAll(res.Body)
    72  			res.Body.Close()
    73  			errRes := &ErrorResponse{Response: res}
    74  			err := jsonx.Unmarshal(b, errRes)
    75  			if err != nil {
    76  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
    77  			}
    78  			return nil, errRes
    79  		}
    80  		var (
    81  			paging Paging
    82  			value  []BookingAppointment
    83  		)
    84  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
    85  		res.Body.Close()
    86  		if err != nil {
    87  			return nil, err
    88  		}
    89  		err = jsonx.Unmarshal(paging.Value, &value)
    90  		if err != nil {
    91  			return nil, err
    92  		}
    93  		values = append(values, value...)
    94  		if n >= 0 {
    95  			n--
    96  		}
    97  		if n == 0 || len(paging.NextLink) == 0 {
    98  			return values, nil
    99  		}
   100  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   101  		if ctx != nil {
   102  			req = req.WithContext(ctx)
   103  		}
   104  		res, err = r.client.Do(req)
   105  		if err != nil {
   106  			return nil, err
   107  		}
   108  	}
   109  }
   110  
   111  // GetN performs GET request for BookingAppointment collection, max N pages
   112  func (r *BookingBusinessAppointmentsCollectionRequest) GetN(ctx context.Context, n int) ([]BookingAppointment, error) {
   113  	var query string
   114  	if r.query != nil {
   115  		query = "?" + r.query.Encode()
   116  	}
   117  	return r.Paging(ctx, "GET", query, nil, n)
   118  }
   119  
   120  // Get performs GET request for BookingAppointment collection
   121  func (r *BookingBusinessAppointmentsCollectionRequest) Get(ctx context.Context) ([]BookingAppointment, error) {
   122  	return r.GetN(ctx, 0)
   123  }
   124  
   125  // Add performs POST request for BookingAppointment collection
   126  func (r *BookingBusinessAppointmentsCollectionRequest) Add(ctx context.Context, reqObj *BookingAppointment) (resObj *BookingAppointment, err error) {
   127  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   128  	return
   129  }
   130  
   131  // CalendarView returns request builder for BookingAppointment collection
   132  func (b *BookingBusinessRequestBuilder) CalendarView() *BookingBusinessCalendarViewCollectionRequestBuilder {
   133  	bb := &BookingBusinessCalendarViewCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   134  	bb.baseURL += "/calendarView"
   135  	return bb
   136  }
   137  
   138  // BookingBusinessCalendarViewCollectionRequestBuilder is request builder for BookingAppointment collection
   139  type BookingBusinessCalendarViewCollectionRequestBuilder struct{ BaseRequestBuilder }
   140  
   141  // Request returns request for BookingAppointment collection
   142  func (b *BookingBusinessCalendarViewCollectionRequestBuilder) Request() *BookingBusinessCalendarViewCollectionRequest {
   143  	return &BookingBusinessCalendarViewCollectionRequest{
   144  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   145  	}
   146  }
   147  
   148  // ID returns request builder for BookingAppointment item
   149  func (b *BookingBusinessCalendarViewCollectionRequestBuilder) ID(id string) *BookingAppointmentRequestBuilder {
   150  	bb := &BookingAppointmentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   151  	bb.baseURL += "/" + id
   152  	return bb
   153  }
   154  
   155  // BookingBusinessCalendarViewCollectionRequest is request for BookingAppointment collection
   156  type BookingBusinessCalendarViewCollectionRequest struct{ BaseRequest }
   157  
   158  // Paging perfoms paging operation for BookingAppointment collection
   159  func (r *BookingBusinessCalendarViewCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingAppointment, error) {
   160  	req, err := r.NewJSONRequest(method, path, obj)
   161  	if err != nil {
   162  		return nil, err
   163  	}
   164  	if ctx != nil {
   165  		req = req.WithContext(ctx)
   166  	}
   167  	res, err := r.client.Do(req)
   168  	if err != nil {
   169  		return nil, err
   170  	}
   171  	var values []BookingAppointment
   172  	for {
   173  		if res.StatusCode != http.StatusOK {
   174  			b, _ := ioutil.ReadAll(res.Body)
   175  			res.Body.Close()
   176  			errRes := &ErrorResponse{Response: res}
   177  			err := jsonx.Unmarshal(b, errRes)
   178  			if err != nil {
   179  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   180  			}
   181  			return nil, errRes
   182  		}
   183  		var (
   184  			paging Paging
   185  			value  []BookingAppointment
   186  		)
   187  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   188  		res.Body.Close()
   189  		if err != nil {
   190  			return nil, err
   191  		}
   192  		err = jsonx.Unmarshal(paging.Value, &value)
   193  		if err != nil {
   194  			return nil, err
   195  		}
   196  		values = append(values, value...)
   197  		if n >= 0 {
   198  			n--
   199  		}
   200  		if n == 0 || len(paging.NextLink) == 0 {
   201  			return values, nil
   202  		}
   203  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   204  		if ctx != nil {
   205  			req = req.WithContext(ctx)
   206  		}
   207  		res, err = r.client.Do(req)
   208  		if err != nil {
   209  			return nil, err
   210  		}
   211  	}
   212  }
   213  
   214  // GetN performs GET request for BookingAppointment collection, max N pages
   215  func (r *BookingBusinessCalendarViewCollectionRequest) GetN(ctx context.Context, n int) ([]BookingAppointment, error) {
   216  	var query string
   217  	if r.query != nil {
   218  		query = "?" + r.query.Encode()
   219  	}
   220  	return r.Paging(ctx, "GET", query, nil, n)
   221  }
   222  
   223  // Get performs GET request for BookingAppointment collection
   224  func (r *BookingBusinessCalendarViewCollectionRequest) Get(ctx context.Context) ([]BookingAppointment, error) {
   225  	return r.GetN(ctx, 0)
   226  }
   227  
   228  // Add performs POST request for BookingAppointment collection
   229  func (r *BookingBusinessCalendarViewCollectionRequest) Add(ctx context.Context, reqObj *BookingAppointment) (resObj *BookingAppointment, err error) {
   230  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   231  	return
   232  }
   233  
   234  // Customers returns request builder for BookingCustomer collection
   235  func (b *BookingBusinessRequestBuilder) Customers() *BookingBusinessCustomersCollectionRequestBuilder {
   236  	bb := &BookingBusinessCustomersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   237  	bb.baseURL += "/customers"
   238  	return bb
   239  }
   240  
   241  // BookingBusinessCustomersCollectionRequestBuilder is request builder for BookingCustomer collection
   242  type BookingBusinessCustomersCollectionRequestBuilder struct{ BaseRequestBuilder }
   243  
   244  // Request returns request for BookingCustomer collection
   245  func (b *BookingBusinessCustomersCollectionRequestBuilder) Request() *BookingBusinessCustomersCollectionRequest {
   246  	return &BookingBusinessCustomersCollectionRequest{
   247  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   248  	}
   249  }
   250  
   251  // ID returns request builder for BookingCustomer item
   252  func (b *BookingBusinessCustomersCollectionRequestBuilder) ID(id string) *BookingCustomerRequestBuilder {
   253  	bb := &BookingCustomerRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   254  	bb.baseURL += "/" + id
   255  	return bb
   256  }
   257  
   258  // BookingBusinessCustomersCollectionRequest is request for BookingCustomer collection
   259  type BookingBusinessCustomersCollectionRequest struct{ BaseRequest }
   260  
   261  // Paging perfoms paging operation for BookingCustomer collection
   262  func (r *BookingBusinessCustomersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingCustomer, error) {
   263  	req, err := r.NewJSONRequest(method, path, obj)
   264  	if err != nil {
   265  		return nil, err
   266  	}
   267  	if ctx != nil {
   268  		req = req.WithContext(ctx)
   269  	}
   270  	res, err := r.client.Do(req)
   271  	if err != nil {
   272  		return nil, err
   273  	}
   274  	var values []BookingCustomer
   275  	for {
   276  		if res.StatusCode != http.StatusOK {
   277  			b, _ := ioutil.ReadAll(res.Body)
   278  			res.Body.Close()
   279  			errRes := &ErrorResponse{Response: res}
   280  			err := jsonx.Unmarshal(b, errRes)
   281  			if err != nil {
   282  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   283  			}
   284  			return nil, errRes
   285  		}
   286  		var (
   287  			paging Paging
   288  			value  []BookingCustomer
   289  		)
   290  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   291  		res.Body.Close()
   292  		if err != nil {
   293  			return nil, err
   294  		}
   295  		err = jsonx.Unmarshal(paging.Value, &value)
   296  		if err != nil {
   297  			return nil, err
   298  		}
   299  		values = append(values, value...)
   300  		if n >= 0 {
   301  			n--
   302  		}
   303  		if n == 0 || len(paging.NextLink) == 0 {
   304  			return values, nil
   305  		}
   306  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   307  		if ctx != nil {
   308  			req = req.WithContext(ctx)
   309  		}
   310  		res, err = r.client.Do(req)
   311  		if err != nil {
   312  			return nil, err
   313  		}
   314  	}
   315  }
   316  
   317  // GetN performs GET request for BookingCustomer collection, max N pages
   318  func (r *BookingBusinessCustomersCollectionRequest) GetN(ctx context.Context, n int) ([]BookingCustomer, error) {
   319  	var query string
   320  	if r.query != nil {
   321  		query = "?" + r.query.Encode()
   322  	}
   323  	return r.Paging(ctx, "GET", query, nil, n)
   324  }
   325  
   326  // Get performs GET request for BookingCustomer collection
   327  func (r *BookingBusinessCustomersCollectionRequest) Get(ctx context.Context) ([]BookingCustomer, error) {
   328  	return r.GetN(ctx, 0)
   329  }
   330  
   331  // Add performs POST request for BookingCustomer collection
   332  func (r *BookingBusinessCustomersCollectionRequest) Add(ctx context.Context, reqObj *BookingCustomer) (resObj *BookingCustomer, err error) {
   333  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   334  	return
   335  }
   336  
   337  // Services returns request builder for BookingService collection
   338  func (b *BookingBusinessRequestBuilder) Services() *BookingBusinessServicesCollectionRequestBuilder {
   339  	bb := &BookingBusinessServicesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   340  	bb.baseURL += "/services"
   341  	return bb
   342  }
   343  
   344  // BookingBusinessServicesCollectionRequestBuilder is request builder for BookingService collection
   345  type BookingBusinessServicesCollectionRequestBuilder struct{ BaseRequestBuilder }
   346  
   347  // Request returns request for BookingService collection
   348  func (b *BookingBusinessServicesCollectionRequestBuilder) Request() *BookingBusinessServicesCollectionRequest {
   349  	return &BookingBusinessServicesCollectionRequest{
   350  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   351  	}
   352  }
   353  
   354  // ID returns request builder for BookingService item
   355  func (b *BookingBusinessServicesCollectionRequestBuilder) ID(id string) *BookingServiceRequestBuilder {
   356  	bb := &BookingServiceRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   357  	bb.baseURL += "/" + id
   358  	return bb
   359  }
   360  
   361  // BookingBusinessServicesCollectionRequest is request for BookingService collection
   362  type BookingBusinessServicesCollectionRequest struct{ BaseRequest }
   363  
   364  // Paging perfoms paging operation for BookingService collection
   365  func (r *BookingBusinessServicesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingService, error) {
   366  	req, err := r.NewJSONRequest(method, path, obj)
   367  	if err != nil {
   368  		return nil, err
   369  	}
   370  	if ctx != nil {
   371  		req = req.WithContext(ctx)
   372  	}
   373  	res, err := r.client.Do(req)
   374  	if err != nil {
   375  		return nil, err
   376  	}
   377  	var values []BookingService
   378  	for {
   379  		if res.StatusCode != http.StatusOK {
   380  			b, _ := ioutil.ReadAll(res.Body)
   381  			res.Body.Close()
   382  			errRes := &ErrorResponse{Response: res}
   383  			err := jsonx.Unmarshal(b, errRes)
   384  			if err != nil {
   385  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   386  			}
   387  			return nil, errRes
   388  		}
   389  		var (
   390  			paging Paging
   391  			value  []BookingService
   392  		)
   393  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   394  		res.Body.Close()
   395  		if err != nil {
   396  			return nil, err
   397  		}
   398  		err = jsonx.Unmarshal(paging.Value, &value)
   399  		if err != nil {
   400  			return nil, err
   401  		}
   402  		values = append(values, value...)
   403  		if n >= 0 {
   404  			n--
   405  		}
   406  		if n == 0 || len(paging.NextLink) == 0 {
   407  			return values, nil
   408  		}
   409  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   410  		if ctx != nil {
   411  			req = req.WithContext(ctx)
   412  		}
   413  		res, err = r.client.Do(req)
   414  		if err != nil {
   415  			return nil, err
   416  		}
   417  	}
   418  }
   419  
   420  // GetN performs GET request for BookingService collection, max N pages
   421  func (r *BookingBusinessServicesCollectionRequest) GetN(ctx context.Context, n int) ([]BookingService, error) {
   422  	var query string
   423  	if r.query != nil {
   424  		query = "?" + r.query.Encode()
   425  	}
   426  	return r.Paging(ctx, "GET", query, nil, n)
   427  }
   428  
   429  // Get performs GET request for BookingService collection
   430  func (r *BookingBusinessServicesCollectionRequest) Get(ctx context.Context) ([]BookingService, error) {
   431  	return r.GetN(ctx, 0)
   432  }
   433  
   434  // Add performs POST request for BookingService collection
   435  func (r *BookingBusinessServicesCollectionRequest) Add(ctx context.Context, reqObj *BookingService) (resObj *BookingService, err error) {
   436  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   437  	return
   438  }
   439  
   440  // StaffMembers returns request builder for BookingStaffMember collection
   441  func (b *BookingBusinessRequestBuilder) StaffMembers() *BookingBusinessStaffMembersCollectionRequestBuilder {
   442  	bb := &BookingBusinessStaffMembersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   443  	bb.baseURL += "/staffMembers"
   444  	return bb
   445  }
   446  
   447  // BookingBusinessStaffMembersCollectionRequestBuilder is request builder for BookingStaffMember collection
   448  type BookingBusinessStaffMembersCollectionRequestBuilder struct{ BaseRequestBuilder }
   449  
   450  // Request returns request for BookingStaffMember collection
   451  func (b *BookingBusinessStaffMembersCollectionRequestBuilder) Request() *BookingBusinessStaffMembersCollectionRequest {
   452  	return &BookingBusinessStaffMembersCollectionRequest{
   453  		BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
   454  	}
   455  }
   456  
   457  // ID returns request builder for BookingStaffMember item
   458  func (b *BookingBusinessStaffMembersCollectionRequestBuilder) ID(id string) *BookingStaffMemberRequestBuilder {
   459  	bb := &BookingStaffMemberRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
   460  	bb.baseURL += "/" + id
   461  	return bb
   462  }
   463  
   464  // BookingBusinessStaffMembersCollectionRequest is request for BookingStaffMember collection
   465  type BookingBusinessStaffMembersCollectionRequest struct{ BaseRequest }
   466  
   467  // Paging perfoms paging operation for BookingStaffMember collection
   468  func (r *BookingBusinessStaffMembersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingStaffMember, error) {
   469  	req, err := r.NewJSONRequest(method, path, obj)
   470  	if err != nil {
   471  		return nil, err
   472  	}
   473  	if ctx != nil {
   474  		req = req.WithContext(ctx)
   475  	}
   476  	res, err := r.client.Do(req)
   477  	if err != nil {
   478  		return nil, err
   479  	}
   480  	var values []BookingStaffMember
   481  	for {
   482  		if res.StatusCode != http.StatusOK {
   483  			b, _ := ioutil.ReadAll(res.Body)
   484  			res.Body.Close()
   485  			errRes := &ErrorResponse{Response: res}
   486  			err := jsonx.Unmarshal(b, errRes)
   487  			if err != nil {
   488  				return nil, fmt.Errorf("%s: %s", res.Status, string(b))
   489  			}
   490  			return nil, errRes
   491  		}
   492  		var (
   493  			paging Paging
   494  			value  []BookingStaffMember
   495  		)
   496  		err := jsonx.NewDecoder(res.Body).Decode(&paging)
   497  		res.Body.Close()
   498  		if err != nil {
   499  			return nil, err
   500  		}
   501  		err = jsonx.Unmarshal(paging.Value, &value)
   502  		if err != nil {
   503  			return nil, err
   504  		}
   505  		values = append(values, value...)
   506  		if n >= 0 {
   507  			n--
   508  		}
   509  		if n == 0 || len(paging.NextLink) == 0 {
   510  			return values, nil
   511  		}
   512  		req, err = http.NewRequest("GET", paging.NextLink, nil)
   513  		if ctx != nil {
   514  			req = req.WithContext(ctx)
   515  		}
   516  		res, err = r.client.Do(req)
   517  		if err != nil {
   518  			return nil, err
   519  		}
   520  	}
   521  }
   522  
   523  // GetN performs GET request for BookingStaffMember collection, max N pages
   524  func (r *BookingBusinessStaffMembersCollectionRequest) GetN(ctx context.Context, n int) ([]BookingStaffMember, error) {
   525  	var query string
   526  	if r.query != nil {
   527  		query = "?" + r.query.Encode()
   528  	}
   529  	return r.Paging(ctx, "GET", query, nil, n)
   530  }
   531  
   532  // Get performs GET request for BookingStaffMember collection
   533  func (r *BookingBusinessStaffMembersCollectionRequest) Get(ctx context.Context) ([]BookingStaffMember, error) {
   534  	return r.GetN(ctx, 0)
   535  }
   536  
   537  // Add performs POST request for BookingStaffMember collection
   538  func (r *BookingBusinessStaffMembersCollectionRequest) Add(ctx context.Context, reqObj *BookingStaffMember) (resObj *BookingStaffMember, err error) {
   539  	err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
   540  	return
   541  }