bookings

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 4 Imported by: 0

README

Zoho BOOKINGS V1 API

NOTE: Not finished and probably unstable. PRs welcome.

This API wrapper should provide access to Zoho BOOKINGS. For the GET api's which use query parameters, these should be passed as the type map[string]zoho.Parameter. For the POST API's which require RequestBody, the key value pairs should be passed on as variables of type map[string]string.

Note: These APIs result entire API response in JSON format. It is expected that client application will parse the API response to get the desired fields. fields they need.

Usage

import (
    "log"
    "fmt"
    "github.com/schmorrison/Zoho"
)

func main() {
    // get access/refresh tokens
    z := zoho.New()
    scopes := []zoho.ScopeString{
        zoho.BuildScope(zoho.Bookings, zoho.DataScope, "", zoho.Create),
    }
    if err := z.AuthorizationCodeRequest("yourClientID", "yourClientSecret", scopes, "http://localhost:8080/oauthredirect"); err != nil {
        log.Fatal(err)
    }

    // Create a new Bookings object and provide the Zoho struct
    c := bookings.New(z)

    // While untested, getting data should work like so
    data := bookings.ServiceResponse{}
    param := make(map[string]zoho.Parameter)
    param["workspace_id"] = "yourWorkspaceID"
    resp, err := c.FetchServices(&data,param)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(resp)
}

TODO

  • Write a TODO list
  • Comment code with full details
  • Add page context values to returned data, or methods to interact with it via module
  • Create godoc for bookings APIs
  • Identify Bookings APIs which are used most

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	*zoho.Zoho
	// contains filtered or unexported fields
}

API is used for interacting with the Zoho expense API the exposed methods are primarily access to expense modules which provide access to expense Methods

func New

func New(z *zoho.Zoho) *API

New returns a *expense.API with the provided zoho.Zoho as an embedded field

func (*API) BookAppointment

func (c *API) BookAppointment(request BookAppointmentData) (data AppointmentResponse, err error)

func (*API) FetchAvailability

func (c *API) FetchAvailability(serviceID zoho.Parameter, staffID zoho.Parameter, resourceID zoho.Parameter, date zoho.Parameter) (data AvailabilityResponse, err error)

func (*API) FetchResources

func (c *API) FetchResources(resourceID zoho.Parameter, serviceID zoho.Parameter) (data ResourceResponse, err error)

func (*API) FetchServices

func (c *API) FetchServices(workspacesID zoho.Parameter, serviceID zoho.Parameter, staffID zoho.Parameter) (data ServiceResponse, err error)

func (*API) FetchStaff

func (c *API) FetchStaff(serviceID zoho.Parameter, staffID zoho.Parameter) (data StaffResponse, err error)

func (*API) FetchWorkspaces

func (c *API) FetchWorkspaces(workspacesID zoho.Parameter) (data WorkspaceResponse, err error)

func (*API) GetAppointment

func (c *API) GetAppointment(bookingID zoho.Parameter) (data AppointmentResponse, err error)

func (*API) RescheduleAppointment

func (c *API) RescheduleAppointment(request RescheduleAppointmentData) (data AppointmentResponse, err error)

func (*API) UpdateAppointment

func (c *API) UpdateAppointment(request UpdateAppointmentData) (data AppointmentResponse, err error)

type AdditionalFields

type AdditionalFields struct {
	AddressField        string `json:"Address,omitempty"`
	IssueField          string `json:"Issue,omitempty"`
	ConfirmContactField string `json:"Confirm Contact Number,omitempty"`
	ScanningChargeField int    `json:"ScanningCharge,omitempty"`
	DriveLinkField      string `json:"Scanning Drive Link,omitempty"`
	BookedByField       string `json:"BookedBy,omitempty"`
	CityField           string `json:"City,omitempty"`
}

type AppointmentResponse

type AppointmentResponse struct {
	Response struct {
		ErrorMessage string   `json:"errormessage,omitempty"`
		Status       string   `json:"status"`
		LogMessage   []string `json:"logMessage"`
		ReturnValue  struct {
			StaffName                string   `json:"staff_name"`
			CustomerMoreInfo         struct{} `json:"customer_more_info"`
			CustomerBookingStartTime string   `json:"customer_booking_start_time"`
			CustomerContactNo        string   `json:"customer_contact_no"`
			BookedOn                 string   `json:"booked_on"`
			BookingID                string   `json:"booking_id"`
			WorkspaceId              string   `json:"workspace_id"`
			Duration                 string   `json:"duration"`
			ServiceId                string   `json:"service_id"`
			StaffId                  string   `json:"staff_id"`
			CostPaid                 string   `json:"cost_paid"`
			Currency                 string   `json:"currency"`
			WorkspaceName            string   `json:"workspace_name"`
			Cost                     string   `json:"cost"`
			ServiceName              string   `json:"service_name"`
			TimeZone                 string   `json:"time_zone"`
			StartTime                string   `json:"start_time"`
			Due                      string   `json:"due"`
			CustomerEmail            string   `json:"customer_email"`
			BookingType              string   `json:"booking_type"`
			CustomerName             string   `json:"customer_name"`
			SummaryUrl               string   `json:"summary_url"`
			CustomerBookingTimeZone  string   `json:"customer_booking_time_zone"`
			Status                   string   `json:status"`
		} `json:"returnvalue"`
	} `json:"response"`
}

AppointmentResponse is the data returned by GetAppointment

type AvailabilityResponse

type AvailabilityResponse struct {
	Response struct {
		ReturnValue struct {
			Response bool     `json:"response"`
			Data     []string `json:"data"`
			TimeZone string   `json:"time_zone"`
		} `json:"returnvalue"`
		Status string `json:"status"`
	} `json:"response"`
}

type BookAppointmentData

type BookAppointmentData struct {
	ServiceId        string           `url:"service_id"`
	StaffId          string           `url:"staff_id,omitempty"`
	ResourceId       string           `url:"resource_id,omitempty"`
	FromTime         string           `url:"from_time"`
	TimeZone         string           `url:"time_zone,omitempty"`
	Customer_Details CustomerDetails  `url:"customer_details,json,omitempty"` // Note the option `json` before `omitempty`, the order shouldn't matter
	AddFields        AdditionalFields `url:"additional_fields,json,omitempty"`
}

type BookingsModule

type BookingsModule = string
const (
	GetAppointmentModule        BookingsModule = "getappointment"
	GetAvailabilityModule       BookingsModule = "availableslots"
	FetchWorkspacesModule       BookingsModule = "workspaces"
	FetchServicesModule         BookingsModule = "services"
	FetchStaffModule            BookingsModule = "staffs"
	FetchResourceModule         BookingsModule = "resources"
	BookAppointmentModule       BookingsModule = "appointment"
	RescheduleAppointmentModule BookingsModule = "rescheduleappointment"
	UpdateAppointmentModule     BookingsModule = "updateappointment"
)

type CustomerDetails

type CustomerDetails struct {
	Name        string `json:"name"`
	Email       string `json:"email"`
	PhoneNumber string `json:"phone_number"`
}

type RescheduleAppointmentData

type RescheduleAppointmentData struct {
	BookingID string `url:"booking_id"`
	StaffId   string `url:"staff_id,omitempty"`
	StartTime string `url:"start_time,omitempty"`
}

type ResourceResponse

type ResourceResponse struct {
	Response struct {
		ReturnValue struct {
			Data []struct {
				Name string `json:"name"`
				Id   string `json:"id"`
			} `json:"data"`
		} `json:"returnvalue"`
		Status string `json:"status"`
	} `json:"response"`
}

type ServiceResponse

type ServiceResponse struct {
	Response struct {
		ReturnValue struct {
			Data []struct {
				Duration   string `json:"duration"`
				Buffertime string `json:"buffertime"`
				Price      int    `json:"price"`
				Name       string `json:"name"`
				Currency   string `json:"currency"`
				Id         string `json:"id"`
			} `json:"data"`
		} `json:"returnvalue"`
		Status string `json:"status"`
	} `json:"response"`
}

type StaffResponse

type StaffResponse struct {
	Response struct {
		ReturnValue struct {
			Data []struct {
				Name string `json:"name"`
				Id   string `json:"id"`
			} `json:"data"`
		} `json:"returnvalue"`
		Status string `json:"status"`
	} `json:"response"`
}

type UpdateAppointmentData

type UpdateAppointmentData struct {
	BookingID string `url:"booking_id"`
	Action    string `url:"action"`
}

type WorkspaceResponse

type WorkspaceResponse struct {
	Response struct {
		ReturnValue struct {
			Data []struct {
				Name string `json:"name"`
				Id   string `json:"id"`
			} `json:"data"`
		} `json:"returnvalue"`
		Status string `json:"status"`
	} `json:"response"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL