Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Initializing go helper library with auto generated code #37

Merged
merged 22 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
token: ${{ secrets.github_token }}

- name: Get dependencies
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*.dll
*.so
*.dylib
.idea

**/.openapi-generator

# Test binary, built with `go test -c`
*.test
Expand Down
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,76 @@ func main() {
}
```

### Send a text message

```go
package main
import (
"fmt"
openapi "github.com/twilio/twilio-go/rest/api/v2010"
"github.com/twilio/twilio-go/twilio"
"os"
)
func main() {
accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
authToken := os.Getenv("TWILIO_AUTH_TOKEN")
client := twilio.NewClient(accountSid, authToken)

from := "9999999999"
to := "4444444444"
text := "Hello there"

params := &openapi.CreateMessageParams{}
params.To = &to
params.From = &from
params.Body = &text


resp, err := client.ApiV2010.CreateMessage(accountSid, params)
if err != nil {
fmt.Println(err.Error())
err = nil
} else {
fmt.Println(resp)
}
}
```

### Make a call

``` go
package main

import (
"fmt"
openapi "github.com/twilio/twilio-go/rest/api/v2010"
"github.com/twilio/twilio-go/twilio"
"os"
)
func main() {
accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
authToken := os.Getenv("TWILIO_AUTH_TOKEN")
client := twilio.NewClient(accountSid, authToken)

from := "9999999999"
to := "4444444444"
callurl := "http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient"

params := &openapi.CreateCallParams{}
params.To = &to
params.From = &from
params.Url = &callurl

resp, err := client.ApiV2010.CreateCall(accountSid, params)
if err != nil {
fmt.Println(err.Error())
err = nil
} else {
fmt.Println(resp)
}
}
```

### Handling Exceptions
```go
package main
Expand Down
86 changes: 86 additions & 0 deletions rest/accounts/v1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Go API client for openapi

This is the public Twilio REST API.

## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project from the OpenAPI specs located at [twilio/twilio-oai](https://github.com/twilio/twilio-oai/tree/main/spec). By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: 1.0.0
- Package version: 1.0.0
- Build package: com.twilio.oai.TwilioGoGenerator
For more information, please visit [https://support.twilio.com](https://support.twilio.com)

## Installation

Install the following dependencies:

```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
```

Put the package under your project folder and add the following in import:

```golang
import "./openapi"
```

## Documentation for API Endpoints

All URIs are relative to *http://localhost*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**CreateCredentialAws**](docs/DefaultApi.md#createcredentialaws) | **Post** /v1/Credentials/AWS |
*DefaultApi* | [**CreateCredentialPublicKey**](docs/DefaultApi.md#createcredentialpublickey) | **Post** /v1/Credentials/PublicKeys |
*DefaultApi* | [**CreateSecondaryAuthToken**](docs/DefaultApi.md#createsecondaryauthtoken) | **Post** /v1/AuthTokens/Secondary |
*DefaultApi* | [**DeleteCredentialAws**](docs/DefaultApi.md#deletecredentialaws) | **Delete** /v1/Credentials/AWS/{Sid} |
*DefaultApi* | [**DeleteCredentialPublicKey**](docs/DefaultApi.md#deletecredentialpublickey) | **Delete** /v1/Credentials/PublicKeys/{Sid} |
*DefaultApi* | [**DeleteSecondaryAuthToken**](docs/DefaultApi.md#deletesecondaryauthtoken) | **Delete** /v1/AuthTokens/Secondary |
*DefaultApi* | [**FetchCredentialAws**](docs/DefaultApi.md#fetchcredentialaws) | **Get** /v1/Credentials/AWS/{Sid} |
*DefaultApi* | [**FetchCredentialPublicKey**](docs/DefaultApi.md#fetchcredentialpublickey) | **Get** /v1/Credentials/PublicKeys/{Sid} |
*DefaultApi* | [**ListCredentialAws**](docs/DefaultApi.md#listcredentialaws) | **Get** /v1/Credentials/AWS |
*DefaultApi* | [**ListCredentialPublicKey**](docs/DefaultApi.md#listcredentialpublickey) | **Get** /v1/Credentials/PublicKeys |
*DefaultApi* | [**UpdateAuthTokenPromotion**](docs/DefaultApi.md#updateauthtokenpromotion) | **Post** /v1/AuthTokens/Promote |
*DefaultApi* | [**UpdateCredentialAws**](docs/DefaultApi.md#updatecredentialaws) | **Post** /v1/Credentials/AWS/{Sid} |
*DefaultApi* | [**UpdateCredentialPublicKey**](docs/DefaultApi.md#updatecredentialpublickey) | **Post** /v1/Credentials/PublicKeys/{Sid} |


## Documentation For Models

- [AccountsV1AuthTokenPromotion](docs/AccountsV1AuthTokenPromotion.md)
- [AccountsV1CredentialCredentialAws](docs/AccountsV1CredentialCredentialAws.md)
- [AccountsV1CredentialCredentialPublicKey](docs/AccountsV1CredentialCredentialPublicKey.md)
- [AccountsV1SecondaryAuthToken](docs/AccountsV1SecondaryAuthToken.md)
- [CreateCredentialAwsRequest](docs/CreateCredentialAwsRequest.md)
- [CreateCredentialPublicKeyRequest](docs/CreateCredentialPublicKeyRequest.md)
- [ListCredentialAwsResponse](docs/ListCredentialAwsResponse.md)
- [ListCredentialAwsResponseMeta](docs/ListCredentialAwsResponseMeta.md)
- [ListCredentialPublicKeyResponse](docs/ListCredentialPublicKeyResponse.md)
- [UpdateCredentialAwsRequest](docs/UpdateCredentialAwsRequest.md)
- [UpdateCredentialPublicKeyRequest](docs/UpdateCredentialPublicKeyRequest.md)


## Documentation For Authorization



## accountSid_authToken

- **Type**: HTTP basic authentication

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
```


## Author

support@twilio.com

Loading