-
Notifications
You must be signed in to change notification settings - Fork 29
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 #6 from belong-inc/feature/add-marketing-email-sta…
…tistics Add client of Marketing domain to handle marketing email statistics
- Loading branch information
Showing
15 changed files
with
1,049 additions
and
27 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2021 Belong Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/* | ||
Package hubspot is the root of packages used to access Hubspot APIs. | ||
This library is targeting HubSpot API v3. | ||
Docs are available in https://developers.hubspot.com/docs/api/overview. | ||
*/ | ||
package hubspot |
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 |
---|---|---|
|
@@ -3,8 +3,9 @@ package hubspot_test | |
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/belong-inc/go-hubspot" | ||
hubspot "github.com/belong-inc/go-hubspot" | ||
) | ||
|
||
type ExampleContact struct { | ||
|
@@ -16,7 +17,7 @@ type ExampleContact struct { | |
} | ||
|
||
func ExampleContactServiceOp_Create() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
example := &ExampleContact{ | ||
email: "[email protected]", | ||
|
@@ -53,7 +54,7 @@ func ExampleContactServiceOp_Create() { | |
} | ||
|
||
func ExampleContactServiceOp_Update() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
example := &ExampleContact{ | ||
email: "[email protected]", | ||
|
@@ -91,7 +92,7 @@ func ExampleContactServiceOp_Update() { | |
} | ||
|
||
func ExampleContactServiceOp_Get() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
res, err := cli.CRM.Contact.Get("contact001", &hubspot.Contact{}, nil) | ||
if err != nil { | ||
|
@@ -112,7 +113,7 @@ func ExampleContactServiceOp_Get() { | |
} | ||
|
||
func ExampleContactServiceOp_AssociateAnotherObj() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
res, err := cli.CRM.Contact.AssociateAnotherObj("contact001", &hubspot.AssociationConfig{ | ||
ToObject: hubspot.ObjectTypeDeal, | ||
|
@@ -144,7 +145,7 @@ type ExampleDeal struct { | |
} | ||
|
||
func ExampleDealServiceOp_Create_apikey() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
example := &ExampleDeal{ | ||
amount: "1500.00", | ||
|
@@ -227,7 +228,7 @@ type CustomDeal struct { | |
} | ||
|
||
func ExampleDealServiceOp_Create_custom() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
example := &ExampleDeal{ | ||
amount: "1500.00", | ||
|
@@ -266,7 +267,7 @@ func ExampleDealServiceOp_Create_custom() { | |
} | ||
|
||
func ExampleDealServiceOp_Update() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
example := &ExampleDeal{ | ||
amount: "1500.00", | ||
|
@@ -302,7 +303,7 @@ func ExampleDealServiceOp_Update() { | |
} | ||
|
||
func ExampleDealServiceOp_Get() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
res, err := cli.CRM.Deal.Get("deal001", &hubspot.Deal{}, nil) | ||
if err != nil { | ||
|
@@ -323,7 +324,7 @@ func ExampleDealServiceOp_Get() { | |
} | ||
|
||
func ExampleDealServiceOp_Get_custom() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
res, err := cli.CRM.Deal.Get("deal001", &CustomDeal{}, &hubspot.RequestQueryOption{ | ||
CustomProperties: []string{ | ||
|
@@ -349,7 +350,7 @@ func ExampleDealServiceOp_Get_custom() { | |
} | ||
|
||
func ExampleDealServiceOp_AssociateAnotherObj() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey("apikey")) | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
res, err := cli.CRM.Deal.AssociateAnotherObj("deal001", &hubspot.AssociationConfig{ | ||
ToObject: hubspot.ObjectTypeContact, | ||
|
@@ -372,3 +373,47 @@ func ExampleDealServiceOp_AssociateAnotherObj() { | |
|
||
// // Output: | ||
} | ||
|
||
func ExampleMarketingEmailOp_GetStatistics() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
emailID := 0 // Set proper value. | ||
res, err := cli.Marketing.Email.GetStatistics(emailID, &hubspot.Statistics{}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
r, ok := res.Properties.(*hubspot.Statistics) | ||
if !ok { | ||
log.Fatal("unable to type assertion") | ||
} | ||
|
||
// use properties | ||
_ = r | ||
|
||
fmt.Printf("%+v", r) | ||
|
||
// // Output: | ||
} | ||
|
||
func ExampleMarketingEmailOp_ListStatistics() { | ||
cli, _ := hubspot.NewClient(hubspot.SetAPIKey(os.Getenv("API_KEY"))) | ||
|
||
statistics := make([]hubspot.Statistics, 0, 50) | ||
res, err := cli.Marketing.Email.ListStatistics(&hubspot.BulkStatisticsResponse{Objects: statistics}, &hubspot.BulkRequestQueryOption{Limit: 10}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
r, ok := res.Properties.(*hubspot.BulkStatisticsResponse) | ||
if !ok { | ||
log.Fatal("unable to type assertion") | ||
} | ||
|
||
// use properties | ||
_ = r | ||
|
||
fmt.Printf("%+v", r) | ||
|
||
// // Output: | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2021 Belong Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/* | ||
Package legacy is the package for legacy APIs in Hubspot. | ||
Not all APIs of Hubspot have been migrated v3 therefore components for legacy API is put in this package. | ||
Docs are available in https://legacydocs.hubspot.com/docs/overview. | ||
*/ | ||
package legacy |
Oops, something went wrong.