api

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: MIT Imports: 10 Imported by: 7

Documentation

Index

Constants

View Source
const (
	GET    = "GET"
	POST   = "POST"
	DELETE = "DELETE"
	PUT    = "PUT"
)

HTTP Methods

View Source
const (
	OK              = 200
	MUTIPLE_CHOICES = 300
	BAD_REQUEST     = 400
	NOT_FOUND       = 404
)

Status codes

View Source
const API_KEY_HEADER = "MC-Api-Key"

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient

type ApiClient interface {
	Do(request CcaRequest) (*CcaResponse, error)
	GetApiURL() string
	GetApiKey() string
}

func NewApiClient

func NewApiClient(apiURL, apiKey string) ApiClient

func NewInsecureApiClient

func NewInsecureApiClient(apiURL, apiKey string) ApiClient

type CcaApiClient

type CcaApiClient struct {
	// contains filtered or unexported fields
}

func (CcaApiClient) Do

func (ccaClient CcaApiClient) Do(request CcaRequest) (*CcaResponse, error)

Does the API call to server and returns a CCAResponse. Cloud.ca errors will be returned in the CCAResponse body, not in the error return value. The error return value is reserved for unexpected errors.

func (CcaApiClient) GetApiKey

func (ccaClient CcaApiClient) GetApiKey() string

func (CcaApiClient) GetApiURL

func (ccaClient CcaApiClient) GetApiURL() string

type CcaError

type CcaError struct {
	ErrorCode string                 `json:"errorCode"`
	Message   string                 `json:"message"`
	Context   map[string]interface{} `json:"context"`
}

An API error

type CcaErrorResponse

type CcaErrorResponse CcaResponse

An Api Response with errors

func (CcaErrorResponse) Error

func (errorResponse CcaErrorResponse) Error() string

type CcaRequest

type CcaRequest struct {
	Method   string
	Endpoint string
	Body     []byte
	Options  map[string]string
}

A request object

type CcaResponse

type CcaResponse struct {
	TaskId     string
	TaskStatus string
	StatusCode int
	Data       []byte
	Errors     []CcaError
	MetaData   map[string]interface{}
}

An Api Response

func NewCcaResponse

func NewCcaResponse(response *http.Response) (*CcaResponse, error)

func (CcaResponse) IsError

func (ccaResponse CcaResponse) IsError() bool

Returns true if API response has errors

Jump to

Keyboard shortcuts

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