scheduling

package module
v0.0.0-...-711662e Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

README

Shilling Scheduling API Go SDK

The Shilling Scheduling API Go SDK is primarily generated using go-swagger which implements a more Go idiomatic (and functioning) version of what the swagger-codegen project does for other languages. While we generate the client, models, and core requests handling we also add some helper utilities to symplify instantiation. Below are some basic examples to get you up and running in short order.

Prerequisites

You will need to request an environment and access credentials from our site Shilling. After which you should be able to fill in the necessary values below in the examples.

Install

This package uses Go modules so to install you can simply run the following

go get github.com/shillingio/scheduling.go

Usage

  import(
    "github.com/go-openapi/swag"

    "github.com/shillingio/scheduling.go"
    "github.com/shillingio/scheduling.go/models"
    "github.com/shillingio/scheduling.go/scheduler"
  )

  api, err := scheduling.NewAPI(scheduling.Config{
		BaseURL:      "<provided base URL>",
		TokenURL:     "<provided token URL>",
		ClientID:     "<provided client id>",
		ClientSecret: "<provided client secret>",
	})
Get Services
  ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
  defer cancel()

  resp, err := api.Client.Scheduler.SchedulerGetServices(
    &scheduler.SchedulerGetServicesParams{
      Context: ctx,
    },
    api.WithAuth,
  )
  if err != nil {
    // handle err
  }


Search Availability
  var (
    zip       = "92101"
    serviceID = "service uuid"
    rangeFrom = time.Now().Add(1 * time.Hour).Format(time.RFC3339)
    rangeTo   = time.Now().Add(3 * (24 * time.Hour)).Format(time.RFC3339)
    duration  = 15 // appointment duration length (15,30,45,60) 
  )

  ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
  defer cancel()

  resp, err := api.Client.Scheduler.SchedulerSearchAvailability(
    &scheduler.SchedulerSearchAvailabilityParams{
      Body: &models.SchedulerAvailabilitySearchRequest{
        RangeFrom: swag.String(rangeFrom),
        RangeTo:   swag.String(rangeTo),
        Zip:       swag.String(zip),
        ServiceID: serviceID,
        Duration:  swag.Int32(duration),
      },
      Context: ctx,
    },
    api.WithAuth,
  )
  if err != nil {
    // handle err
  }

Create an Appointment
  var (
    apptID       = "<appointment ID from the availability search results>"
    refID        = "<your internal reference ID>"
    patientRefID = "<your internal patient reference ID>"
  )
  
  ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
  defer cancel()

  resp, err := api.Client.Scheduler.SchedulerCreateAppointment(&scheduler.SchedulerCreateAppointmentParams{
    Body: &models.SchedulingAppointment{
      ID:    apptID, // shilling reservation UUID
      RefID: refID,  // your reference ID
      Patient: &models.SchedulingPatient{
        ID:    "",            // shilling UUID (if not using ref id)
        RefID: patientRefID,  // your reference ID
      },
    },
    Context: ctx,
  },
    api.WithAuth,
  )

  if err != nil {
    // handle err
  }

Documentation

Index

Constants

View Source
const (
	// DefaultHost is the default Host
	// found in Meta (info) section of spec file
	DefaultHost string = "localhost"
	// DefaultBasePath is the default BasePath
	// found in Meta (info) section of spec file
	DefaultBasePath string = "/"
)
View Source
const (
	EnvBaseURL      = "SCHEDULING_API_BASE_URL"
	EnvTokenURL     = "SCHEDULING_API_TOKEN_URL"
	EnvClientID     = "SCHEDULING_API_CLIENT_ID"
	EnvClientSecret = "SCHEDULING_API_CLIENT_SECRET"
)

Variables

View Source
var (
	ErrMissingBaseURL      = fmt.Errorf("new scheduling api: missing base URL, pass in a complete config or set the environment variable %s", EnvBaseURL)
	ErrMissingTokenURL     = fmt.Errorf("new scheduling api: missing token URL, pass in a complete config or set the environment variable %s", EnvTokenURL)
	ErrMissingClientID     = fmt.Errorf("new scheduling api: missing client id, pass in a complete config or set the environment variable %s", EnvClientID)
	ErrMissingClientSecret = fmt.Errorf("new scheduling api: missing client secret, pass in a complete config or set the environment variable %s", EnvClientSecret)
)
View Source
var Default = NewHTTPClient(nil)

Default API proto HTTP client.

View Source
var DefaultSchemes = []string{"https"}

DefaultSchemes are the default schemes found in Meta (info) section of spec file

Functions

func DebugRoundTripper

func DebugRoundTripper(base http.RoundTripper) http.RoundTripper

func SetUserAgent

func SetUserAgent(inner http.RoundTripper, userAgent string) http.RoundTripper

Types

type API

type API struct {
	Client *APIProto
	Config Config

	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(config ...Config) (*API, error)

func (*API) AuthInfoWriter

func (a *API) AuthInfoWriter() runtime.ClientAuthInfoWriter

func (*API) Authenticate

func (a *API) Authenticate() error

func (*API) WithAuth

func (a *API) WithAuth(op *runtime.ClientOperation)

type APIProto

type APIProto struct {
	Scheduler scheduler.ClientService

	Transport runtime.ClientTransport
}

APIProto is a client for API proto

func New

func New(transport runtime.ClientTransport, formats strfmt.Registry) *APIProto

New creates a new API proto client

func NewHTTPClient

func NewHTTPClient(formats strfmt.Registry) *APIProto

NewHTTPClient creates a new API proto HTTP client.

func NewHTTPClientWithConfig

func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *APIProto

NewHTTPClientWithConfig creates a new API proto HTTP client, using a customizable transport config.

func (*APIProto) SetTransport

func (c *APIProto) SetTransport(transport runtime.ClientTransport)

SetTransport changes the transport on the client and all its subresources

type Config

type Config struct {
	BaseURL      string
	ClientID     string
	ClientSecret string
	TokenURL     string
	Debug        bool

	Options []scheduler.ClientOption
}

type TransportConfig

type TransportConfig struct {
	Host     string
	BasePath string
	Schemes  []string
}

TransportConfig contains the transport related info, found in the meta section of the spec file.

func DefaultTransportConfig

func DefaultTransportConfig() *TransportConfig

DefaultTransportConfig creates a TransportConfig with the default settings taken from the meta section of the spec file.

func (*TransportConfig) WithBasePath

func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig

WithBasePath overrides the default basePath, provided by the meta section of the spec file.

func (*TransportConfig) WithHost

func (cfg *TransportConfig) WithHost(host string) *TransportConfig

WithHost overrides the default host, provided by the meta section of the spec file.

func (*TransportConfig) WithSchemes

func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig

WithSchemes overrides the default schemes, provided by the meta section of the spec file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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