Skip to content

Commit 8350139

Browse files
authored
Merge pull request #2 from kben/master
fix person structures
2 parents e143fc6 + 9419247 commit 8350139

File tree

6 files changed

+338
-122
lines changed

6 files changed

+338
-122
lines changed

pipedrive/activities.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,17 @@ func (s *ActivitiesService) Create(ctx context.Context, opt *ActivitiesCreateOpt
137137
// ActivitiesCreateOptions specifices the optional parameters to the
138138
// ActivitiesService.Update method.
139139
type ActivitiesCreateOptions struct {
140-
Subject string `url:"subject,omitempty"`
141-
Done uint8 `url:"done,omitempty"`
142-
Type string `url:"type,omitempty"`
143-
DueDate string `url:"due_date,omitempty"`
144-
DueTime string `url:"due_time,omitempty"`
145-
Duration string `url:"duration,omitempty"`
146-
UserID uint `url:"user_id,omitempty"`
147-
DealID uint `url:"user_id,omitempty"`
148-
PersonID uint `url:"person_id,omitempty"`
149-
Participants interface{} `url:"participants,omitempty"`
150-
OrgID uint `url:"org_id,omitempty"`
140+
Subject string `json:"subject,omitempty"`
141+
Done uint8 `json:"done,omitempty"`
142+
Type string `json:"type,omitempty"`
143+
DueDate string `json:"due_date,omitempty"`
144+
DueTime string `json:"due_time,omitempty"`
145+
Duration string `json:"duration,omitempty"`
146+
UserID uint `json:"user_id,omitempty"`
147+
DealID uint `json:"user_id,omitempty"`
148+
PersonID uint `json:"person_id,omitempty"`
149+
Participants interface{} `json:"participants,omitempty"`
150+
OrgID uint `json:"org_id,omitempty"`
151151
}
152152

153153
// Update an activity

pipedrive/deals.go

Lines changed: 174 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -53,58 +53,74 @@ type Deal struct {
5353
CcEmail string `json:"cc_email"`
5454
Value int `json:"value"`
5555
} `json:"org_id"`
56-
StageID int `json:"stage_id"`
57-
Title string `json:"title"`
58-
Value int `json:"value"`
59-
Currency string `json:"currency"`
60-
AddTime string `json:"add_time"`
61-
UpdateTime string `json:"update_time"`
62-
StageChangeTime string `json:"stage_change_time"`
63-
Active bool `json:"active"`
64-
Deleted bool `json:"deleted"`
65-
Status string `json:"status"`
66-
Probability interface{} `json:"probability"`
67-
NextActivityDate interface{} `json:"next_activity_date"`
68-
NextActivityTime interface{} `json:"next_activity_time"`
69-
NextActivityID interface{} `json:"next_activity_id"`
70-
LastActivityID int `json:"last_activity_id"`
71-
LastActivityDate string `json:"last_activity_date"`
72-
LostReason string `json:"lost_reason"`
73-
VisibleTo string `json:"visible_to"`
74-
CloseTime string `json:"close_time"`
75-
PipelineID int `json:"pipeline_id"`
76-
WonTime interface{} `json:"won_time"`
77-
FirstWonTime interface{} `json:"first_won_time"`
78-
LostTime string `json:"lost_time"`
79-
ProductsCount int `json:"products_count"`
80-
FilesCount int `json:"files_count"`
81-
NotesCount int `json:"notes_count"`
82-
FollowersCount int `json:"followers_count"`
83-
EmailMessagesCount int `json:"email_messages_count"`
84-
ActivitiesCount int `json:"activities_count"`
85-
DoneActivitiesCount int `json:"done_activities_count"`
86-
UndoneActivitiesCount int `json:"undone_activities_count"`
87-
ReferenceActivitiesCount int `json:"reference_activities_count"`
88-
ParticipantsCount int `json:"participants_count"`
89-
ExpectedCloseDate interface{} `json:"expected_close_date"`
90-
LastIncomingMailTime interface{} `json:"last_incoming_mail_time"`
91-
LastOutgoingMailTime interface{} `json:"last_outgoing_mail_time"`
92-
Eight02Aa45Ecc05F31Fcebe8B706510389F56B7A041 interface{} `json:"802aa45ecc05f31fcebe8b706510389f56b7a041"`
93-
StageOrderNr int `json:"stage_order_nr"`
94-
PersonName string `json:"person_name"`
95-
OrgName string `json:"org_name"`
96-
NextActivitySubject interface{} `json:"next_activity_subject"`
97-
NextActivityType interface{} `json:"next_activity_type"`
98-
NextActivityDuration interface{} `json:"next_activity_duration"`
99-
NextActivityNote interface{} `json:"next_activity_note"`
100-
FormattedValue string `json:"formatted_value"`
101-
RottenTime interface{} `json:"rotten_time"`
102-
WeightedValue int `json:"weighted_value"`
103-
FormattedWeightedValue string `json:"formatted_weighted_value"`
104-
OwnerName string `json:"owner_name"`
105-
CcEmail string `json:"cc_email"`
106-
OrgHidden bool `json:"org_hidden"`
107-
PersonHidden bool `json:"person_hidden"`
56+
StageID int `json:"stage_id"`
57+
Title string `json:"title"`
58+
Value float64 `json:"value"`
59+
Currency string `json:"currency"`
60+
AddTime string `json:"add_time"`
61+
UpdateTime string `json:"update_time"`
62+
StageChangeTime string `json:"stage_change_time"`
63+
Active bool `json:"active"`
64+
Deleted bool `json:"deleted"`
65+
Status string `json:"status"`
66+
Probability interface{} `json:"probability"`
67+
NextActivityDate interface{} `json:"next_activity_date"`
68+
NextActivityTime interface{} `json:"next_activity_time"`
69+
NextActivityID interface{} `json:"next_activity_id"`
70+
LastActivityID int `json:"last_activity_id"`
71+
LastActivityDate string `json:"last_activity_date"`
72+
LostReason string `json:"lost_reason"`
73+
VisibleTo string `json:"visible_to"`
74+
CloseTime string `json:"close_time"`
75+
PipelineID int `json:"pipeline_id"`
76+
WonTime interface{} `json:"won_time"`
77+
FirstWonTime interface{} `json:"first_won_time"`
78+
LostTime string `json:"lost_time"`
79+
ProductsCount int `json:"products_count"`
80+
FilesCount int `json:"files_count"`
81+
NotesCount int `json:"notes_count"`
82+
FollowersCount int `json:"followers_count"`
83+
EmailMessagesCount int `json:"email_messages_count"`
84+
ActivitiesCount int `json:"activities_count"`
85+
DoneActivitiesCount int `json:"done_activities_count"`
86+
UndoneActivitiesCount int `json:"undone_activities_count"`
87+
ReferenceActivitiesCount int `json:"reference_activities_count"`
88+
ParticipantsCount int `json:"participants_count"`
89+
ExpectedCloseDate interface{} `json:"expected_close_date"`
90+
LastIncomingMailTime interface{} `json:"last_incoming_mail_time"`
91+
LastOutgoingMailTime interface{} `json:"last_outgoing_mail_time"`
92+
StageOrderNr int `json:"stage_order_nr"`
93+
PersonName string `json:"person_name"`
94+
OrgName string `json:"org_name"`
95+
NextActivitySubject interface{} `json:"next_activity_subject"`
96+
NextActivityType interface{} `json:"next_activity_type"`
97+
NextActivityDuration interface{} `json:"next_activity_duration"`
98+
NextActivityNote interface{} `json:"next_activity_note"`
99+
FormattedValue string `json:"formatted_value"`
100+
RottenTime interface{} `json:"rotten_time"`
101+
WeightedValue int `json:"weighted_value"`
102+
FormattedWeightedValue string `json:"formatted_weighted_value"`
103+
OwnerName string `json:"owner_name"`
104+
CcEmail string `json:"cc_email"`
105+
OrgHidden bool `json:"org_hidden"`
106+
PersonHidden bool `json:"person_hidden"`
107+
OfflineCommunication string `json:"b556c5618b88cd3d33f99b996b5b2fdbc8ba3c7e"`
108+
ServicePrice float64 `json:"6906ddfb72aaef6810b35703de142db0f435c314"`
109+
AgencyInCharge struct {
110+
Name string `json:"name"`
111+
PeopleCount int `json:"people_count"`
112+
OwnerID int `json:"owner_id"`
113+
Address interface{} `json:"address"`
114+
CcEmail string `json:"cc_email"`
115+
Value float32 `json:"value"`
116+
} `json:"eb2a2df8945c29118a01d324c58fbf6cef7bfd43"`
117+
WantedStartTime string `json:"a3114acce61bb930180af173b395d76f42af8794"`
118+
RequirementAnalysis string `json:"56d3d40c37c0db60fff576ae73ba2fea0d58dc09"`
119+
DepartureCurrentCT string `json:"ffd2a712d781417ef17a33b3540d3ecd8d945f76"`
120+
ArrivalNextCT string `json:"f5bb67b24aec5f9733be8b3402bf1fe5b1ac6ed6"`
121+
LeadSource uint `json:"5d4fbabc9b032aeb3df515d9c66994d6892ee062"`
122+
TemporaryLink string `json:"4fe88fad67d8dcbc17d18d9ee1faac55122249fd"`
123+
RideCosts string `json:"31443a48d1405182dfccac9bf378bbe8216ffc9a"`
108124
}
109125

110126
func (d Deal) String() string {
@@ -170,11 +186,26 @@ func (s *DealService) Find(ctx context.Context, term string) (*DealsResponse, *R
170186
return record, resp, nil
171187
}
172188

173-
// List all deals.
189+
type FilterOptions struct {
190+
FilterID int `url:"filter_id"`
191+
Status string `url:"status"`
192+
}
193+
194+
// List deals.
174195
//
175196
// Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Deals/get_deals
176-
func (s *DealService) List(ctx context.Context) (*DealsResponse, *Response, error) {
177-
req, err := s.client.NewRequest(http.MethodGet, "/deals", nil, nil)
197+
func (s *DealService) List(ctx context.Context, filterID int) (*DealsResponse, *Response, error) {
198+
var err error
199+
var req *http.Request
200+
if filterID > 0 {
201+
req, err = s.client.NewRequest(http.MethodGet, "/deals", &FilterOptions{
202+
FilterID: filterID,
203+
Status: "all_not_deleted",
204+
}, nil)
205+
} else {
206+
req, err = s.client.NewRequest(http.MethodGet, "/deals", nil, nil)
207+
208+
}
178209

179210
if err != nil {
180211
return nil, nil, err
@@ -236,16 +267,18 @@ func (s *DealService) Merge(ctx context.Context, id int, opt *DealsMergeOptions)
236267
// DealsUpdateOptions specifices the optional parameters to the
237268
// DealService.Update method.
238269
type DealsUpdateOptions struct {
239-
Title string `url:"title,omitempty"`
240-
Value string `url:"value,omitempty"`
241-
Currency string `url:"currency,omitempty"`
242-
UserID uint `url:"user_id,omitempty"`
243-
PersonID uint `url:"person_id,omitempty"`
244-
OrganizationID uint `url:"org_id,omitempty"`
245-
StageID uint `url:"stage_id,omitempty"`
246-
Status string `url:"status,omitempty"`
247-
LostReason string `url:"lost_reason,omitempty"`
248-
VisibleTo uint `url:"visible_to,omitempty"`
270+
Title string `json:"title,omitempty"`
271+
Value string `json:"value,omitempty"`
272+
Currency string `json:"currency,omitempty"`
273+
UserID uint `json:"user_id,omitempty"`
274+
PersonID uint `json:"person_id,omitempty"`
275+
OrganizationID uint `json:"org_id,omitempty"`
276+
StageID uint `json:"stage_id,omitempty"`
277+
Status string `json:"status,omitempty"`
278+
LostReason string `json:"lost_reason,omitempty"`
279+
VisibleTo uint `json:"visible_to,omitempty"`
280+
RequirementAnalysis string `json:"56d3d40c37c0db60fff576ae73ba2fea0d58dc09,omitempty"`
281+
TemporaryLink string `json:"4fe88fad67d8dcbc17d18d9ee1faac55122249fd,omitempty"`
249282
}
250283

251284
// Update a deal.
@@ -331,3 +364,79 @@ func (s *DealService) DeleteAttachedProduct(ctx context.Context, dealID int, pro
331364

332365
return s.client.Do(ctx, req, nil)
333366
}
367+
368+
// DealCreateOptions specifices the optional parameters to the
369+
// DealsService.Create method.
370+
type DealCreateOptions struct {
371+
Title string `json:"title"`
372+
Value string `json:"value"`
373+
Currency string `json:"currency"`
374+
UserID uint `json:"user_id"`
375+
PersonID uint `json:"person_id"`
376+
OrgID uint `json:"org_id"`
377+
StageID uint `json:"stage_id"`
378+
Status string `json:"status"`
379+
Probability uint `json:"probability"`
380+
LostReason string `json:"lost_reason"`
381+
AddTime Timestamp `json:"add_time"`
382+
VisibleTo VisibleTo `json:"visible_to"`
383+
RequirementAnalysis string `json:"56d3d40c37c0db60fff576ae73ba2fea0d58dc09"`
384+
WantedStartTime Timestamp `json:"a3114acce61bb930180af173b395d76f42af8794"`
385+
TemporaryLink string `json:"4fe88fad67d8dcbc17d18d9ee1faac55122249fd,omitempty"`
386+
LeadSource uint `json:"5d4fbabc9b032aeb3df515d9c66994d6892ee062,omitempty"`
387+
}
388+
389+
// Create a new deal.
390+
//
391+
// Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Deals/post_deals
392+
func (s *DealService) Create(ctx context.Context, opt *DealCreateOptions) (*DealResponse, *Response, error) {
393+
req, err := s.client.NewRequest(http.MethodPost, "/deals", nil, struct {
394+
Title string `json:"title"`
395+
Value string `json:"value"`
396+
Currency string `json:"currency"`
397+
UserID uint `json:"user_id"`
398+
PersonID uint `json:"person_id"`
399+
OrgID uint `json:"org_id"`
400+
StageID uint `json:"stage_id"`
401+
Status string `json:"status"`
402+
Probability uint `json:"probability"`
403+
LostReason string `json:"lost_reason"`
404+
AddTime string `json:"add_time"`
405+
VisibleTo VisibleTo `json:"visible_to"`
406+
RequirementAnalysis string `json:"56d3d40c37c0db60fff576ae73ba2fea0d58dc09"`
407+
WantedStartTime string `json:"a3114acce61bb930180af173b395d76f42af8794"`
408+
TemporaryLink string `json:"4fe88fad67d8dcbc17d18d9ee1faac55122249fd,omitempty"`
409+
LeadSource uint `json:"5d4fbabc9b032aeb3df515d9c66994d6892ee062,omitempty"`
410+
}{
411+
opt.Title,
412+
opt.Value,
413+
opt.Currency,
414+
opt.UserID,
415+
opt.PersonID,
416+
opt.OrgID,
417+
opt.StageID,
418+
opt.Status,
419+
opt.Probability,
420+
opt.LostReason,
421+
opt.AddTime.FormatFull(),
422+
opt.VisibleTo,
423+
opt.RequirementAnalysis,
424+
opt.WantedStartTime.Format(),
425+
opt.TemporaryLink,
426+
opt.LeadSource,
427+
})
428+
429+
if err != nil {
430+
return nil, nil, err
431+
}
432+
433+
var record *DealResponse
434+
435+
resp, err := s.client.Do(ctx, req, &record)
436+
437+
if err != nil {
438+
return nil, resp, err
439+
}
440+
441+
return record, resp, nil
442+
}

pipedrive/notes.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ func (s *NotesService) GetByID(ctx context.Context, id int) (*NoteResponse, *Res
9292
// NoteCreateOptions specifices the optional parameters to the
9393
// NotesService.Create method.
9494
type NoteCreateOptions struct {
95-
DealID uint `url:"deal_id"`
96-
Content string `url:"content"`
97-
PersonID uint `url:"person_id"`
98-
OrgID uint `url:"org_id"`
99-
PinnedToDealFlag uint8 `url:"pinned_to_deal_flag"`
100-
PinnedToOrganizationFlag uint8 `url:"pinned_to_organization_flag"`
101-
PinnedToPersonFlag uint8 `url:"pinned_to_person_flag"`
95+
DealID uint `json:"deal_id"`
96+
Content string `json:"content"`
97+
PersonID uint `json:"person_id"`
98+
OrgID uint `json:"org_id"`
99+
PinnedToDealFlag uint8 `json:"pinned_to_deal_flag"`
100+
PinnedToOrganizationFlag uint8 `json:"pinned_to_organization_flag"`
101+
PinnedToPersonFlag uint8 `json:"pinned_to_person_flag"`
102102
}
103103

104104
// Create a note.

0 commit comments

Comments
 (0)