Skip to content

Commit

Permalink
Merge pull request #18 from shenzhencenter/develop
Browse files Browse the repository at this point in the history
feat: delete examples
  • Loading branch information
xnkjj authored Aug 21, 2023
2 parents 1db9af0 + e50b682 commit 3ec3caf
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 350 deletions.
86 changes: 55 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,30 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/shenzhencenter/google-ads-pb)](https://goreportcard.com/report/github.com/shenzhencenter/google-ads-pb)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

This is a Golang client library for accessing the [Google Ads API](https://developers.google.com/google-ads/api/docs/start). Most of the code is generated from the [googleapis](https://github.com/googleapis/googleapis/tree/master/google/ads/googleads) repository. We only make some modifications and examples. Detailed informations can be found on [workflows/generator](https://github.com/shenzhencenter/google-ads-pb/blob/main/.github/workflows/generator.yml).
This is a Golang client library for accessing the [Google Ads API](https://developers.google.com/google-ads/api/docs/start). The code is fully generated from the [googleapis](https://github.com/googleapis/googleapis/tree/master/google/ads/googleads) repository. Detailed informations can be found on [workflows/generator](https://github.com/shenzhencenter/google-ads-pb/blob/main/.github/workflows/generator.yml).

Please note that this is not an official project. But we think it is very low risk because it is a very mature project, and we have been using it in production for more than two years. The only thing to note is the [sunset schedule](https://developers.google.com/google-ads/api/docs/sunset-dates) of the Google Ads API.

## Features

- Fully support for Google Ads API.
- Code is fully generated from the official googleapis repository.
- Support for GRPC calls.
- Support for HTTP calls by using [protojson](https://google.golang.org/protobuf/encoding/protojson).
- Frequent updates based on [official repository](https://github.com/googleapis/googleapis).
- <del>Frequent updates based on [official repository](https://github.com/googleapis/googleapis).</del> We are sorry that we will not update it frequently in the future, but we will continue to maintain it. The frequency of updates depends on our needs (abount later than the official release one month).

## Version support

| google-ads-pb | Google Ads API | Sunset date |
|---|---|---|
| v1.5.1 | v14.1 | End of May 2024 |
| v1.5.0 | v14 | End of May 2024 |
| v1.4.1 | v13.1 | End of January 2024 |
| v1.4.0 | v13 | End of January 2024 |
| v1.3.1 | v12 | <b>End of September 2023</b> |
| <del>v1.2.1</del> | <del>v11.1</del> | Deprecated |
| <del>v1.2.0</del> | <del>v11</del> | Deprecated |
| <del>v1.1.1</del> | <del>v10</del> | Deprecated |
| google-ads-pb | Google Ads API | Sunset date |
| ----------------- | ---------------- | ---------------------------- |
| v1.5.1 | v14.1 | End of May 2024 |
| v1.5.0 | v14 | End of May 2024 |
| v1.4.1 | v13.1 | End of January 2024 |
| v1.4.0 | v13 | End of January 2024 |
| v1.3.1 | v12 | <b>End of September 2023</b> |
| <del>v1.2.1</del> | <del>v11.1</del> | Deprecated |
| <del>v1.2.0</del> | <del>v11</del> | Deprecated |
| <del>v1.1.1</del> | <del>v10</del> | Deprecated |

## Requirements

Expand Down Expand Up @@ -66,7 +67,9 @@ ctx = metadata.NewOutgoingContext(ctx, headers)

cred := grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, ""))
conn, err := grpc.Dial("googleads.googleapis.com:443", cred)
if err != nil { panic(err) }
if err != nil {
panic(err)
}
defer conn.Close()
```

Expand All @@ -78,27 +81,54 @@ accessibleCustomers, err := customerServiceClient.ListAccessibleCustomers(
ctx,
&services.ListAccessibleCustomersRequest{},
)
if err != nil { panic(err) }
if err != nil {
panic(err)
}

for _, customer := range accessibleCustomers.ResourceNames {
fmt.Println("ResourceName: " + customer)
}
```

4. Make HTTP calls with using [protojson](https://google.golang.org/protobuf/encoding/protojson) is not recommended now. But it is available yet, for more information please refer to the code in examples.
4. Make HTTP calls with using [protojson](https://google.golang.org/protobuf/encoding/protojson) is not recommended now, but it is available yet.

```go
req := services.ListAccessibleCustomersRequest{}
requestBody, err := protojson.Marshal(&req)
if err != nil {
panic(err)
}
request, err := http.NewRequest("GET", "https://googleads.googleapis.com/v14/customers:listAccessibleCustomers", bytes.NewBuffer(requestBody))
if err != nil {
panic(err)
}
header := make(http.Header)
header.Set("content-type", "application/json")
header.Set("authorization", os.Getenv("ACCESS_TOKEN"))
header.Set("developer-token", os.Getenv("DEVELOPER_TOKEN"))
request.Header = header
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
panic(err)
}
defer response.Body.Close()
var responseBody []byte
if responseBody, err = io.ReadAll(response.Body); err != nil {
panic(err)
}
listAccessibleCustomersResponse := new(services.ListAccessibleCustomersResponse)
if err := protojson.Unmarshal(response, listAccessibleCustomersResponse); err != nil {
panic(err)
}
for _, customer := range listAccessibleCustomersResponse.ResourceNames {
fmt.Println("ResourceName: " + customer)
}
```

## Examples


### Account management

- ListAccessiableCustomer [[GRPC](https://github.com/shenzhencenter/google-ads-pb/blob/main/examples/account_management/list_accessible_customers.go)] [[HTTP](https://github.com/shenzhencenter/google-ads-pb/blob/main/examples/account_management/http_list_accessible_customers.go)]
- GetAccountInformation [[GRPC](https://github.com/shenzhencenter/google-ads-pb/blob/main/examples/account_management/get_account_information.go)] [[HTTP](https://github.com/shenzhencenter/google-ads-pb/blob/main/examples/account_management/http_get_account_information.go)]

### Campaign management

- GetCampaignsByLabel [[GRPC](https://github.com/shenzhencenter/google-ads-pb/blob/main/examples/campaign_management/get_campaigns_by_label.go)] [[HTTP](https://github.com/shenzhencenter/google-ads-pb/blob/main/examples/campaign_management/http_get_campaigns_by_label.go)]
See [clients/internal/snippets](https://github.com/shenzhencenter/google-ads-pb/tree/main/clients/internal/snippets).

## Related

Expand All @@ -109,10 +139,4 @@ Here are some related projects

## Contributing

Welcome to contribute more examples and documentations.

### Supporting

If you like this project, please consider buying me a coffee. 😄

<a href="https://www.buymeacoffee.com/crazyfrog" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
This project is fully generated by protoc, so we can't accept pull requests. But we are very happy to receive your feedback and suggestions. Please feel free to create an issue.
37 changes: 0 additions & 37 deletions examples/account_management/get_account_information.go

This file was deleted.

41 changes: 0 additions & 41 deletions examples/account_management/http_get_account_information.go

This file was deleted.

32 changes: 0 additions & 32 deletions examples/account_management/http_list_accessible_customers.go

This file was deleted.

34 changes: 0 additions & 34 deletions examples/account_management/list_accessible_customers.go

This file was deleted.

44 changes: 0 additions & 44 deletions examples/campaign_management/get_campaigns_by_label.go

This file was deleted.

44 changes: 0 additions & 44 deletions examples/campaign_management/http_get_campaigns_by_label.go

This file was deleted.

Loading

0 comments on commit 3ec3caf

Please sign in to comment.