-
Notifications
You must be signed in to change notification settings - Fork 0
/
partners.go
42 lines (34 loc) · 924 Bytes
/
partners.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
package statemanager
import (
"context"
"github.com/minskylab/tisp"
p "github.com/minskylab/tisp/repository"
)
func (db *StateManager) RegisterNewPartner(newClient tisp.NewPartnerInformation) (*p.Partner, error) {
var contacts *p.ContactCreateManyInput
if newClient.Email != nil {
contacts = &p.ContactCreateManyInput{
Create: []p.ContactCreateInput{
{
Type: p.ContactTypeEmail,
Value: *newClient.Email,
},
},
}
}
if newClient.Phone != nil {
if contacts == nil {
contacts = &p.ContactCreateManyInput{Create: []p.ContactCreateInput{}}
}
contacts.Create = append(contacts.Create, p.ContactCreateInput{
Type: p.ContactTypePhone,
Value: *newClient.Phone,
})
}
return db.client.CreatePartner(p.PartnerCreateInput{
CompanyName: newClient.CompanyName,
Selector: newClient.Selector,
Contacts: contacts,
Projects: nil,
}).Exec(context.Background())
}