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

Test branch #214

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
version: latest
continue-on-error: true

coverage:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [7.51.1](https://github.com/plivo/plivo-go/tree/v7.51.1) (2024-09-03)
**Feature - Adding new element for Audio Stream XML **
- Added `keepCallAlive` element in Audio Stream XML

## [7.51.0](https://github.com/plivo/plivo-go/tree/v7.51.0) (2024-07-11)
**Feature - Adding support for Locale param in Create, Get and List Session**
- Added new request param `locale` in create Session API
Expand Down
10 changes: 5 additions & 5 deletions baseclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"reflect"

"github.com/google/go-querystring/query"
)

const sdkVersion = "7.51.0"
const sdkVersion = "7.51.1"

const lookupBaseUrl = "lookup.plivo.com"

Expand Down Expand Up @@ -121,15 +121,15 @@ func (client *BaseClient) ExecuteRequest(request *http.Request, body interface{}
}
}
}
bodyCopy, _ := ioutil.ReadAll(request.Body)
request.Body = ioutil.NopCloser(bytes.NewReader(bodyCopy))
bodyCopy, _ := io.ReadAll(request.Body)
request.Body = io.NopCloser(bytes.NewReader(bodyCopy))
response, err := client.httpClient.Do(request)

if err != nil {
return
}

data, err := ioutil.ReadAll(response.Body)
data, err := io.ReadAll(response.Body)
if err == nil && data != nil && len(data) > 0 {
if isVoiceRequest && response.StatusCode >= 500 {
if extra[0]["retry"] == 2 {
Expand Down
8 changes: 4 additions & 4 deletions compliance_documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package plivo
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"mime/multipart"
"net/http"
"os"
Expand Down Expand Up @@ -171,7 +171,7 @@ func newfileUploadRequest(uri string, params map[string]string, paramName, path
if err != nil {
return nil, err
}
fileContents, err := ioutil.ReadAll(file)
fileContents, err := io.ReadAll(file)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -208,7 +208,7 @@ func newfileUploadRequest(uri string, params map[string]string, paramName, path

func (service *ComplianceDocumentService) Create(params CreateComplianceDocumentParams) (response *GetComplianceDocumentResponse, err error) {
requestUrl := service.client.BaseUrl
requestUrl.Path = fmt.Sprintf(baseRequestString, fmt.Sprintf(service.client.AuthId+"/ComplianceDocument"))
requestUrl.Path = fmt.Sprintf("%sComplianceDocument/", fmt.Sprintf(baseRequestString, service.client.AuthId))

requestParams := make(map[string]string)
fields := reflect.TypeOf(params)
Expand All @@ -235,7 +235,7 @@ func (service *ComplianceDocumentService) Create(params CreateComplianceDocument

func (service *ComplianceDocumentService) Update(params UpdateComplianceDocumentParams) (response *UpdateComplianceDocumentResponse, err error) {
requestUrl := service.client.BaseUrl
requestUrl.Path = fmt.Sprintf(baseRequestString, fmt.Sprintf(service.client.AuthId+"/ComplianceDocument/"+params.ComplianceDocumentID))
requestUrl.Path = fmt.Sprintf(baseRequestString, service.client.AuthId) + "ComplianceDocument/" + params.ComplianceDocumentID + "/"

requestParams := make(map[string]string)

Expand Down
8 changes: 7 additions & 1 deletion lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

import (
"encoding/json"
"fmt"
)

// NOTE: All of Plivo's APIs are in a single Go package. Unfortunately,
// this imposes the limitation that each struct type has to be unique across
// all of Plivo's product APIs.

const (
numberString = "v1/Number/%s"
format = "%s"
)

type Country struct {
Name string `json:"name"`
ISO2 string `json:"iso2"`
Expand Down Expand Up @@ -55,7 +61,7 @@
params.Type = "carrier"
}

req, err := s.client.BaseClient.NewRequest("GET", params, "v1/Number/%s", number)
req, err := s.client.BaseClient.NewRequest("GET", params, fmt.Sprintf(numberString, format), number)

Check failure on line 64 in lookup.go

View workflow job for this annotation

GitHub Actions / lint

printf: non-constant format string in call to (*github.com/plivo/plivo-go/v7.BaseClient).NewRequest (govet)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion media.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (service *MediaService) Upload(params MediaUpload) (response *MediaResponse
}
}
requestUrl := service.client.BaseUrl
requestUrl.Path = fmt.Sprintf(baseRequestString, fmt.Sprintf(service.client.AuthId+"/Media"))
requestUrl.Path = fmt.Sprintf("/v1/Account/%s/Media/", service.client.AuthId)
request, err := http.NewRequest("POST", requestUrl.String(), payload)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions testutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package plivo

import (
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
"net/url"
"os"
"testing"
"unicode"

Expand Down Expand Up @@ -37,7 +37,7 @@ func expectResponse(fixturePath string, statusCode int) {
fixturePathRunes := []rune(fixturePath)
fixturePathRunes[0] = unicode.ToLower(fixturePathRunes[0])
fullFixturePath := fmt.Sprintf("fixtures/%s", string(fixturePathRunes))
contents, err := ioutil.ReadFile(fullFixturePath)
contents, err := os.ReadFile(fullFixturePath)
if err != nil {
panic(err)
}
Expand Down
7 changes: 7 additions & 0 deletions xml/plivoxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,8 @@ type StreamElement struct {

ExtraHeaders *string `xml:"extraHeaders,attr"`

KeepCallAlive *bool `xml:"keepCallAlive,attr"`

XMLName xml.Name `xml:"Stream"`
}

Expand Down Expand Up @@ -1444,6 +1446,11 @@ func (e StreamElement) SetExtraHeaders(value string) StreamElement {
return e
}

func (e StreamElement) SetKeepCallAlive(value bool) StreamElement {
e.KeepCallAlive = &value
return e
}

func (e StreamElement) SetContents(value string) StreamElement {
e.Contents = value
return e
Expand Down
4 changes: 2 additions & 2 deletions xml/plivoxml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ func TestMPCXMLWithHold(t *testing.T) {
}

func TestStreamXML(t *testing.T) {
assert.Equal(t, "<Response><Stream bidirectional=\"true\" extraHeaders=\"a=1,b=2\">wss://test.url</Stream></Response>", ResponseElement{
assert.Equal(t, "<Response><Stream bidirectional=\"true\" extraHeaders=\"a=1,b=2\" keepCallAlive=\"true\">wss://test.url</Stream></Response>", ResponseElement{
Contents: []interface{}{
new(StreamElement).SetBidirectional(true).SetContents("wss://test.url").SetExtraHeaders("a=1,b=2"),
new(StreamElement).SetBidirectional(true).SetContents("wss://test.url").SetExtraHeaders("a=1,b=2").SetKeepCallAlive(true),
},
}.String())
}
Loading