netvisor

package module
v0.0.0-...-788378c Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddQueryParams

func AddQueryParams(params1, params2 url.Values) url.Values

func AddQueryParamsToRequest

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

func AddQueryParamsToURL

func AddQueryParamsToURL(url url.URL, params url.Values) url.URL

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the Client response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. Client 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.

func NewSchemaEncoder

func NewSchemaEncoder() *schema.Encoder

Types

type AccountingPathParams

type AccountingPathParams struct {
}

func (*AccountingPathParams) Params

func (p *AccountingPathParams) Params() map[string]string

type AccountingQueryParams

type AccountingQueryParams struct {
	// Finds vouchers that are added after given date (inclusive)
	StartDate DateTime `schema:"startdate"`
	// Finds vouchers that are added before given date(inclusive)
	EndDate DateTime `schema:"enddate"`
	// Finds vouchers which account number is equal or greater than given value
	AccountNumberStart int `schema:"accountnumberstart,omitemptyt"`
	// Finds vouchers which account number is equal or less than given value
	AccountNumberEnd int `schema:"accountnumberend,omitempty"`
	// Finds vouchers that are modified or added after given date
	ChangedSince DateTime `schema:"changedsince,omitempty"`
	// Finds vouchers that are modified after given date
	LastModifiedStart DateTime `schema:"lastmodifiedstart,omitempty"`
	// Finds vouchers that are modified before given date
	LastModifiedEnd DateTime `schema:"lastmodifiedend,omitempty"`
	// Returns the creator of the voucher (eg. user or system) 	1
	ShowGenerator bool `schema:"showgenerator,omitempty"`
	// Finds all, only valid or invalidated and deleted vouchers. Status -attribute shows which status voucher is: "valid", "invalidated" or "deleted" 	1 = All
	// 2 = Valid
	// 3 = Invalidated and deleted}
	VoucherStatus int `schema:"voucherstatus,omitempty"`
}

func (AccountingQueryParams) ToURLValues

func (p AccountingQueryParams) ToURLValues() (url.Values, error)

type AccountingRequest

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

func (*AccountingRequest) Do

func (*AccountingRequest) Method

func (r *AccountingRequest) Method() string

func (*AccountingRequest) NewResponseBody

func (r *AccountingRequest) NewResponseBody() *AccountingResponseBody

func (*AccountingRequest) PathParams

func (r *AccountingRequest) PathParams() *AccountingPathParams

func (*AccountingRequest) QueryParams

func (r *AccountingRequest) QueryParams() *AccountingQueryParams

func (*AccountingRequest) RequestBody

func (r *AccountingRequest) RequestBody() *AccountingRequestBody

func (*AccountingRequest) SetMethod

func (r *AccountingRequest) SetMethod(method string)

func (*AccountingRequest) SetRequestBody

func (r *AccountingRequest) SetRequestBody(body AccountingRequestBody)

func (*AccountingRequest) URL

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

type AccountingRequestBody

type AccountingRequestBody struct {
	XMLName xml.Name   `xml:"Root"`
	Voucher NewVoucher `xml:"Voucher"`
}

type AccountingResponseBody

type AccountingResponseBody struct {
	ResponseStatus ResponseStatus
	Vouchers       Vouchers `xml:"Vouchers>Voucher"`
}

type AccountingledgerPathParams

type AccountingledgerPathParams struct {
}

func (*AccountingledgerPathParams) Params

func (p *AccountingledgerPathParams) Params() map[string]string

type AccountingledgerQueryParams

type AccountingledgerQueryParams struct {
	// Finds vouchers that are added after given date (inclusive)
	StartDate DateTime `schema:"startdate"`
	// Finds vouchers that are added before given date(inclusive)
	EndDate DateTime `schema:"enddate"`
	// Finds vouchers which account number is equal or greater than given value
	AccountNumberStart int `schema:"accountnumberstart,omitemptyt"`
	// Finds vouchers which account number is equal or less than given value
	AccountNumberEnd int `schema:"accountnumberend,omitempty"`
	// Finds vouchers that are modified or added after given date
	ChangedSince DateTime `schema:"changedsince,omitempty"`
	// Finds vouchers that are modified after given date
	LastModifiedStart DateTime `schema:"lastmodifiedstart,omitempty"`
	// Finds vouchers that are modified before given date
	LastModifiedEnd DateTime `schema:"lastmodifiedend,omitempty"`
	// Returns the creator of the voucher (eg. user or system) 	1
	ShowGenerator bool `schema:"showgenerator,omitempty"`
	// Finds all, only valid or invalidated and deleted vouchers. Status -attribute shows which status voucher is: "valid", "invalidated" or "deleted" 	1 = All
	// 2 = Valid
	// 3 = Invalidated and deleted}
	VoucherStatus int `schema:"voucherstatus,omitempty"`
}

func (AccountingledgerQueryParams) ToURLValues

func (p AccountingledgerQueryParams) ToURLValues() (url.Values, error)

type AccountingledgerRequest

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

func (*AccountingledgerRequest) Do

func (*AccountingledgerRequest) Method

func (r *AccountingledgerRequest) Method() string

func (*AccountingledgerRequest) NewResponseBody

func (*AccountingledgerRequest) PathParams

func (*AccountingledgerRequest) QueryParams

func (*AccountingledgerRequest) RequestBody

func (*AccountingledgerRequest) SetMethod

func (r *AccountingledgerRequest) SetMethod(method string)

func (*AccountingledgerRequest) SetRequestBody

func (r *AccountingledgerRequest) SetRequestBody(body AccountingledgerRequestBody)

func (*AccountingledgerRequest) URL

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

type AccountingledgerRequestBody

type AccountingledgerRequestBody struct{}

type AccountingledgerResponseBody

type AccountingledgerResponseBody struct {
	ResponseStatus ResponseStatus
	Vouchers       Vouchers `xml:"Vouchers>Voucher"`
}

type BeforeRequestDoCallback

type BeforeRequestDoCallback func(*http.Client, *http.Request, interface{})

type Client

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

Client manages communication with Visma Netvisor

func NewClient

func NewClient(httpClient *http.Client, customerID, partnerID, organisationID, partnerKey, privateKey string) *Client

NewClient returns a new Visma Netvisor client

func (*Client) BaseURL

func (c *Client) BaseURL() url.URL

func (*Client) Charset

func (c *Client) Charset() string

func (*Client) CustomerID

func (c *Client) CustomerID() string

func (*Client) Debug

func (c *Client) Debug() bool

func (*Client) Do

func (c *Client) Do(req *http.Request, responseBody interface{}) (*http.Response, error)

Do sends an Client request and returns the Client response. The Client response is xml decoded and stored in the value pointed to by v, or returned as an error if an Client 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) GetEndpointURL

func (c *Client) GetEndpointURL(path string, pathParams PathParams) url.URL

func (*Client) InterfaceLanguage

func (c *Client) InterfaceLanguage() string

func (*Client) MediaType

func (c *Client) MediaType() string

func (*Client) NewAccountingPathParams

func (c *Client) NewAccountingPathParams() *AccountingPathParams

func (*Client) NewAccountingQueryParams

func (c *Client) NewAccountingQueryParams() *AccountingQueryParams

func (*Client) NewAccountingRequest

func (c *Client) NewAccountingRequest() AccountingRequest

func (*Client) NewAccountingRequestBody

func (s *Client) NewAccountingRequestBody() AccountingRequestBody

func (*Client) NewAccountingledgerPathParams

func (c *Client) NewAccountingledgerPathParams() *AccountingledgerPathParams

func (*Client) NewAccountingledgerQueryParams

func (c *Client) NewAccountingledgerQueryParams() *AccountingledgerQueryParams

func (*Client) NewAccountingledgerRequest

func (c *Client) NewAccountingledgerRequest() AccountingledgerRequest

func (*Client) NewAccountingledgerRequestBody

func (s *Client) NewAccountingledgerRequestBody() AccountingledgerRequestBody

func (*Client) NewCustomerlistPathParams

func (c *Client) NewCustomerlistPathParams() *CustomerlistPathParams

func (*Client) NewCustomerlistQueryParams

func (c *Client) NewCustomerlistQueryParams() *CustomerlistQueryParams

func (*Client) NewCustomerlistRequest

func (c *Client) NewCustomerlistRequest() CustomerlistRequest

func (*Client) NewCustomerlistRequestBody

func (s *Client) NewCustomerlistRequestBody() CustomerlistRequestBody

func (*Client) NewDimensionlistPathParams

func (c *Client) NewDimensionlistPathParams() *DimensionlistPathParams

func (*Client) NewDimensionlistQueryParams

func (c *Client) NewDimensionlistQueryParams() *DimensionlistQueryParams

func (*Client) NewDimensionlistRequest

func (c *Client) NewDimensionlistRequest() DimensionlistRequest

func (*Client) NewDimensionlistRequestBody

func (s *Client) NewDimensionlistRequestBody() DimensionlistRequestBody

func (*Client) NewMAC

func (c *Client) NewMAC(req *http.Request) string

func (*Client) NewRequest

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

func (*Client) NewTimestamp

func (c *Client) NewTimestamp() string

func (*Client) NewTransactionID

func (c *Client) NewTransactionID() string

func (*Client) OrganisationID

func (c *Client) OrganisationID() string

func (*Client) PartnerID

func (c *Client) PartnerID() string

func (*Client) PartnerKey

func (c *Client) PartnerKey() string

func (*Client) PrivateKey

func (c *Client) PrivateKey() string

func (*Client) Sender

func (c *Client) Sender() string

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL url.URL)

func (*Client) SetBeforeRequestDo

func (c *Client) SetBeforeRequestDo(fun BeforeRequestDoCallback)

func (*Client) SetCharset

func (c *Client) SetCharset(charset string)

func (*Client) SetCustomerID

func (c *Client) SetCustomerID(customerID string)

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool)

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(client *http.Client)

func (*Client) SetInterfaceLanguage

func (c *Client) SetInterfaceLanguage(interfaceLanguage string)

func (*Client) SetMediaType

func (c *Client) SetMediaType(mediaType string)

func (*Client) SetOrganisationID

func (c *Client) SetOrganisationID(organisationID string)

func (*Client) SetPartnerID

func (c *Client) SetPartnerID(partnerID string)

func (*Client) SetPartnerKey

func (c *Client) SetPartnerKey(partnerKey string)

func (*Client) SetPrivateKey

func (c *Client) SetPrivateKey(privateKey string)

func (*Client) SetSender

func (c *Client) SetSender(sender string)

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(userAgent string)

func (*Client) UserAgent

func (c *Client) UserAgent() string

type Customer

type Customer struct {
	Netvisorkey            string `xml:"Netvisorkey"`
	Name                   string `xml:"Name"`
	Code                   string `xml:"Code"`
	OrganisationIdentifier string `xml:"OrganisationIdentifier"`
	URI                    string `xml:"Uri"`
}

type CustomerlistPathParams

type CustomerlistPathParams struct {
}

func (*CustomerlistPathParams) Params

func (p *CustomerlistPathParams) Params() map[string]string

type CustomerlistQueryParams

type CustomerlistQueryParams struct {
	// Filters result list with given keyword. Match is searched from following
	// fields: Name, Customer Code, Organization identifier, CoName
	Keyword string `schema:"keyword,omitempty"`
	// Filters result to contain only customers having change after given date, date in format YYYY-MM-DD
	ChangedSince DateTime `schema:"changedsince,omitempty"`
}

func (CustomerlistQueryParams) ToURLValues

func (p CustomerlistQueryParams) ToURLValues() (url.Values, error)

type CustomerlistRequest

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

func (*CustomerlistRequest) Do

func (*CustomerlistRequest) Method

func (r *CustomerlistRequest) Method() string

func (*CustomerlistRequest) NewResponseBody

func (r *CustomerlistRequest) NewResponseBody() *CustomerlistResponseBody

func (*CustomerlistRequest) PathParams

func (*CustomerlistRequest) QueryParams

func (r *CustomerlistRequest) QueryParams() *CustomerlistQueryParams

func (*CustomerlistRequest) RequestBody

func (r *CustomerlistRequest) RequestBody() *CustomerlistRequestBody

func (*CustomerlistRequest) SetMethod

func (r *CustomerlistRequest) SetMethod(method string)

func (*CustomerlistRequest) SetRequestBody

func (r *CustomerlistRequest) SetRequestBody(body CustomerlistRequestBody)

func (*CustomerlistRequest) URL

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

type CustomerlistRequestBody

type CustomerlistRequestBody struct{}

type CustomerlistResponseBody

type CustomerlistResponseBody struct {
	ResponseStatus ResponseStatus
	Customers      Customers `xml:"Customerlist>Customer"`
}

type Customers

type Customers []Customer

type DateTime

type DateTime struct {
	time.Time
	Layout string
}

func (DateTime) IsEmpty

func (d DateTime) IsEmpty() bool

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

func (DateTime) MarshalSchema

func (d DateTime) MarshalSchema() string

func (DateTime) MarshalXML

func (d DateTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*DateTime) UnmarshalXML

func (d *DateTime) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error

type DimensionlistPathParams

type DimensionlistPathParams struct {
}

func (*DimensionlistPathParams) Params

func (p *DimensionlistPathParams) Params() map[string]string

type DimensionlistQueryParams

type DimensionlistQueryParams struct{}

func (DimensionlistQueryParams) ToURLValues

func (p DimensionlistQueryParams) ToURLValues() (url.Values, error)

type DimensionlistRequest

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

func (*DimensionlistRequest) Do

func (*DimensionlistRequest) Method

func (r *DimensionlistRequest) Method() string

func (*DimensionlistRequest) NewResponseBody

func (r *DimensionlistRequest) NewResponseBody() *DimensionlistResponseBody

func (*DimensionlistRequest) PathParams

func (*DimensionlistRequest) QueryParams

func (*DimensionlistRequest) RequestBody

func (*DimensionlistRequest) SetMethod

func (r *DimensionlistRequest) SetMethod(method string)

func (*DimensionlistRequest) SetRequestBody

func (r *DimensionlistRequest) SetRequestBody(body DimensionlistRequestBody)

func (*DimensionlistRequest) URL

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

type DimensionlistRequestBody

type DimensionlistRequestBody struct{}

type DimensionlistResponseBody

type DimensionlistResponseBody struct {
}

type ErrorResponse

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

	Errors []error
}

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type NewVoucher

type NewVoucher struct {
	CalculationMode string `xml:"CalculationMode"` // net
	VoucherDate     struct {
		Text   string `xml:",chardata"`   // 2017-09-11
		Format string `xml:"format,attr"` // ansi
	} `xml:"VoucherDate"`
	Description        string                `xml:"Description"`  // Testiyritys Oy lasku 1
	VoucherClass       string                `xml:"VoucherClass"` // Myyntilasku
	VoucherLine        NewVoucherLines       `xml:"VoucherLine"`
	VoucherAttachments NewVoucherAttachments `xml:"VoucherAttachments"`
}

type NewVoucherAttachment

type NewVoucherAttachment struct {
	MimeType              string `xml:"MimeType"`              // Application/Pdf
	AttachmentDescription string `xml:"AttachmentDescription"` // Testiliite
	FileName              string `xml:"FileName"`              // liite.pdf
	DocumentData          string `xml:"DocumentData"`          // JVBERi0xLjQNJeLjz9MNCjYgM...
}

type NewVoucherAttachments

type NewVoucherAttachments []NewVoucherAttachment

type NewVoucherLine

type NewVoucherLine struct {
	LineSum struct {
		Text float64 `xml:",chardata"` // -10000.00, -5000, 20000
		Type string  `xml:"type,attr"`
	} `xml:"LineSum"`
	Description   string `xml:"Description"`   // Testiyritys Oy, lasku 1, ...
	AccountNumber string `xml:"AccountNumber"` // 3000, 2939, 1701
	VatPercent    struct {
		Text    string `xml:",chardata"` // 24, 0, 0
		Vatcode string `xml:"vatcode,attr"`
	} `xml:"VatPercent"`
	Dimension struct {
		DimensionName string `xml:"DimensionName"` // Project
		DimensionItem string `xml:"DimensionItem"` // IIHF
	} `xml:"Dimension"`
}

type NewVoucherLines

type NewVoucherLines []NewVoucherLine

type PathParams

type PathParams interface {
	Params() map[string]string
}

type RequestCompletionCallback

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

RequestCompletionCallback defines the type of the request callback function

type ResponseStatus

type ResponseStatus struct {
	Status    string
	TimeStamp DateTime
}

type SchemaMarshaler

type SchemaMarshaler interface {
	MarshalSchema() string
}

type ToURLValues

type ToURLValues interface {
	ToURLValues() (url.Values, error)
}

type Voucher

type Voucher struct {
	Status                  string   `xml:"Status,attr"`
	NetvisorKey             string   `xml:"NetvisorKey"`
	VoucherDate             DateTime `xml:"VoucherDate"`
	VoucherNumber           string   `xml:"VoucherNumber"`
	VoucherDescription      string   `xml:"VoucherDescription"`
	VoucherClass            string   `xml:"VoucherClass"`
	LinkedSourceNetvisorKey struct {
		Text string `xml:",chardata"`
		Type string `xml:"type,attr"`
	} `xml:"LinkedSourceNetvisorKey"`
	VoucherNetvisorURI string       `xml:"VoucherNetvisorURI"`
	VoucherLine        VoucherLines `xml:"VoucherLine"`
}

type VoucherLine

type VoucherLine struct {
	NetvisorKey   int     `xml:"NetvisorKey"`
	LineSum       float64 `xml:"LineSum"`
	Description   string  `xml:"Description"`
	AccountNumber string  `xml:"AccountNumber"`
	VatPercent    float64 `xml:"VatPercent"`
	VatCode       string  `xml:"VatCode"`
}

type VoucherLines

type VoucherLines []VoucherLine

type Vouchers

type Vouchers []Voucher

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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