-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.go
130 lines (115 loc) · 4.06 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package exact
import (
"net/http"
"net/url"
"github.com/tim-online/go-exactonline/crm"
"github.com/tim-online/go-exactonline/document"
"github.com/tim-online/go-exactonline/financial"
"github.com/tim-online/go-exactonline/financialtransaction"
"github.com/tim-online/go-exactonline/general"
"github.com/tim-online/go-exactonline/generaljournalentry"
"github.com/tim-online/go-exactonline/hrm"
"github.com/tim-online/go-exactonline/logistics"
"github.com/tim-online/go-exactonline/payroll"
"github.com/tim-online/go-exactonline/project"
"github.com/tim-online/go-exactonline/purchaseentry"
"github.com/tim-online/go-exactonline/purchaseorder"
"github.com/tim-online/go-exactonline/rest"
"github.com/tim-online/go-exactonline/sales"
"github.com/tim-online/go-exactonline/salesentry"
"github.com/tim-online/go-exactonline/salesinvoice"
"github.com/tim-online/go-exactonline/salesorder"
"github.com/tim-online/go-exactonline/system"
"github.com/tim-online/go-exactonline/vat"
)
const (
DefaultBaseURL = "https://start.exactonline.nl/api"
libraryVersion = "0.0.1"
userAgent = "go-exactonline/" + libraryVersion
)
// Client manages communication with Exact Online API
type Client struct {
// REST client used to communicate with the API.
rest.Client
// Services
// Accountancy *Accountancy
// Activities *Activities
// Assets *Assets
// Budget *Budget
// Bulk *Bulk
// Cashflow *Cashflow
// ContinuousMonitoring *ContinuousMonitoring
CRM *crm.Service
Document *document.Service
Financial *financial.Service
FinancialTransaction *financialtransaction.Service
General *general.Service
GeneralJournalEntry *generaljournalentry.Service
HRM *hrm.Service
// Inventory *Inventory
Logistics *logistics.Service
// Mailbox *Mailbox
// Manufacturing *Manufacturing
// OpeningBalance *OpeningBalance
Payroll *payroll.Service
Project *project.Service
PurchaseEntry *purchaseentry.Service
PurchaseOrder *purchaseorder.Service
Sales *sales.Service
SalesEntry *salesentry.Service
SalesInvoice *salesinvoice.Service
SalesOrder *salesorder.Service
// Subscription *Subscription
System *system.Service
// Users *Users
VAT *vat.Service
// Workflow *Workflow
}
// NewClient returns a new Exact Online API client
func NewClient(httpClient *http.Client, divisionID int) *Client {
if httpClient == nil {
httpClient = http.DefaultClient
}
c := &Client{
Client: *rest.New(httpClient),
}
// set default options
baseURL, _ := url.Parse(DefaultBaseURL)
c.SetBaseURL(baseURL)
c.SetDivisionID(divisionID)
c.SetUserAgent(userAgent)
c.SetDebug(false)
c.CRM = crm.NewService(&c.Client)
c.Document = document.NewService(&c.Client)
c.Financial = financial.NewService(&c.Client)
c.FinancialTransaction = financialtransaction.NewService(&c.Client)
c.General = general.NewService(&c.Client)
c.GeneralJournalEntry = generaljournalentry.NewService(&c.Client)
c.HRM = hrm.NewService(&c.Client)
c.Logistics = logistics.NewService(&c.Client)
c.Payroll = payroll.NewService(&c.Client)
c.Project = project.NewService(&c.Client)
c.PurchaseEntry = purchaseentry.NewService(&c.Client)
c.PurchaseOrder = purchaseorder.NewService(&c.Client)
c.Sales = sales.NewService(&c.Client)
c.SalesEntry = salesentry.NewService(&c.Client)
c.SalesInvoice = salesinvoice.NewService(&c.Client)
c.SalesOrder = salesorder.NewService(&c.Client)
c.System = system.NewService(&c.Client)
c.VAT = vat.NewService(&c.Client)
return c
}
func (c *Client) SetDebug(debug bool) {
c.Client.SetDebug(debug)
}
func (c *Client) SetDisallowUnknownFields(disallowUnknownFields bool) {
c.Client.SetDisallowUnknownFields(disallowUnknownFields)
}
func (c *Client) SetBaseURL(baseURL *url.URL) {
// set base url for use in http client
c.Client.SetBaseURL(baseURL)
}
func (c *Client) SetDivisionID(divisionID int) {
// set base url for use in http client
c.Client.SetDivisionID(divisionID)
}