calendly

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHeaderTokenKey = "X-Token"

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func NewTokenAuthClient

func NewTokenAuthClient(config *Config) *http.Client

NewTokenAuthClient returns a new http Client which signs requests via header Token.

Types

type AboutMe

type AboutMe struct {
	Type       string          `json:"type"`
	ID         string          `json:"id"`
	Attributes *UserAttributes `json:"attributes,omitempty"`
}

func (*AboutMe) String

func (a *AboutMe) String() string

type AboutMeResponse

type AboutMeResponse struct {
	AboutMe *AboutMe `json:"data"`
}

type Avatar

type Avatar struct {
	URL string `json:"url"`
}

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent for client
	UserAgent string

	// Event Types Service
	EventTypes EventTypesService

	// Users Service
	Users UsersService

	// Webhooks Service
	Webhooks WebhooksService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Calendly API client.

func (*Client) Delete

func (c *Client) Delete(urlStr string) (*http.Request, error)

Convenient shorthand for DELETE requests

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*Client) Echo

func (c *Client) Echo(ctx context.Context) (*Echo, *Response, error)

func (*Client) Get

func (c *Client) Get(urlStr string) (*http.Request, error)

Convenient shorthand for GET requests

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.

func (*Client) Post

func (c *Client) Post(urlStr string, body interface{}) (*http.Request, error)

Convenient shorthand for POST requests

func (*Client) Put

func (c *Client) Put(urlStr string, body interface{}) (*http.Request, error)

Convenient shorthand for PUT requests

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(bUrl string) error

SetBaseURL is a client option for setting the base URL.

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(ua string)

SetUserAgent is a client option for setting the user agent.

type Config

type Config struct {
	// API Key (Client Identifier)
	ApiKey string

	// Header identifier for passing the API key
	HeaderKey string
}

Config represents an OAuth1 consumer's (client's) key and secret, the callback URL, and the provider Endpoint to which the consumer corresponds.

type Data

type Data struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

type Echo

type Echo struct {
	Email string `json:"email"`
}

Test Authentication Token Use this endpoint to test your Authentication Token.

func (*Echo) String

func (r *Echo) String() string

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// Error message
	Message string `json:"message"`

	// RequestID returned from the API, useful to contact support.
	RequestID string `json:"request_id"`
}

An ErrorResponse reports the error caused by an API request

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type EventHookType

type EventHookType string
const (
	InviteeCreatedHookType   EventHookType = "invitee.created"
	InviteeCancelledHookType EventHookType = "invitee.cancelled"
)

type EventType

type EventType struct {
	Type          string               `json:"type"`
	ID            string               `json:"id"`
	Attributes    *EventTypeAttributes `json:"attributes,omitempty"`
	Relationships *Relationships       `json:"relationships,omitempty"`
}

func (*EventType) String

func (et *EventType) String() string

type EventTypeAttributes

type EventTypeAttributes struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Duration    int64  `json:"duration"`
	Slug        string `json:"slug"`
	Color       string `json:"color"`
	Active      bool   `json:"active"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
	URL         string `json:"url"`
}

type EventTypesOpts

type EventTypesOpts struct {
	// request extra information about the entity that owns the Event Type,
	// by adding ?include=owner to the URL of the request.
	Include IncludeType `url:"include,omitempty"`
}

type EventTypesService

type EventTypesService apiService

func (*EventTypesService) List

Event Types contain the most important configurations in Calendly. If you need some basic information about your event types, you can use this endpoint.

type IncludeType

type IncludeType string

Include Event type option

const (

	// Owner event type option
	IncludeTypeOwner IncludeType = "owner"
)

type Owner

type Owner struct {
	Data Data `json:"data"`
}

type Relationships

type Relationships struct {
	Owner Owner `json:"owner"`
}

type Response

type Response struct {
	*http.Response
}

Response is a Calendly response. This wraps the standard http.Response returned from Calendly.

type Transport

type Transport struct {
	// Base is the base RoundTripper used to make HTTP requests. If nil, then
	// http.DefaultTransport is used
	Base http.RoundTripper
	// contains filtered or unexported fields
}

Transport is an http.RoundTripper which makes Authenticated HTTP requests. It wraps a base RoundTripper and adds an API header using the token from the config.

Transport is a low-level component, most users should use NewClient to create an http.Client instead.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip authorizes the request by passing the API token to the request header

type UserAttributes

type UserAttributes struct {
	Name      string  `json:"name"`
	Slug      string  `json:"slug"`
	Email     string  `json:"email"`
	URL       string  `json:"url"`
	Timezone  string  `json:"timezone"`
	Avatar    *Avatar `json:"avatar,omitempty"`
	CreatedAt string  `json:"created_at"`
	UpdatedAt string  `json:"updated_at"`
}

type UsersService

type UsersService apiService

func (*UsersService) AboutMe

func (s *UsersService) AboutMe(ctx context.Context) (*AboutMe, *Response, error)

Use this endpoint to request basic information about yourself. This might be helpful if you're building functionality for multiple Calendly users.

type Webhook

type Webhook struct {
	Type       string             `json:"type"`
	ID         int64              `json:"id"`
	Attributes *WebhookAttributes `json:"attributes,omitempty"`
}

type WebhookAttributes

type WebhookAttributes struct {
	URL       string          `json:"url"`
	CreatedAt string          `json:"created_at"`
	State     string          `json:"state"`
	Events    []EventHookType `json:"events"`
}

type WebhooksOpts

type WebhooksOpts struct {
	Url    string
	Events []EventHookType
}

type WebhooksService

type WebhooksService apiService

func (*WebhooksService) Create

func (s *WebhooksService) Create(ctx context.Context, opt *WebhooksOpts) (*Webhook, *Response, error)

Calendly supports webhooks which allow you to receive Calendly appointment data in real-time at a specified URL when a Calendly event is scheduled or cancelled.

Specifically, you can subscribe to:

* Invitee Created Events (allowing you to receive notifications when a new Calendly event is created)
* Invitee Canceled Events (allowing you to receive notifications when a Calendly event is canceled)

Creating a Webhook Subscription will not immediately trigger a webhook. So once it's set up, create or cancel an invitee to test it out.

func (*WebhooksService) Delete

func (s *WebhooksService) Delete(ctx context.Context, id int64) (*Response, error)

Any of your Webhook Subscriptions can be deleted by ID using this endpoint.

func (*WebhooksService) GetByID

func (s *WebhooksService) GetByID(ctx context.Context, id int64) (*Webhook, *Response, error)

Any of your Webhook Subscriptions can be accessed by ID using this endpoint.

func (*WebhooksService) List

func (s *WebhooksService) List(ctx context.Context) ([]*Webhook, *Response, error)

You can view your current Webhook Subscriptions.

Using this endpoint will list up to the first 100 Webhook Subscriptions, and it will order active subscriptions first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL