@@ -236,16 +236,17 @@ func (s *DealService) Merge(ctx context.Context, id int, opt *DealsMergeOptions)
236236// DealsUpdateOptions specifices the optional parameters to the
237237// DealService.Update method.
238238type 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"`
239+ Title string `json:"title,omitempty"`
240+ Value string `json:"value,omitempty"`
241+ Currency string `json:"currency,omitempty"`
242+ UserID uint `json:"user_id,omitempty"`
243+ PersonID uint `json:"person_id,omitempty"`
244+ OrganizationID uint `json:"org_id,omitempty"`
245+ StageID uint `json:"stage_id,omitempty"`
246+ Status string `json:"status,omitempty"`
247+ LostReason string `json:"lost_reason,omitempty"`
248+ VisibleTo uint `json:"visible_to,omitempty"`
249+ RequirementAnalysis string `json:"56d3d40c37c0db60fff576ae73ba2fea0d58dc09"`
249250}
250251
251252// Update a deal.
@@ -331,3 +332,73 @@ func (s *DealService) DeleteAttachedProduct(ctx context.Context, dealID int, pro
331332
332333return s .client .Do (ctx , req , nil )
333334}
335+
336+ // DealCreateOptions specifices the optional parameters to the
337+ // DealsService.Create method.
338+ type DealCreateOptions struct {
339+ Title string `json:"title"`
340+ Value string `json:"value"`
341+ Currency string `json:"currency"`
342+ UserID uint `json:"user_id"`
343+ PersonID uint `json:"person_id"`
344+ OrgID uint `json:"org_id"`
345+ StageID uint `json:"stage_id"`
346+ Status string `json:"status"`
347+ Probability uint `json:"probability"`
348+ LostReason string `json:"lost_reason"`
349+ AddTime Timestamp `json:"add_time"`
350+ VisibleTo VisibleTo `json:"visible_to"`
351+ RequirementAnalysis string `json:"56d3d40c37c0db60fff576ae73ba2fea0d58dc09"`
352+ WantedStartTime Timestamp `json:"a3114acce61bb930180af173b395d76f42af8794"`
353+ }
354+
355+ // Create a new deal.
356+ //
357+ // Pipedrive API docs: https://developers.pipedrive.com/docs/api/v1/#!/Deals/post_deals
358+ func (s * DealService ) Create (ctx context.Context , opt * DealCreateOptions ) (* DealResponse , * Response , error ) {
359+ req , err := s .client .NewRequest (http .MethodPost , "/deals" , nil , struct {
360+ Title string `json:"title"`
361+ Value string `json:"value"`
362+ Currency string `json:"currency"`
363+ UserID uint `json:"user_id"`
364+ PersonID uint `json:"person_id"`
365+ OrgID uint `json:"org_id"`
366+ StageID uint `json:"stage_id"`
367+ Status string `json:"status"`
368+ Probability uint `json:"probability"`
369+ LostReason string `json:"lost_reason"`
370+ AddTime string `json:"add_time"`
371+ VisibleTo VisibleTo `json:"visible_to"`
372+ RequirementAnalysis string `json:"56d3d40c37c0db60fff576ae73ba2fea0d58dc09"`
373+ WantedStartTime string `json:"a3114acce61bb930180af173b395d76f42af8794"`
374+ }{
375+ opt .Title ,
376+ opt .Value ,
377+ opt .Currency ,
378+ opt .UserID ,
379+ opt .PersonID ,
380+ opt .OrgID ,
381+ opt .StageID ,
382+ opt .Status ,
383+ opt .Probability ,
384+ opt .LostReason ,
385+ opt .AddTime .FormatFull (),
386+ opt .VisibleTo ,
387+ opt .RequirementAnalysis ,
388+ opt .WantedStartTime .FormatFull (),
389+ })
390+
391+ if err != nil {
392+ return nil , nil , err
393+ }
394+
395+ var record * DealResponse
396+
397+ resp , err := s .client .Do (ctx , req , & record )
398+
399+ if err != nil {
400+ return nil , resp , err
401+ }
402+
403+ return record , resp , nil
404+ }
0 commit comments