Beispiel #1
0
func NewTestResponse(status float64, data interface{}, errors []map[string]interface{}, context string, changeInfo api.ChangeInfo) *api.Response {

	httpResponse := new(http.Response)

	sro := map[string]interface{}{common.ResponseObjectFieldStatusCode: status,
		common.ResponseObjectFieldData:       data,
		common.ResponseObjectFieldErrors:     errors,
		common.ResponseObjectFieldChangeInfo: changeInfo,
		common.ResponseObjectFieldContext:    context}

	session := api.NewSession("project", "company", "apiKey")

	responseBytes, _ := session.Codec().Marshal(sro, nil)
	httpResponse.Body = ioutil.NopCloser(bytes.NewBuffer(responseBytes))
	httpResponse.Header = make(map[string][]string)

	response, newResponseErr := api.NewResponse(session, httpResponse)

	if newResponseErr != nil {
		panic(fmt.Sprintf("NewTestResponse: %s", newResponseErr))
	}

	return response

}
Beispiel #2
0
func getTestSession() *Session {
	testSession = NewSession("test", "account", "123")
	testSession.underlyingSession = api.NewSession("project", "company", "apiKey")
	mockedTransporter = new(api.MockedTransporter)
	testSession.SetTransporter(mockedTransporter)
	return testSession
}
Beispiel #3
0
// NewSession creates a new Session object for interacting with Stretchr services.
//
// Recommended Usage
//
// We recommend that you assign the return of a stretchr.NewSession call to a variable
// called Stretchr for easy reading.
//
// For example,
//
//     Stretchr := stretchr.NewSession(project, apiKey, privateKey)
//
// This enables the following code:
//
//     person, err := Stretchr.ReadOne("people/123")
func NewSession(project, account, apiKey string) *Session {
	s := new(Session)
	s.underlyingSession = api.NewSession(project, account, apiKey)
	return s
}