github.com/subosito/twilio@v0.0.1/helper_test.go (about) 1 package twilio 2 3 import ( 4 "bytes" 5 "io/ioutil" 6 "net/http" 7 ) 8 9 type RecordingTransport struct { 10 Transport http.RoundTripper 11 Status int 12 Body string 13 } 14 15 func (rx *RecordingTransport) RoundTrip(r *http.Request) (*http.Response, error) { 16 re := &http.Response{ 17 Proto: "HTTP/1.1", 18 ProtoMajor: 1, 19 ProtoMinor: 1, 20 Status: http.StatusText(rx.Status), 21 StatusCode: rx.Status, 22 Body: ioutil.NopCloser(bytes.NewBufferString(rx.Body)), 23 ContentLength: int64(len(rx.Body)), 24 Request: r, 25 } 26 27 return re, nil 28 } 29 30 var accountSid string = "AC65c2ee6fddb57b5ad6818ddb850c20b9" 31 var authToken string = "2ecaf0108548e09a74387cbb28456aa2" 32 var from string = "+15005550006" 33 var to string = "+62821234567" 34 var body string = "Hello Go!" 35 var callbackUrl = "http://subosito.com/" 36 37 var response = map[string]string{ 38 "SMS": `{ 39 "account_sid": "AC65c2ee6fddb57b5ad6818ddb850c20b9", 40 "api_version": "2010-04-01", 41 "body": "Hello raw response!", 42 "date_created": "Mon, 16 Aug 2010 03:45:01 +0000", 43 "date_sent": "Mon, 16 Aug 2010 03:45:03 +0000", 44 "date_updated": "Mon, 16 Aug 2010 03:45:03 +0000", 45 "direction": "outbound-api", 46 "from": "+14158141829", 47 "price": "-0.02000", 48 "sid": "SM800f449d0399ed014aae2bcc0cc2f2ec", 49 "status": "sent", 50 "to": "+14159978453", 51 "uri": "/2010-04-01/Accounts/AC65c2ee6fddb57b5ad6818ddb850c20b9/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json" 52 }`, 53 "SMSList": ` { 54 "start": 0, 55 "total": 261, 56 "num_pages": 6, 57 "page": 0, 58 "page_size": 50, 59 "end": 49, 60 "uri": "/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages.json", 61 "first_page_uri": "/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages.json?Page=0&PageSize=50", 62 "last_page_uri": "/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages.json?Page=5&PageSize=50", 63 "next_page_uri": "/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages.json?Page=1&PageSize=50", 64 "previous_page_uri": null, 65 "sms_messages": [ 66 { 67 "account_sid": "AC65c2ee6fddb57b5ad6818ddb850c20b9", 68 "api_version": "2010-04-01", 69 "body": "Morning response!", 70 "date_created": "Mon, 16 Aug 2010 03:45:01 +0000", 71 "date_sent": "Mon, 16 Aug 2010 03:45:03 +0000", 72 "date_updated": "Mon, 16 Aug 2010 03:45:03 +0000", 73 "direction": "outbound-api", 74 "from": "+14158141829", 75 "price": "-0.02000", 76 "sid": "SM800f449d0399ed014aae2bcc0cc2f2ec", 77 "status": "sent", 78 "to": "+14159978453", 79 "uri": "/2010-04-01/Accounts/AC5ef872f6da5a21de157d80997a64bd33/SMS/Messages/SM800f449d0399ed014aae2bcc0cc2f2ec.json" 80 } 81 ] 82 }`, 83 }