afas

package module
v0.0.0-...-c6fd671 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BaseURL = url.URL{
		Scheme: "https",
		Host:   "{account_number}.rest.afas.online",
		Path:   "/profitrestservices/",
	}
)

Functions

func AddQueryParamsToRequest

func AddQueryParamsToRequest(requestParams interface{}, req *http.Request, skipEmpty bool) error

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 XML response body that maps to ErrorResponse. Any other response body will be silently ignored.

Types

type API

type API struct {

	// Services used for communicating with the API
	Meta      *MetaService
	Connector *ConnectorService
	// contains filtered or unexported fields
}

API manages communication with AFAS API

func NewAPI

func NewAPI(httpClient *http.Client, accountNumber string, token string) *API

NewAPI returns a new AFAS API client

func (*API) AccountNumber

func (api *API) AccountNumber() string

func (*API) BaseURL

func (api *API) BaseURL() url.URL

func (*API) Charset

func (api *API) Charset() string

func (*API) Debug

func (api *API) Debug() bool

func (*API) Do

func (api *API) Do(req *http.Request, responseBody interface{}) (*http.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 (*API) GetEndpointURL

func (api *API) GetEndpointURL(p string) url.URL

func (*API) MediaType

func (api *API) MediaType() string

func (*API) NewRequest

func (api *API) NewRequest(ctx context.Context, method string, URL url.URL, body interface{}) (*http.Request, error)

func (*API) SetAccountNumber

func (api *API) SetAccountNumber(accountNumber string)

func (*API) SetBaseURL

func (api *API) SetBaseURL(baseURL url.URL)

func (*API) SetCharset

func (api *API) SetCharset(charset string)

func (*API) SetDebug

func (api *API) SetDebug(debug bool)

func (*API) SetMediaType

func (api *API) SetMediaType(mediaType string)

func (*API) SetToken

func (api *API) SetToken(token string)

func (*API) SetUserAgent

func (api *API) SetUserAgent(userAgent string)

func (*API) Token

func (api *API) Token() string

func (*API) UserAgent

func (api *API) UserAgent() string

type ConnectorInsertQueryParams

type ConnectorInsertQueryParams struct {
}

type ConnectorInsertRequest

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

func (*ConnectorInsertRequest) Do

func (*ConnectorInsertRequest) Method

func (r *ConnectorInsertRequest) Method() string

func (*ConnectorInsertRequest) QueryParams

func (*ConnectorInsertRequest) RequestBody

func (*ConnectorInsertRequest) ResponseBody

func (*ConnectorInsertRequest) SetMethod

func (r *ConnectorInsertRequest) SetMethod(method string)

func (*ConnectorInsertRequest) SetRequestBody

func (r *ConnectorInsertRequest) SetRequestBody(body ConnectorInsertRequestBody)

func (*ConnectorInsertRequest) URL

func (r *ConnectorInsertRequest) URL() url.URL

func (*ConnectorInsertRequest) URLParams

type ConnectorInsertRequestBody

type ConnectorInsertRequestBody interface{}

type ConnectorInsertResponseBody

type ConnectorInsertResponseBody struct {
	Results json.RawMessage `json:"results"`
}

{"results":{"FiEntryPar":{"UnId":"4","EnNo":"54605"}}}

type ConnectorInsertURLParams

type ConnectorInsertURLParams struct {
	ConnectorID string
	SubElement  string
}

type ConnectorListQueryParams

type ConnectorListQueryParams struct {
	Skip            int    `schema:"skip,omitempty"`
	Take            int    `schema:"take,omitempty"`
	OrderByFieldIDs string `schema:"orderbyfieldids,omitempty"`
	FilterFieldIDs  string `schema:"filterfieldids,omitempty"`
	FilterValues    string `schema:"filtervalues,omitempty"`
	OperatorTypes   string `schema:"operatortypes,omitempty"`
}

type ConnectorListRequest

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

func (*ConnectorListRequest) Do

func (*ConnectorListRequest) Method

func (r *ConnectorListRequest) Method() string

func (*ConnectorListRequest) QueryParams

func (*ConnectorListRequest) RequestBody

func (r *ConnectorListRequest) RequestBody() *EmptyRequestBody

func (*ConnectorListRequest) ResponseBody

func (*ConnectorListRequest) SetMethod

func (r *ConnectorListRequest) SetMethod(method string)

func (*ConnectorListRequest) SetRequestBody

func (r *ConnectorListRequest) SetRequestBody(body EmptyRequestBody)

func (*ConnectorListRequest) SetResponseBody

func (r *ConnectorListRequest) SetResponseBody(body *ConnectorListResponseBody)

func (*ConnectorListRequest) URL

func (r *ConnectorListRequest) URL() url.URL

func (*ConnectorListRequest) URLParams

type ConnectorListResponseBody

type ConnectorListResponseBody struct {
	Skip int         `json:"skip"`
	Take int         `json:"take"`
	Rows interface{} `json:"rows"`
}

type ConnectorListURLParams

type ConnectorListURLParams struct {
	ConnectorID string
	SubElement  string
}

type ConnectorService

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

func NewConnectorService

func NewConnectorService(api *API) *ConnectorService

func (*ConnectorService) NewInsertRequest

func (s *ConnectorService) NewInsertRequest() ConnectorInsertRequest

func (*ConnectorService) NewInsertRequestBody

func (s *ConnectorService) NewInsertRequestBody() ConnectorInsertRequestBody

func (*ConnectorService) NewInsertResponseBody

func (s *ConnectorService) NewInsertResponseBody() *ConnectorInsertResponseBody

func (*ConnectorService) NewListRequest

func (s *ConnectorService) NewListRequest() ConnectorListRequest

func (*ConnectorService) NewListRequestBody

func (s *ConnectorService) NewListRequestBody() EmptyRequestBody

func (*ConnectorService) NewListResponseBody

func (s *ConnectorService) NewListResponseBody() *ConnectorListResponseBody

func (*ConnectorService) NewUpdateRequest

func (s *ConnectorService) NewUpdateRequest() ConnectorUpdateRequest

func (*ConnectorService) NewUpdateRequestBody

func (s *ConnectorService) NewUpdateRequestBody() ConnectorUpdateRequestBody

func (*ConnectorService) NewUpdateResponseBody

func (s *ConnectorService) NewUpdateResponseBody() *ConnectorUpdateResponseBody

type ConnectorUpdateQueryParams

type ConnectorUpdateQueryParams struct {
}

type ConnectorUpdateRequest

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

func (*ConnectorUpdateRequest) Do

func (*ConnectorUpdateRequest) Method

func (r *ConnectorUpdateRequest) Method() string

func (*ConnectorUpdateRequest) QueryParams

func (*ConnectorUpdateRequest) RequestBody

func (*ConnectorUpdateRequest) ResponseBody

func (*ConnectorUpdateRequest) SetMethod

func (r *ConnectorUpdateRequest) SetMethod(method string)

func (*ConnectorUpdateRequest) SetRequestBody

func (r *ConnectorUpdateRequest) SetRequestBody(body ConnectorUpdateRequestBody)

func (*ConnectorUpdateRequest) URL

func (r *ConnectorUpdateRequest) URL() url.URL

func (*ConnectorUpdateRequest) URLParams

type ConnectorUpdateRequestBody

type ConnectorUpdateRequestBody interface{}

type ConnectorUpdateResponseBody

type ConnectorUpdateResponseBody struct {
	Results json.RawMessage `json:"results"`
}

{"results":{"FiEntryPar":{"UnId":"4","EnNo":"54605"}}}

type ConnectorUpdateURLParams

type ConnectorUpdateURLParams struct {
	ConnectorID string
	SubElement  string
}

type Element

type Element struct {
	DBID    string                 `json:"@DbId,omitempty"`
	Fields  map[string]interface{} `json:"Fields,omitempty"`
	Objects map[string]interface{} `json:"Objects,omitempty"`
}

func (Element) MarshalJSON

func (e Element) MarshalJSON() ([]byte, error)

type Elements

type Elements []Element

func (Elements) MarshalJSON

func (e Elements) MarshalJSON() ([]byte, error)

type EmptyRequestBody

type EmptyRequestBody struct{}

func (EmptyRequestBody) MarshalJSON

func (r EmptyRequestBody) MarshalJSON() ([]byte, error)

type ErrorResponse1

type ErrorResponse1 struct {
	// HTTP response that caused this error
	Response *http.Response `json:"-"`

	Message string `json:"message"`
}
{
	"message":"Invalid json"
}

func (ErrorResponse1) Error

func (r ErrorResponse1) Error() string

type ErrorResponse2

type ErrorResponse2 struct {
	// HTTP response that caused this error
	Response *http.Response `json:"-"`

	ErrorNumber        int    `json:"errorNumber"`
	ExternalMessage    string `json:"externalMessage"`
	ProfitLogReference string `json:"profitLogReference"`
}
{
  "errorNumber": -2147180996,
  "externalMessage": "General message: Deze UpdateConnector wordt niet ondersteund of de gebruiker is niet geautoriseerd.",
  "profitLogReference": "923A9F6F4D5875E0D7B96982F6E4E0D2"
}

func (ErrorResponse2) Error

func (r ErrorResponse2) Error() string

type GetConnector

type GetConnector struct {
	ID          string `json:"id"`
	Description string `json:"description"`
}

type GetConnectorField

type GetConnectorField struct {
	ID              string `json:"id"`
	FieldID         string `json:"fieldId"`
	DataType        string `json:"dataType"`
	Label           string `json:"label"`
	Length          int    `json:"length"`
	ControlType     int    `json:"controlType"`
	Decimals        int    `json:"decimals"`
	DecimalsFieldID string `json:"decimalsFieldId"`
}

type GetConnectors

type GetConnectors []GetConnector

type MetaDescribeGetConnectorQueryParams

type MetaDescribeGetConnectorQueryParams struct {
}

type MetaDescribeGetConnectorRequest

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

func (*MetaDescribeGetConnectorRequest) Do

func (*MetaDescribeGetConnectorRequest) Method

func (*MetaDescribeGetConnectorRequest) NewResponseBody

func (*MetaDescribeGetConnectorRequest) QueryParams

func (*MetaDescribeGetConnectorRequest) RequestBody

func (*MetaDescribeGetConnectorRequest) SetMethod

func (r *MetaDescribeGetConnectorRequest) SetMethod(method string)

func (*MetaDescribeGetConnectorRequest) SetRequestBody

func (r *MetaDescribeGetConnectorRequest) SetRequestBody(body EmptyRequestBody)

func (*MetaDescribeGetConnectorRequest) URL

func (*MetaDescribeGetConnectorRequest) URLParams

type MetaDescribeGetConnectorResponseBody

type MetaDescribeGetConnectorResponseBody struct {
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Fields      []GetConnectorField `json:"fields"`
}

type MetaDescribeGetConnectorURLParams

type MetaDescribeGetConnectorURLParams struct {
	ConnectorID string
}

type MetaDescribeUpdateConnectorQueryParams

type MetaDescribeUpdateConnectorQueryParams struct {
}

type MetaDescribeUpdateConnectorRequest

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

func (*MetaDescribeUpdateConnectorRequest) Do

func (*MetaDescribeUpdateConnectorRequest) Method

func (*MetaDescribeUpdateConnectorRequest) NewResponseBody

func (*MetaDescribeUpdateConnectorRequest) QueryParams

func (*MetaDescribeUpdateConnectorRequest) SetMethod

func (r *MetaDescribeUpdateConnectorRequest) SetMethod(method string)

func (*MetaDescribeUpdateConnectorRequest) URL

func (*MetaDescribeUpdateConnectorRequest) URLParams

type MetaDescribeUpdateConnectorResponseBody

type MetaDescribeUpdateConnectorResponseBody struct {
	ID          string `json:"id"`
	Description string `json:"description"`

	UpdateConnectorObject
}

type MetaDescribeUpdateConnectorURLParams

type MetaDescribeUpdateConnectorURLParams struct {
	ConnectorID string
}

type MetaListConnectorsQueryParams

type MetaListConnectorsQueryParams struct {
}

type MetaListConnectorsRequest

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

func (*MetaListConnectorsRequest) Do

func (*MetaListConnectorsRequest) Method

func (r *MetaListConnectorsRequest) Method() string

func (*MetaListConnectorsRequest) NewResponseBody

func (*MetaListConnectorsRequest) SetMethod

func (r *MetaListConnectorsRequest) SetMethod(method string)

func (*MetaListConnectorsRequest) URL

type MetaListConnectorsResponseBody

type MetaListConnectorsResponseBody struct {
	UpdateConnectors UpdateConnectors `json:"updateConnectors"`
	GetConnectors    GetConnectors    `json:"getConnectors"`
}

type MetaListConnectorsURLParams

type MetaListConnectorsURLParams struct {
}

type MetaService

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

func NewMetaService

func NewMetaService(api *API) *MetaService

func (*MetaService) NewDescribeGetConnectorRequest

func (s *MetaService) NewDescribeGetConnectorRequest() MetaDescribeGetConnectorRequest

func (*MetaService) NewDescribeUpdateConnectorRequest

func (s *MetaService) NewDescribeUpdateConnectorRequest() MetaDescribeUpdateConnectorRequest

func (*MetaService) NewListConnectorsRequest

func (s *MetaService) NewListConnectorsRequest() MetaListConnectorsRequest

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

type SchemaMarshaler

type SchemaMarshaler interface {
	MarshalSchema() string
}

type ToURLValues

type ToURLValues interface {
	ToURLValues() url.Values
}

type UpdateConnector

type UpdateConnector struct {
	ID          string `json:"id"`
	Description string `json:"description"`
}

type UpdateConnectorField

type UpdateConnectorField struct {
	FieldID        string `json:"fieldId"`
	PrimaryKey     bool   `json:"primaryKey"`
	DataType       string `json:"dataType"`
	Label          string `json:"label"`
	Mandatory      bool   `json:"mandatory"`
	Length         int    `json:"length"`
	Decimals       int    `json:"decimals"`
	DecimalFieldID string `json:"decimalFieldId"`
	NotZero        bool   `json:"notzero"`
	ControlType    int    `json:"controlType"`
	Values         []struct {
		ID          string `json:"id"`
		Description string `json:"description"`
	} `json:"values"`
}

type UpdateConnectorObject

type UpdateConnectorObject struct {
	Name    string                  `json:"name"`
	Fields  []UpdateConnectorField  `json:"fields"`
	Objects []UpdateConnectorObject `json:"objects"`
}

type UpdateConnectors

type UpdateConnectors []UpdateConnector

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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