-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathestimate_create.go
53 lines (39 loc) · 1.28 KB
/
estimate_create.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
package gofastbill
import (
"errors"
)
type EstimateCreate_Request struct {
CUSTOMER_ID string `xml:"CUSTOMER_ID,omitempty" json:"CUSTOMER_ID,omitempty"`
ITEMS []ITEMS `xml:"ITEMS,omitempty" json:"ITEMS,omitempty"` //
TEMPLATE_NAME string `xml:"TEMPLATE_NAME,omitempty" json:"TEMPLATE_NAME,omitempty"` //Vorlagenname
TEMPLATE_HASH string `xml:"TEMPLATE_HASH,omitempty" json:"TEMPLATE_HASH,omitempty"` //Eindeutige ID des Templates
}
//CREATE Estimate
//FILTER => All fields from Struct: gofastbill.EstimateCreate_Request
//Required:
//CUSTOMER_ID, ITEMS[]
//RESPONSE: STATUS, ESTIMATE_ID
func (s *Initialization) Estimate_create(req EstimateCreate_Request) (*FBAPI, error) {
var fastbillbody string
var r FBAPI
r.SERVICE = "estimate.create"
if req.CUSTOMER_ID == "" {
return nil, errors.New(s.Typ + ": CUSTOMER_ID must not be empty")
}
if len(req.ITEMS) <= 0 {
return nil, errors.New(s.Typ + ": ITEMS must not be empty")
}
r.DATA.CUSTOMER_ID = req.CUSTOMER_ID
r.DATA.ITEMS = req.ITEMS
r.DATA.TEMPLATE_NAME = req.TEMPLATE_NAME
r.DATA.TEMPLATE_HASH = req.TEMPLATE_HASH
fastbillbody, err := s.GenerateRequest(r)
if err != nil {
return nil, err
}
resp, err := s.FastbillRequest(fastbillbody)
if err != nil {
return nil, err
}
return resp, nil
}