This repository has been archived by the owner on May 23, 2019. It is now read-only.
forked from AnalyticalFlavorSystems/closeio-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opportunity.go
53 lines (49 loc) · 1.66 KB
/
opportunity.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 closeio
import "encoding/json"
type Opportunity struct {
Confidence int `json:"confidence,omitempty"`
Status string `json:"status,omitempty"`
StatusId string `json:"status,omitempty"`
Value int `json:"value,omitempty"`
ValuePeriod string `json:"value_period,omitempty"` //Monthly, annually, one-time
Note string `json:"note,omitempty"`
LeadId string `json:"lead_id"`
}
type OpportunityResp struct {
StatusId string `json:"status_id"`
StatusLabel string `json:"status_label"`
StatusType string `json:"status_type"`
DateWon string `json:"date_won"`
Confidence int `json:"confidence"`
Userid string `json:"user_id"`
ContactId string `json:"contact_id"`
UpdatedBy string `json:"updated_by"`
DateUpdated string `json:"date_updated"`
CreatedBy string `json:"created_by"`
LeadId string `json:"lead_id"`
Note string `json:"note"`
Value int `json:"value"`
DateCreated string `json:"date_created"`
OrganizationId string `json:"organization_id"`
LeadName string `json:"lead_name"`
UserName string `json:"user_name"`
Id string `json:"id"`
ValuePeriod string `json:"value_period"`
}
func (c *Closeio) CreateOpportunity(opportunity *Opportunity) (l *OpportunityResp, err error) {
data, err := marshal(opportunity)
if err != nil {
return nil, err
}
resp, err := request("opportunity/", "POST", c.Token, data)
if err != nil {
return nil, err
}
opportunityresp := OpportunityResp{}
decoder := json.NewDecoder(resp.Body)
err = decoder.Decode(&opportunityresp)
if err != nil {
return nil, err
}
return &opportunityresp, nil
}