-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from belong-inc/feature/deprecate-apikey-and-a…
…dd-private-app-description Add deprecated comments to SetAPIKey and replace usages
- Loading branch information
Showing
7 changed files
with
124 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ type ExampleContact struct { | |
} | ||
|
||
func ExampleContactServiceOp_Create() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
example := &ExampleContact{ | ||
email: "[email protected]", | ||
|
@@ -54,7 +54,7 @@ func ExampleContactServiceOp_Create() { | |
} | ||
|
||
func ExampleContactServiceOp_Update() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
example := &ExampleContact{ | ||
email: "[email protected]", | ||
|
@@ -92,7 +92,7 @@ func ExampleContactServiceOp_Update() { | |
} | ||
|
||
func ExampleContactServiceOp_Get() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
res, err := cli.CRM.Contact.Get("contact001", &hubspot.Contact{}, nil) | ||
if err != nil { | ||
|
@@ -113,7 +113,7 @@ func ExampleContactServiceOp_Get() { | |
} | ||
|
||
func ExampleContactServiceOp_AssociateAnotherObj() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
res, err := cli.CRM.Contact.AssociateAnotherObj("contact001", &hubspot.AssociationConfig{ | ||
ToObject: hubspot.ObjectTypeDeal, | ||
|
@@ -221,14 +221,50 @@ func ExampleDealServiceOp_Create_oauth() { | |
// // Output: | ||
} | ||
|
||
func ExampleDealServiceOp_Create_privateapp() { | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
example := &ExampleDeal{ | ||
amount: "1500.00", | ||
name: "Custom data integrations", | ||
stage: "presentation scheduled", | ||
ownerID: "910901", | ||
} | ||
|
||
deal := &hubspot.Deal{ | ||
Amount: hubspot.NewString(example.amount), | ||
DealName: hubspot.NewString(example.name), | ||
DealStage: hubspot.NewString(example.stage), | ||
DealOwnerID: hubspot.NewString(example.ownerID), | ||
PipeLine: hubspot.NewString("default"), | ||
} | ||
|
||
res, err := cli.CRM.Deal.Create(deal) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
r, ok := res.Properties.(*hubspot.Deal) | ||
if !ok { | ||
log.Fatal("unable to type assertion") | ||
} | ||
|
||
// use properties | ||
_ = r | ||
|
||
fmt.Println(res) | ||
|
||
// // Output: | ||
} | ||
|
||
type CustomDeal struct { | ||
hubspot.Deal | ||
CustomA string `json:"custom_a,omitempty"` | ||
CustomB string `json:"custom_b,omitempty"` | ||
} | ||
|
||
func ExampleDealServiceOp_Create_custom() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
example := &ExampleDeal{ | ||
amount: "1500.00", | ||
|
@@ -267,7 +303,7 @@ func ExampleDealServiceOp_Create_custom() { | |
} | ||
|
||
func ExampleDealServiceOp_Update() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
example := &ExampleDeal{ | ||
amount: "1500.00", | ||
|
@@ -303,7 +339,7 @@ func ExampleDealServiceOp_Update() { | |
} | ||
|
||
func ExampleDealServiceOp_Get() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
res, err := cli.CRM.Deal.Get("deal001", &hubspot.Deal{}, nil) | ||
if err != nil { | ||
|
@@ -324,7 +360,7 @@ func ExampleDealServiceOp_Get() { | |
} | ||
|
||
func ExampleDealServiceOp_Get_custom() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
res, err := cli.CRM.Deal.Get("deal001", &CustomDeal{}, &hubspot.RequestQueryOption{ | ||
CustomProperties: []string{ | ||
|
@@ -350,7 +386,7 @@ func ExampleDealServiceOp_Get_custom() { | |
} | ||
|
||
func ExampleDealServiceOp_AssociateAnotherObj() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
res, err := cli.CRM.Deal.AssociateAnotherObj("deal001", &hubspot.AssociationConfig{ | ||
ToObject: hubspot.ObjectTypeContact, | ||
|
@@ -375,7 +411,7 @@ func ExampleDealServiceOp_AssociateAnotherObj() { | |
} | ||
|
||
func ExampleMarketingEmailOp_GetStatistics() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
emailID := 0 // Set proper value. | ||
res, err := cli.Marketing.Email.GetStatistics(emailID, &hubspot.Statistics{}) | ||
|
@@ -397,7 +433,7 @@ func ExampleMarketingEmailOp_GetStatistics() { | |
} | ||
|
||
func ExampleMarketingEmailOp_ListStatistics() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
cli, _ := hubspot.NewClient(hubspot.SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN"))) | ||
|
||
statistics := make([]hubspot.Statistics, 0, 50) | ||
res, err := cli.Marketing.Email.ListStatistics(&hubspot.BulkStatisticsResponse{Objects: statistics}, &hubspot.BulkRequestQueryOption{Limit: 10}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.