saas

package
v0.4.86 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	Self() API
	Base() *BaseAPI
	Init() error
	Close() error
	GetProp(key string) string
	SetProp(key string, val string)
	GetBaseURL() string
	Call(name string, params map[string]interface{}, body []byte) (respBytes []byte, err error)
	Stream(name string, params map[string]interface{}, body []byte) (ds *iop.Datastream, err error)
	LoadEndpoints() (err error)
}

API is the Base interface for apis

func NewAPI

func NewAPI(ap APIProvider, props ...string) (api API, err error)

NewAPI creates an API

func NewAPIClientContext

func NewAPIClientContext(ctx context.Context, ap APIProvider, props ...string) (api API, err error)

NewAPI creates an API Client with provided context

func NewAPIClientFromConn

func NewAPIClientFromConn(c connection.Connection) (api API, err error)

NewAPIClientFromConn provides an API client with the given Dataconn URL

func NewAPIClientFromConnContext

func NewAPIClientFromConnContext(ctx context.Context, c connection.Connection) (api API, err error)

NewAPIClientFromConnContext provides an API client with the given Dataconn URL

type APIEndpoint

type APIEndpoint struct {
	API       API                    `yaml:"-"`
	Name      string                 `yaml:"-"`
	ColumnMap map[string]*iop.Column `yaml:"-"`
	URL       string                 `yaml:"-"`
	Endpoint  string                 `yaml:"endpoint,omitempty"`
	Method    string                 `yaml:"method,omitempty"`
	RecordsJP string                 `yaml:"records_jp,omitempty"`
	NextJP    string                 `yaml:"next_jp,omitempty"`
	RespType  string                 `yaml:"resp_type,omitempty"`
	Headers   map[string]string      `yaml:"headers"`
	Ds        *iop.Datastream        `yaml:"-"`
	// contains filtered or unexported fields
}

APIEndpoint represents an api endpoint

func (*APIEndpoint) NextURL

func (aos *APIEndpoint) NextURL(data interface{}, resp *http.Response) string

NextURL determines and sets the next URL in a stream call

func (*APIEndpoint) Request

func (aos *APIEndpoint) Request(url string, body []byte) (resp *http.Response, respBytes []byte, err error)

Request performs a request

func (*APIEndpoint) Unmarshal

func (aos *APIEndpoint) Unmarshal(body []byte, data *interface{}) (err error)

Unmarshal parses the response based on the response type

type APIProvider

type APIProvider string
const (
	// DigitalOcean is APIProvider
	DigitalOcean APIProvider = "digitalocean"
	Git          APIProvider = "git"
	Github       APIProvider = "github"
	SurveyMonkey APIProvider = "surveymonkey"
	Hubspot      APIProvider = "hubspot"
)

func (APIProvider) String

func (ap APIProvider) String() string

String returns the db type string

type BaseAPI

type BaseAPI struct {
	API
	Provider      APIProvider
	Endpoints     map[string]*APIEndpoint
	BaseURL       string
	User          string
	Key           string
	Context       g.Context
	FlattenNested bool
	DefHeaders    map[string]string
	DefParams     map[string]string
	// contains filtered or unexported fields
}

BaseAPI is the base api struct

func (*BaseAPI) Base

func (api *BaseAPI) Base() *BaseAPI

Base return the base API instance

func (*BaseAPI) Call

func (api *BaseAPI) Call(name string, params map[string]interface{}, body []byte) (respBytes []byte, err error)

Call calls an endpoint by name with the provided params and body

func (*BaseAPI) GetBaseURL

func (api *BaseAPI) GetBaseURL() string

GetBaseURL return the base URL

func (*BaseAPI) GetProp

func (api *BaseAPI) GetProp(key string) string

GetProp returns the value of a property

func (*BaseAPI) Init

func (api *BaseAPI) Init() (err error)

Init initializes the base API

func (*BaseAPI) LoadEndpoints

func (api *BaseAPI) LoadEndpoints() (err error)

LoadEndpoints loads the endpoints from a yaml file

func (*BaseAPI) Props added in v0.3.101

func (api *BaseAPI) Props() map[string]string

Props returns a copy of the properties map

func (*BaseAPI) SetProp

func (api *BaseAPI) SetProp(key string, val string)

SetProp sets the value of a property

func (*BaseAPI) Stream

func (api *BaseAPI) Stream(name string, params map[string]interface{}, body []byte) (ds *iop.Datastream, err error)

Stream returns a stream of the endpoint

type DigitalOceanAPI

type DigitalOceanAPI struct {
	BaseAPI
	// contains filtered or unexported fields
}

DigitalOceanAPI is DO's api https://developers.digitalocean.com/documentation/v2

func (*DigitalOceanAPI) Init

func (api *DigitalOceanAPI) Init() (err error)

Init initializes

type GitAPI

type GitAPI struct {
	BaseAPI
}

GitAPI is for interacting with a Git Repo for cloning, fetching

func (*GitAPI) Init

func (api *GitAPI) Init() (err error)

Init initializes

type GithubAPI

type GithubAPI struct {
	BaseAPI
}

GithubAPI is github's api https://developer.github.com/v3/

func (*GithubAPI) Init

func (api *GithubAPI) Init() (err error)

Init initializes

type HubspotAPI

type HubspotAPI struct {
	BaseAPI
}

HubspotAPI is for hubspot https://developers.hubspot.com/docs/api/overview

func (*HubspotAPI) Init

func (api *HubspotAPI) Init() (err error)

Init initializes

type SurveyMonkeyAPI

type SurveyMonkeyAPI struct {
	BaseAPI
}

SurveyMonkeyAPI is for surveymonkey https://developer.surveymonkey.com/api/v3

func (*SurveyMonkeyAPI) Init

func (api *SurveyMonkeyAPI) Init() (err error)

Init initializes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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