Documentation
¶
Index ¶
- Constants
- func SetBaseDomain(domain string)
- type BodyMock
- type BusinessArea
- type Client
- func BuildClient() (*Client, error)
- func NewClient(sessionKey string, clientCode string, customCli *http.Client) (*Client, error)
- func NewClientFromCredentials(username, password, clientCode string, customCli *http.Client) (*Client, error)
- func NewClientWithCustomHeaders(customHTTPCli *http.Client, ...) (*Client, error)
- func NewClientWithURL(sessionKey, clientCode, partnerKey, url string, httpCli *http.Client, ...) (*Client, error)
- func NewUnvalidatedClient(sk, cc, partnerKey string, httpCli *http.Client) *Client
- func (c *Client) GetBusinessAreas(ctx context.Context, filters map[string]string) ([]BusinessArea, error)
- func (c *Client) GetCountries(ctx context.Context, filters map[string]string) ([]Country, error)
- func (c *Client) GetCurrencies(ctx context.Context, filters map[string]string) ([]Currency, error)
- func (c *Client) GetEmployees(ctx context.Context, filters map[string]string) ([]Employee, error)
- func (c *Client) GetEmployeesBulk(ctx context.Context, bulkFilters []map[string]interface{}, ...) (GetEmployeesResponseBulk, error)
- func (c *Client) GetEvents(ctx context.Context, filters map[string]string) ([]Event, error)
- func (c *Client) GetSession() (sessionKey string, err error)
- func (c *Client) GetUserOperationsLog(ctx context.Context, filters map[string]string) (*GetUserOperationsLogResponse, error)
- func (c *Client) GetUserRights(ctx context.Context, filters map[string]string) ([]UserRights, error)
- func (c *Client) InvalidateSession()
- func (c *Client) LogProcessingOfCustomerData(ctx context.Context, filters map[string]string) error
- func (c *Client) SaveEvent(ctx context.Context, filters map[string]string) (int, error)
- func (c *Client) SendParametersInRequestBody()
- type ClientBuilder
- type ClientMock
- type Country
- type Currency
- type DynamicSessionProvider
- type Employee
- type EmployeeProduct
- type EmployeeWarehouse
- type Event
- type GetBusinessAreasResponse
- type GetCountriesResponse
- type GetCurrenciesResponse
- type GetEmployeesResponse
- type GetEmployeesResponseBulk
- type GetEmployeesResponseBulkItem
- type GetEventsResponse
- type GetUserOperationsLogResponse
- type GetUserRightsResponse
- type InstallationRequest
- type InstallationResponse
- type Manager
- type OperationLog
- type PartnerClient
- type SaveEventResponse
- type UserRights
Constants ¶
const ( GetCountriesMethod = "getCountries" GetEmployeesMethod = "getEmployees" GetBusinessAreasMethod = "getBusinessAreas" GetCurrenciesMethod = "getCurrencies" GetUserOperationsLog = "getUserOperationsLog" GetUserRightsMethod = "getUserRights" SaveEventMethod = "saveEvent" GetEvents = "getEvents" )
Variables ¶
This section is empty.
Functions ¶
func SetBaseDomain ¶ added in v1.27.6
func SetBaseDomain(domain string)
SetBaseDomain sets the base domain used by the library for Erply API calls from erply.com to the specified domain
Types ¶
type BodyMock ¶ added in v0.3.0
BodyMock implements resp.Body
func NewFromStr ¶ added in v0.3.0
NewFromStr creates BodyMock from a string
func NewFromStruct ¶ added in v0.3.0
func NewFromStruct(input interface{}) *BodyMock
NewFromStruct creates BodyMock from a struct converted to json or string
type BusinessArea ¶ added in v0.1.0
type Client ¶ added in v0.4.0
type Client struct {
// Address requests
AddressProvider addresses.Manager
// Token requests
AuthProvider auth.Provider
// Company and Conf parameter requests
CompanyManager company.Manager
// Customers and suppliers requests
CustomerManager customers.Manager
// POS related requests
PosManager pos.Manager
// ListingDataProvider related requests
ProductManager products.Manager
// SalesDocuments, Payments, Projects, ShoppingCart, VatRates
SalesManager sales.Manager
// Warehouse requests
WarehouseManager warehouse.Manager
// Prices requests
PricesManager prices.Manager
// Documents requests
DocumentsManager documents.Manager
// Service Discovery
ServiceDiscoverer servicediscovery.ServiceDiscoverer
// contains filtered or unexported fields
}
func BuildClient ¶ added in v1.13.1
func NewClient ¶
NewClient Takes three params: sessionKey string obtained from credentials or jwt clientCode erply customer identification number and a custom http Client if needs to be overwritten. if nil will use default http client provided by the SDK The headersSetToEveryRequest function will be executed on every request and supplied with the request name. There is an example in the /examples of you to use it
func NewClientFromCredentials ¶ added in v1.22.0
func NewClientFromCredentials(username, password, clientCode string, customCli *http.Client) (*Client, error)
NewClientFromCredentials makes a verifyUser Erply API call and initializes the client struct
func NewClientWithCustomHeaders ¶ added in v1.3.1
func NewClientWithCustomHeaders(customHTTPCli *http.Client, headersSetToEveryRequest func(requestName string) url.Values) (*Client, error)
NewClientWithCustomHeaders enables defining the function that will set headers to every request by your own
func NewClientWithURL ¶ added in v1.7.3
func NewClientWithURL(sessionKey, clientCode, partnerKey, url string, httpCli *http.Client, headersSetToEveryRequest func(requestName string) url.Values) (*Client, error)
NewClientWithURL creates a new Client which can have a static URL which is not affected by clientCode nor the headersSetToEveryRequest function if set. If the url parameter is set to an empty string, the URL is still resolved normally. This allows creating clients which have a static url in your unit tests but function normally in the rest of your code
func NewUnvalidatedClient ¶ added in v0.4.0
NewUnvalidatedClient returns a new Client without validating any of the incoming parameters giving the developer more flexibility
func (*Client) GetBusinessAreas ¶ added in v0.4.0
func (c *Client) GetBusinessAreas(ctx context.Context, filters map[string]string) ([]BusinessArea, error)
GetBusinessAreas will list business areas according to specified filters.
func (*Client) GetCountries ¶ added in v0.4.0
GetCountries will list countries according to specified filters.
func (*Client) GetCurrencies ¶ added in v0.4.0
GetCurrencies will list currencies according to specified filters.
func (*Client) GetEmployees ¶ added in v0.4.0
GetEmployees will list employees according to specified filters.
func (*Client) GetEmployeesBulk ¶ added in v1.15.0
func (*Client) GetSession ¶ added in v1.15.0
func (*Client) GetUserOperationsLog ¶ added in v1.9.1
func (*Client) GetUserRights ¶ added in v0.4.0
func (c *Client) GetUserRights(ctx context.Context, filters map[string]string) ([]UserRights, error)
GetUserName from GetUserRights erply API request
func (*Client) InvalidateSession ¶ added in v1.15.0
func (c *Client) InvalidateSession()
func (*Client) LogProcessingOfCustomerData ¶ added in v0.4.0
func (*Client) SendParametersInRequestBody ¶ added in v1.22.0
func (c *Client) SendParametersInRequestBody()
SendParametersInRequestBody indicates to the client that the request should add the data payload in the request body instead of using the query parameters. Using the request body eliminates the query size limitations imposed by the maximum URL length
type ClientBuilder ¶ added in v1.15.0
type ClientBuilder struct {
UserName string // if set this will be used to fetch session key every time when session gets outdated
Password string // if set this will be used to fetch session key every time when session gets outdated
ClientCode string // required value for all requests
SessionKey string // if you don't set SessionProvider this key will be used to auth all requests
DefaultSessionLenSeconds int // set the length of dynamically created sessions
URL string // change the base API url
PartnerKey string // set the partner key
HttpCli *http.Client // you can adjust the http client transport options here
HeadersForEveryRequestFunc common.AuthFunc // this will set headers for all outgoing requests except for the session key
SessionProvider common.SessionProvider // custom session establishing logic, if not set DynamicSessionProvider is used which requires UserName and Password
}
func (ClientBuilder) Build ¶ added in v1.15.0
func (cb ClientBuilder) Build() *Client
type ClientMock ¶ added in v0.3.0
type ClientMock struct {
ErrToGive error
ResponseToGive *http.Response
Requests []*http.Request
Lock sync.Mutex
}
ClientMock mocks HttpClient interface
type DynamicSessionProvider ¶ added in v1.15.0
type DynamicSessionProvider struct {
ClientCode string
UserName string
Pass string
SessionKey string
SessionValidTill *time.Time
DefaultSessionLenSeconds int
Lock sync.Mutex
HTTPClient *http.Client
}
func (*DynamicSessionProvider) GetSession ¶ added in v1.15.0
func (dsp *DynamicSessionProvider) GetSession() (sessionKey string, err error)
func (*DynamicSessionProvider) Invalidate ¶ added in v1.15.0
func (dsp *DynamicSessionProvider) Invalidate()
type Employee ¶ added in v0.1.0
type Employee struct {
EmployeeID string `json:"employeeID"`
FullName string `json:"fullName"`
EmployeeName string `json:"employeeName"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Phone string `json:"phone"`
Mobile string `json:"mobile"`
Email string `json:"email"`
Fax string `json:"fax"`
Code string `json:"code"`
Gender string `json:"gender"`
UserID string `json:"userID"`
Username string `json:"username"`
UserGroupID string `json:"userGroupID"`
Warehouses []EmployeeWarehouse `json:"warehouses"`
PointsOfSale string `json:"pointsOfSale"`
ProductIDs []EmployeeProduct `json:"productIDs"`
Attributes []sharedCommon.ObjAttribute `json:"attributes"`
LastModified uint64 `json:"lastModified"`
LastModifiedByUserName string `json:"lastModifiedByUserName"`
// detail fileds
Skype string `json:"skype"`
Birthday string `json:"birthday"`
JobTitleID uint `json:"jobTitleID"`
JobTitleName string `json:"jobTitleName"`
Notes string `json:"notes"`
Added uint64 `json:"added"`
}
type EmployeeProduct ¶ added in v0.1.0
type EmployeeWarehouse ¶ added in v0.1.0
type EmployeeWarehouse struct {
Id uint `json:"id"`
}
type Event ¶ added in v1.8.0
type Event struct {
EventID string `json:"eventID"`
ID string `json:"id"`
Description string `json:"description"`
TypeID string `json:"typeID"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
CustomerID string `json:"customerID"`
ContactID string `json:"contactID"`
ProjectID string `json:"projectID"`
EmployeeID string `json:"employeeID"`
SubmitterID string `json:"submitterID"`
SupplierID string `json:"supplierID"`
SupplierName string `json:"supplierName"`
StatusID string `json:"statusID"`
ResourceID string `json:"resourceID"`
Notes string `json:"notes"`
LastModified string `json:"lastModified"`
ContactName string `json:"contactName"`
CustomerName string `json:"customerName"`
EmployeeName string `json:"employeeName"`
SubmitterName string `json:"submitterName"`
ProjectName string `json:"projectName"`
ResourceName string `json:"resourceName"`
StatusName string `json:"statusName"`
TypeName string `json:"typeName"`
Completed string `json:"completed"`
}
type GetBusinessAreasResponse ¶ added in v0.1.0
type GetBusinessAreasResponse struct {
Status sharedCommon.Status `json:"status"`
BusinessAreas []BusinessArea `json:"records"`
}
type GetCountriesResponse ¶ added in v0.1.0
type GetCountriesResponse struct {
Status sharedCommon.Status `json:"status"`
Countries []Country `json:"records"`
}
type GetCurrenciesResponse ¶ added in v0.1.0
type GetCurrenciesResponse struct {
Status sharedCommon.Status `json:"status"`
Currencies []Currency `json:"records"`
}
type GetEmployeesResponse ¶ added in v0.1.0
type GetEmployeesResponse struct {
Status sharedCommon.Status `json:"status"`
Employees []Employee `json:"records"`
}
type GetEmployeesResponseBulk ¶ added in v1.15.0
type GetEmployeesResponseBulk struct {
Status sharedCommon.Status `json:"status"`
BulkItems []GetEmployeesResponseBulkItem `json:"requests"`
}
type GetEmployeesResponseBulkItem ¶ added in v1.15.0
type GetEmployeesResponseBulkItem struct {
Status sharedCommon.StatusBulk `json:"status"`
Employees []Employee `json:"records"`
}
type GetEventsResponse ¶ added in v1.8.0
type GetEventsResponse struct {
Status sharedCommon.Status `json:"status"`
Events []Event `json:"records"`
}
type GetUserOperationsLogResponse ¶ added in v1.9.1
type GetUserOperationsLogResponse struct {
Status struct {
Request string `json:"request"`
RequestUnixTime int `json:"requestUnixTime"`
ResponseStatus string `json:"responseStatus"`
ErrorCode sharedCommon.ApiError `json:"errorCode"`
ErrorField string `json:"errorField"`
GenerationTime float64 `json:"generationTime"`
//the records total field is string type for this request
RecordsTotal string `json:"recordsTotal"`
RecordsInResponse int `json:"recordsInResponse"`
}
OperationLogs []OperationLog `json:"records"`
}
type GetUserRightsResponse ¶
type GetUserRightsResponse struct {
Status sharedCommon.Status `json:"status"`
Records []UserRights `json:"records"`
}
type InstallationRequest ¶ added in v0.1.0
type InstallationResponse ¶ added in v0.1.0
type InstallationResponse struct {
ClientCode int `json:"clientCode"`
UserName string `json:"username"`
Password string `json:"password"`
}
func CreateInstallation ¶ added in v0.1.0
type Manager ¶ added in v0.4.0
type Manager interface {
GetCountries(ctx context.Context, filters map[string]string) ([]Country, error)
GetUserRights(ctx context.Context, filters map[string]string) ([]UserRights, error)
GetEmployees(ctx context.Context, filters map[string]string) ([]Employee, error)
GetEmployeesBulk(ctx context.Context, bulkFilters []map[string]interface{}, baseFilters map[string]string) (GetEmployeesResponseBulk, error)
GetBusinessAreas(ctx context.Context, filters map[string]string) ([]BusinessArea, error)
GetCurrencies(ctx context.Context, filters map[string]string) ([]Currency, error)
SaveEvent(ctx context.Context, filters map[string]string) (int, error)
GetEvents(ctx context.Context, filters map[string]string) ([]Event, error)
LogProcessingOfCustomerData(ctx context.Context, filters map[string]string) error
GetUserOperationsLog(ctx context.Context, filters map[string]string) (*GetUserOperationsLogResponse, error)
}
this interface sums up the general requests here
type OperationLog ¶ added in v1.9.1
type PartnerClient ¶ added in v0.4.0
type PartnerClient struct {
Client *Client
PartnerTokenProvider auth.PartnerTokenProvider
}
func NewPartnerClient ¶ added in v0.4.0
func NewPartnerClient(sessionKey, clientCode, partnerKey string, customCli *http.Client) (*PartnerClient, error)
Deprecated
func NewPartnerClientFromCredentials ¶ added in v1.22.0
func NewPartnerClientFromCredentials(username, password, clientCode, partnerKey string, customCli *http.Client) (*PartnerClient, error)
type SaveEventResponse ¶ added in v1.8.0
type SaveEventResponse struct {
Status sharedCommon.Status
Records []struct {
EventID int `json:"eventID"`
} `json:"records"`
}
type UserRights ¶
type UserRights struct {
UserName string `json:"userName"`
}