Skip to content

Commit

Permalink
feat!: MVR preparation (#233)
Browse files Browse the repository at this point in the history
* feat!: MVR preparation

* chore: added tests for request handler
  • Loading branch information
tiwarishubham635 authored Mar 11, 2024
1 parent 3ece76a commit bb943bb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 66 deletions.
63 changes: 0 additions & 63 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,5 @@
twilio-go changelog
====================
[2023-12-07] Version 2.0.0-rc.1
-------------------------------
**Library - Feature**
- [PR #213](https://github.com/twilio/twilio-go/pull/213): Support JSON payload in HTTP requests. Thanks to [@AsabuHere](https://github.com/AsabuHere)!

**Accounts**
- Updated Safelist metadata to correct the docs.
- Add Global SafeList API changes

**Api**
- Updated service base url for connect apps and authorized connect apps APIs **(breaking change)**
- Update documentation to reflect RiskCheck GA
- Added optional parameter `CallToken` for create participant api

**Events**
- Marked as GA

**Flex**
- Adding `provisioning_status` for Email Manager
- Adding `offline_config` to Flex Configuration

**Insights**
- decommission voice-qualitystats-endpoint role

**Intelligence**
- Add text-generation operator (for example conversation summary) results to existing OperatorResults collection.
- Deleted `redacted` parameter from fetching transcript in v2 **(breaking change)**

**Lookups**
- Add new `phone_number_quality_score` package to the lookup response
- Remove `disposable_phone_number_risk` package **(breaking change)**

**Messaging**
- Add tollfree edit_allowed and edit_reason fields
- Update Phone Number, Short Code, Alpha Sender, US A2P and Channel Sender documentation
- Add DELETE support to Tollfree Verification resource
- Update US App To Person documentation with current `message_samples` requirements

**Serverless**
- Add node18 as a valid Build runtime

**Taskrouter**
- Add container attribute to task_queue_bulk_real_time_statistics endpoint
- Remove beta_feature check on task_queue_bulk_real_time_statistics endpoint
- Add `virtual_start_time` property to tasks
- Updating `task_queue_data` format from `map` to `array` in the response of bulk get endpoint of TaskQueue Real Time Statistics API **(breaking change)**

**Trusthub**
- Add additional optional fields in compliance_tollfree_inquiry.json
- Rename did to tollfree_phone_number in compliance_tollfree_inquiry.json
- Add new optional field notification_email to compliance_tollfree_inquiry.json

**Verify**
- Remove `Tags` from Public Docs **(breaking change)**
- Add `VerifyEventSubscriptionEnabled` parameter to service create and update endpoints.
- Add `Tags` optional parameter on Verification creation.
- Update Verify TOTP maturity to GA.


[2023-11-22] Version 2.0.0-rc.0
---------------------------
- Release Candidate preparation

[2023-10-05] Version 1.14.1
---------------------------
**Library - Chore**
Expand Down
7 changes: 4 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

_All `MAJOR` version bumps will have upgrade notes posted here._

## [2023-11-22] 1.x.x to 2.x.x-rc.x
## [2024-03-11] 1.x.x to 2.x.x
### Overview

#### Twilio Go Helper Library’s major version 2.0.0-rc.x is now available. We ensured that you can upgrade to Go helper Library 2.0.0-rc.x version without any breaking changes
#### Twilio Go Helper Library’s major version 2.0.0 is now available. We ensured that you can upgrade to Go helper Library 2.0.0 version without any breaking changes of existing apis

Support for JSON payloads has been added in the request body
Behind the scenes Go Helper is now auto-generated via OpenAPI with this release. This enables us to rapidly add new features and enhance consistency across versions and languages.
We're pleased to inform you that version 2.0.0 adds support for the application/json content type in the request body.

[2022-10-05] 0.26.x to 1.x.x
-----------------------------
Expand Down
52 changes: 52 additions & 0 deletions client/request_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package client_test

import (
"errors"
"net/http"
"net/http/httptest"
"net/url"
"testing"

Expand Down Expand Up @@ -65,3 +67,53 @@ func assertAndGetURL(t *testing.T, requestHandler *client.RequestHandler, rawURL
assert.Nil(t, err)
return parsedURL
}

func TestRequestHandler_SendGetRequest(t *testing.T) {
errorResponse := `{
"status": 400,
"code":20001,
"message":"Bad request",
"more_info":"https://www.twilio.com/docs/errors/20001"
}`
errorServer := httptest.NewServer(http.HandlerFunc(
func(resp http.ResponseWriter, req *http.Request) {
resp.WriteHeader(400)
_, _ = resp.Write([]byte(errorResponse))
}))
defer errorServer.Close()

requestHandler := NewRequestHandler("user", "pass")
resp, err := requestHandler.Get(errorServer.URL, nil, nil) //nolint:bodyclose
twilioError := err.(*client.TwilioRestError)
assert.Nil(t, resp)
assert.Equal(t, 400, twilioError.Status)
assert.Equal(t, 20001, twilioError.Code)
assert.Equal(t, "https://www.twilio.com/docs/errors/20001", twilioError.MoreInfo)
assert.Equal(t, "Bad request", twilioError.Message)
assert.Nil(t, twilioError.Details)
}

func TestRequestHandler_SendPostRequest(t *testing.T) {
errorResponse := `{
"status": 400,
"code":20001,
"message":"Bad request",
"more_info":"https://www.twilio.com/docs/errors/20001"
}`
errorServer := httptest.NewServer(http.HandlerFunc(
func(resp http.ResponseWriter, req *http.Request) {
resp.WriteHeader(400)
_, _ = resp.Write([]byte(errorResponse))
}))
defer errorServer.Close()

requestHandler := NewRequestHandler("user", "pass")
resp, err := requestHandler.Post(errorServer.URL, nil, nil) //nolint:bodyclose
twilioError := err.(*client.TwilioRestError)
assert.Nil(t, resp)
assert.Equal(t, 400, twilioError.Status)
assert.Equal(t, 20001, twilioError.Code)
assert.Equal(t, "https://www.twilio.com/docs/errors/20001", twilioError.MoreInfo)
assert.Equal(t, "Bad request", twilioError.Message)
assert.Nil(t, twilioError.Details)
}

0 comments on commit bb943bb

Please sign in to comment.