2019-12-26 14:12:28 -08:00
|
|
|
// Code generated by msgraph-generate.go DO NOT EDIT.
|
|
|
|
|
|
|
|
package msgraph
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
"github.com/yaegashi/msgraph.go/jsonx"
|
2019-12-26 14:12:28 -08:00
|
|
|
)
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// BookingAppointmentCancelRequestParameter undocumented
|
|
|
|
type BookingAppointmentCancelRequestParameter struct {
|
|
|
|
// CancellationMessage undocumented
|
|
|
|
CancellationMessage *string `json:"cancellationMessage,omitempty"`
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// BookingBusinessPublishRequestParameter undocumented
|
|
|
|
type BookingBusinessPublishRequestParameter struct {
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// BookingBusinessUnpublishRequestParameter undocumented
|
|
|
|
type BookingBusinessUnpublishRequestParameter struct {
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Appointments returns request builder for BookingAppointment collection
|
|
|
|
func (b *BookingBusinessRequestBuilder) Appointments() *BookingBusinessAppointmentsCollectionRequestBuilder {
|
|
|
|
bb := &BookingBusinessAppointmentsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/appointments"
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessAppointmentsCollectionRequestBuilder is request builder for BookingAppointment collection
|
|
|
|
type BookingBusinessAppointmentsCollectionRequestBuilder struct{ BaseRequestBuilder }
|
|
|
|
|
|
|
|
// Request returns request for BookingAppointment collection
|
|
|
|
func (b *BookingBusinessAppointmentsCollectionRequestBuilder) Request() *BookingBusinessAppointmentsCollectionRequest {
|
|
|
|
return &BookingBusinessAppointmentsCollectionRequest{
|
|
|
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns request builder for BookingAppointment item
|
|
|
|
func (b *BookingBusinessAppointmentsCollectionRequestBuilder) ID(id string) *BookingAppointmentRequestBuilder {
|
|
|
|
bb := &BookingAppointmentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/" + id
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessAppointmentsCollectionRequest is request for BookingAppointment collection
|
|
|
|
type BookingBusinessAppointmentsCollectionRequest struct{ BaseRequest }
|
|
|
|
|
|
|
|
// Paging perfoms paging operation for BookingAppointment collection
|
2020-03-15 15:43:46 -07:00
|
|
|
func (r *BookingBusinessAppointmentsCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingAppointment, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
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 []BookingAppointment
|
|
|
|
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 []BookingAppointment
|
|
|
|
)
|
|
|
|
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...)
|
2020-03-15 15:43:46 -07:00
|
|
|
if n >= 0 {
|
|
|
|
n--
|
|
|
|
}
|
|
|
|
if n == 0 || len(paging.NextLink) == 0 {
|
2019-12-26 14:12:28 -08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// GetN performs GET request for BookingAppointment collection, max N pages
|
|
|
|
func (r *BookingBusinessAppointmentsCollectionRequest) GetN(ctx context.Context, n int) ([]BookingAppointment, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
var query string
|
|
|
|
if r.query != nil {
|
|
|
|
query = "?" + r.query.Encode()
|
|
|
|
}
|
2020-03-15 15:43:46 -07:00
|
|
|
return r.Paging(ctx, "GET", query, nil, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get performs GET request for BookingAppointment collection
|
|
|
|
func (r *BookingBusinessAppointmentsCollectionRequest) Get(ctx context.Context) ([]BookingAppointment, error) {
|
|
|
|
return r.GetN(ctx, 0)
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add performs POST request for BookingAppointment collection
|
|
|
|
func (r *BookingBusinessAppointmentsCollectionRequest) Add(ctx context.Context, reqObj *BookingAppointment) (resObj *BookingAppointment, err error) {
|
|
|
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CalendarView returns request builder for BookingAppointment collection
|
|
|
|
func (b *BookingBusinessRequestBuilder) CalendarView() *BookingBusinessCalendarViewCollectionRequestBuilder {
|
|
|
|
bb := &BookingBusinessCalendarViewCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/calendarView"
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessCalendarViewCollectionRequestBuilder is request builder for BookingAppointment collection
|
|
|
|
type BookingBusinessCalendarViewCollectionRequestBuilder struct{ BaseRequestBuilder }
|
|
|
|
|
|
|
|
// Request returns request for BookingAppointment collection
|
|
|
|
func (b *BookingBusinessCalendarViewCollectionRequestBuilder) Request() *BookingBusinessCalendarViewCollectionRequest {
|
|
|
|
return &BookingBusinessCalendarViewCollectionRequest{
|
|
|
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns request builder for BookingAppointment item
|
|
|
|
func (b *BookingBusinessCalendarViewCollectionRequestBuilder) ID(id string) *BookingAppointmentRequestBuilder {
|
|
|
|
bb := &BookingAppointmentRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/" + id
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessCalendarViewCollectionRequest is request for BookingAppointment collection
|
|
|
|
type BookingBusinessCalendarViewCollectionRequest struct{ BaseRequest }
|
|
|
|
|
|
|
|
// Paging perfoms paging operation for BookingAppointment collection
|
2020-03-15 15:43:46 -07:00
|
|
|
func (r *BookingBusinessCalendarViewCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingAppointment, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
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 []BookingAppointment
|
|
|
|
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 []BookingAppointment
|
|
|
|
)
|
|
|
|
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...)
|
2020-03-15 15:43:46 -07:00
|
|
|
if n >= 0 {
|
|
|
|
n--
|
|
|
|
}
|
|
|
|
if n == 0 || len(paging.NextLink) == 0 {
|
2019-12-26 14:12:28 -08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// GetN performs GET request for BookingAppointment collection, max N pages
|
|
|
|
func (r *BookingBusinessCalendarViewCollectionRequest) GetN(ctx context.Context, n int) ([]BookingAppointment, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
var query string
|
|
|
|
if r.query != nil {
|
|
|
|
query = "?" + r.query.Encode()
|
|
|
|
}
|
2020-03-15 15:43:46 -07:00
|
|
|
return r.Paging(ctx, "GET", query, nil, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get performs GET request for BookingAppointment collection
|
|
|
|
func (r *BookingBusinessCalendarViewCollectionRequest) Get(ctx context.Context) ([]BookingAppointment, error) {
|
|
|
|
return r.GetN(ctx, 0)
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add performs POST request for BookingAppointment collection
|
|
|
|
func (r *BookingBusinessCalendarViewCollectionRequest) Add(ctx context.Context, reqObj *BookingAppointment) (resObj *BookingAppointment, err error) {
|
|
|
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Customers returns request builder for BookingCustomer collection
|
|
|
|
func (b *BookingBusinessRequestBuilder) Customers() *BookingBusinessCustomersCollectionRequestBuilder {
|
|
|
|
bb := &BookingBusinessCustomersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/customers"
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessCustomersCollectionRequestBuilder is request builder for BookingCustomer collection
|
|
|
|
type BookingBusinessCustomersCollectionRequestBuilder struct{ BaseRequestBuilder }
|
|
|
|
|
|
|
|
// Request returns request for BookingCustomer collection
|
|
|
|
func (b *BookingBusinessCustomersCollectionRequestBuilder) Request() *BookingBusinessCustomersCollectionRequest {
|
|
|
|
return &BookingBusinessCustomersCollectionRequest{
|
|
|
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns request builder for BookingCustomer item
|
|
|
|
func (b *BookingBusinessCustomersCollectionRequestBuilder) ID(id string) *BookingCustomerRequestBuilder {
|
|
|
|
bb := &BookingCustomerRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/" + id
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessCustomersCollectionRequest is request for BookingCustomer collection
|
|
|
|
type BookingBusinessCustomersCollectionRequest struct{ BaseRequest }
|
|
|
|
|
|
|
|
// Paging perfoms paging operation for BookingCustomer collection
|
2020-03-15 15:43:46 -07:00
|
|
|
func (r *BookingBusinessCustomersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingCustomer, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
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 []BookingCustomer
|
|
|
|
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 []BookingCustomer
|
|
|
|
)
|
|
|
|
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...)
|
2020-03-15 15:43:46 -07:00
|
|
|
if n >= 0 {
|
|
|
|
n--
|
|
|
|
}
|
|
|
|
if n == 0 || len(paging.NextLink) == 0 {
|
2019-12-26 14:12:28 -08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// GetN performs GET request for BookingCustomer collection, max N pages
|
|
|
|
func (r *BookingBusinessCustomersCollectionRequest) GetN(ctx context.Context, n int) ([]BookingCustomer, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
var query string
|
|
|
|
if r.query != nil {
|
|
|
|
query = "?" + r.query.Encode()
|
|
|
|
}
|
2020-03-15 15:43:46 -07:00
|
|
|
return r.Paging(ctx, "GET", query, nil, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get performs GET request for BookingCustomer collection
|
|
|
|
func (r *BookingBusinessCustomersCollectionRequest) Get(ctx context.Context) ([]BookingCustomer, error) {
|
|
|
|
return r.GetN(ctx, 0)
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add performs POST request for BookingCustomer collection
|
|
|
|
func (r *BookingBusinessCustomersCollectionRequest) Add(ctx context.Context, reqObj *BookingCustomer) (resObj *BookingCustomer, err error) {
|
|
|
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Services returns request builder for BookingService collection
|
|
|
|
func (b *BookingBusinessRequestBuilder) Services() *BookingBusinessServicesCollectionRequestBuilder {
|
|
|
|
bb := &BookingBusinessServicesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/services"
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessServicesCollectionRequestBuilder is request builder for BookingService collection
|
|
|
|
type BookingBusinessServicesCollectionRequestBuilder struct{ BaseRequestBuilder }
|
|
|
|
|
|
|
|
// Request returns request for BookingService collection
|
|
|
|
func (b *BookingBusinessServicesCollectionRequestBuilder) Request() *BookingBusinessServicesCollectionRequest {
|
|
|
|
return &BookingBusinessServicesCollectionRequest{
|
|
|
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns request builder for BookingService item
|
|
|
|
func (b *BookingBusinessServicesCollectionRequestBuilder) ID(id string) *BookingServiceRequestBuilder {
|
|
|
|
bb := &BookingServiceRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/" + id
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessServicesCollectionRequest is request for BookingService collection
|
|
|
|
type BookingBusinessServicesCollectionRequest struct{ BaseRequest }
|
|
|
|
|
|
|
|
// Paging perfoms paging operation for BookingService collection
|
2020-03-15 15:43:46 -07:00
|
|
|
func (r *BookingBusinessServicesCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingService, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
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 []BookingService
|
|
|
|
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 []BookingService
|
|
|
|
)
|
|
|
|
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...)
|
2020-03-15 15:43:46 -07:00
|
|
|
if n >= 0 {
|
|
|
|
n--
|
|
|
|
}
|
|
|
|
if n == 0 || len(paging.NextLink) == 0 {
|
2019-12-26 14:12:28 -08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// GetN performs GET request for BookingService collection, max N pages
|
|
|
|
func (r *BookingBusinessServicesCollectionRequest) GetN(ctx context.Context, n int) ([]BookingService, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
var query string
|
|
|
|
if r.query != nil {
|
|
|
|
query = "?" + r.query.Encode()
|
|
|
|
}
|
2020-03-15 15:43:46 -07:00
|
|
|
return r.Paging(ctx, "GET", query, nil, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get performs GET request for BookingService collection
|
|
|
|
func (r *BookingBusinessServicesCollectionRequest) Get(ctx context.Context) ([]BookingService, error) {
|
|
|
|
return r.GetN(ctx, 0)
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add performs POST request for BookingService collection
|
|
|
|
func (r *BookingBusinessServicesCollectionRequest) Add(ctx context.Context, reqObj *BookingService) (resObj *BookingService, err error) {
|
|
|
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// StaffMembers returns request builder for BookingStaffMember collection
|
|
|
|
func (b *BookingBusinessRequestBuilder) StaffMembers() *BookingBusinessStaffMembersCollectionRequestBuilder {
|
|
|
|
bb := &BookingBusinessStaffMembersCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/staffMembers"
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessStaffMembersCollectionRequestBuilder is request builder for BookingStaffMember collection
|
|
|
|
type BookingBusinessStaffMembersCollectionRequestBuilder struct{ BaseRequestBuilder }
|
|
|
|
|
|
|
|
// Request returns request for BookingStaffMember collection
|
|
|
|
func (b *BookingBusinessStaffMembersCollectionRequestBuilder) Request() *BookingBusinessStaffMembersCollectionRequest {
|
|
|
|
return &BookingBusinessStaffMembersCollectionRequest{
|
|
|
|
BaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns request builder for BookingStaffMember item
|
|
|
|
func (b *BookingBusinessStaffMembersCollectionRequestBuilder) ID(id string) *BookingStaffMemberRequestBuilder {
|
|
|
|
bb := &BookingStaffMemberRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}
|
|
|
|
bb.baseURL += "/" + id
|
|
|
|
return bb
|
|
|
|
}
|
|
|
|
|
|
|
|
// BookingBusinessStaffMembersCollectionRequest is request for BookingStaffMember collection
|
|
|
|
type BookingBusinessStaffMembersCollectionRequest struct{ BaseRequest }
|
|
|
|
|
|
|
|
// Paging perfoms paging operation for BookingStaffMember collection
|
2020-03-15 15:43:46 -07:00
|
|
|
func (r *BookingBusinessStaffMembersCollectionRequest) Paging(ctx context.Context, method, path string, obj interface{}, n int) ([]BookingStaffMember, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
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 []BookingStaffMember
|
|
|
|
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 []BookingStaffMember
|
|
|
|
)
|
|
|
|
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...)
|
2020-03-15 15:43:46 -07:00
|
|
|
if n >= 0 {
|
|
|
|
n--
|
|
|
|
}
|
|
|
|
if n == 0 || len(paging.NextLink) == 0 {
|
2019-12-26 14:12:28 -08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-15 15:43:46 -07:00
|
|
|
// GetN performs GET request for BookingStaffMember collection, max N pages
|
|
|
|
func (r *BookingBusinessStaffMembersCollectionRequest) GetN(ctx context.Context, n int) ([]BookingStaffMember, error) {
|
2019-12-26 14:12:28 -08:00
|
|
|
var query string
|
|
|
|
if r.query != nil {
|
|
|
|
query = "?" + r.query.Encode()
|
|
|
|
}
|
2020-03-15 15:43:46 -07:00
|
|
|
return r.Paging(ctx, "GET", query, nil, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get performs GET request for BookingStaffMember collection
|
|
|
|
func (r *BookingBusinessStaffMembersCollectionRequest) Get(ctx context.Context) ([]BookingStaffMember, error) {
|
|
|
|
return r.GetN(ctx, 0)
|
2019-12-26 14:12:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add performs POST request for BookingStaffMember collection
|
|
|
|
func (r *BookingBusinessStaffMembersCollectionRequest) Add(ctx context.Context, reqObj *BookingStaffMember) (resObj *BookingStaffMember, err error) {
|
|
|
|
err = r.JSONRequest(ctx, "POST", "", reqObj, &resObj)
|
|
|
|
return
|
|
|
|
}
|