-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathim_livechat_report_channel.go
124 lines (108 loc) · 5.03 KB
/
im_livechat_report_channel.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
package odoo
// ImLivechatReportChannel represents im_livechat.report.channel model.
type ImLivechatReportChannel struct {
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
ChannelId *Many2One `xmlrpc:"channel_id,omitempty"`
ChannelName *String `xmlrpc:"channel_name,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
Duration *Float `xmlrpc:"duration,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
LivechatChannelId *Many2One `xmlrpc:"livechat_channel_id,omitempty"`
NbrMessage *Int `xmlrpc:"nbr_message,omitempty"`
NbrSpeaker *Int `xmlrpc:"nbr_speaker,omitempty"`
PartnerId *Many2One `xmlrpc:"partner_id,omitempty"`
StartDate *Time `xmlrpc:"start_date,omitempty"`
StartDateHour *String `xmlrpc:"start_date_hour,omitempty"`
TechnicalName *String `xmlrpc:"technical_name,omitempty"`
Uuid *String `xmlrpc:"uuid,omitempty"`
}
// ImLivechatReportChannels represents array of im_livechat.report.channel model.
type ImLivechatReportChannels []ImLivechatReportChannel
// ImLivechatReportChannelModel is the odoo model name.
const ImLivechatReportChannelModel = "im_livechat.report.channel"
// Many2One convert ImLivechatReportChannel to *Many2One.
func (irc *ImLivechatReportChannel) Many2One() *Many2One {
return NewMany2One(irc.Id.Get(), "")
}
// CreateImLivechatReportChannel creates a new im_livechat.report.channel model and returns its id.
func (c *Client) CreateImLivechatReportChannel(irc *ImLivechatReportChannel) (int64, error) {
ids, err := c.CreateImLivechatReportChannels([]*ImLivechatReportChannel{irc})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateImLivechatReportChannels creates a new im_livechat.report.channel model and returns its id.
func (c *Client) CreateImLivechatReportChannels(ircs []*ImLivechatReportChannel) ([]int64, error) {
var vv []interface{}
for _, v := range ircs {
vv = append(vv, v)
}
return c.Create(ImLivechatReportChannelModel, vv, nil)
}
// UpdateImLivechatReportChannel updates an existing im_livechat.report.channel record.
func (c *Client) UpdateImLivechatReportChannel(irc *ImLivechatReportChannel) error {
return c.UpdateImLivechatReportChannels([]int64{irc.Id.Get()}, irc)
}
// UpdateImLivechatReportChannels updates existing im_livechat.report.channel records.
// All records (represented by ids) will be updated by irc values.
func (c *Client) UpdateImLivechatReportChannels(ids []int64, irc *ImLivechatReportChannel) error {
return c.Update(ImLivechatReportChannelModel, ids, irc, nil)
}
// DeleteImLivechatReportChannel deletes an existing im_livechat.report.channel record.
func (c *Client) DeleteImLivechatReportChannel(id int64) error {
return c.DeleteImLivechatReportChannels([]int64{id})
}
// DeleteImLivechatReportChannels deletes existing im_livechat.report.channel records.
func (c *Client) DeleteImLivechatReportChannels(ids []int64) error {
return c.Delete(ImLivechatReportChannelModel, ids)
}
// GetImLivechatReportChannel gets im_livechat.report.channel existing record.
func (c *Client) GetImLivechatReportChannel(id int64) (*ImLivechatReportChannel, error) {
ircs, err := c.GetImLivechatReportChannels([]int64{id})
if err != nil {
return nil, err
}
return &((*ircs)[0]), nil
}
// GetImLivechatReportChannels gets im_livechat.report.channel existing records.
func (c *Client) GetImLivechatReportChannels(ids []int64) (*ImLivechatReportChannels, error) {
ircs := &ImLivechatReportChannels{}
if err := c.Read(ImLivechatReportChannelModel, ids, nil, ircs); err != nil {
return nil, err
}
return ircs, nil
}
// FindImLivechatReportChannel finds im_livechat.report.channel record by querying it with criteria.
func (c *Client) FindImLivechatReportChannel(criteria *Criteria) (*ImLivechatReportChannel, error) {
ircs := &ImLivechatReportChannels{}
if err := c.SearchRead(ImLivechatReportChannelModel, criteria, NewOptions().Limit(1), ircs); err != nil {
return nil, err
}
return &((*ircs)[0]), nil
}
// FindImLivechatReportChannels finds im_livechat.report.channel records by querying it
// and filtering it with criteria and options.
func (c *Client) FindImLivechatReportChannels(criteria *Criteria, options *Options) (*ImLivechatReportChannels, error) {
ircs := &ImLivechatReportChannels{}
if err := c.SearchRead(ImLivechatReportChannelModel, criteria, options, ircs); err != nil {
return nil, err
}
return ircs, nil
}
// FindImLivechatReportChannelIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindImLivechatReportChannelIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(ImLivechatReportChannelModel, criteria, options)
}
// FindImLivechatReportChannelId finds record id by querying it with criteria.
func (c *Client) FindImLivechatReportChannelId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(ImLivechatReportChannelModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}