Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Rename client type
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSinn committed Mar 8, 2022
1 parent 799c4a2 commit c061a85
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ var (
xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)")
)

// APIClient manages communication with the DevCycle Management API API v1.0.0
// In most cases there should be only one, shared, APIClient.
type APIClient struct {
// DVCClient manages communication with the DevCycle Management API API v1.0.0
// In most cases there should be only one, shared, DVCClient.
type DVCClient struct {
cfg *Configuration
common service // Reuse a single struct instead of allocating one for each service on the heap.

Expand All @@ -60,17 +60,17 @@ type APIClient struct {
}

type service struct {
client *APIClient
client *DVCClient
}

// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
// optionally a custom http.Client to allow for advanced features such as caching.
func NewAPIClient(cfg *Configuration) *APIClient {
func NewAPIClient(cfg *Configuration) *DVCClient {
if cfg.HTTPClient == nil {
cfg.HTTPClient = http.DefaultClient
}

c := &APIClient{}
c := &DVCClient{}
c.cfg = cfg
c.common.client = c

Expand Down Expand Up @@ -161,17 +161,17 @@ func parameterToString(obj interface{}, collectionFormat string) string {
}

// callAPI do the request.
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
func (c *DVCClient) callAPI(request *http.Request) (*http.Response, error) {
return c.cfg.HTTPClient.Do(request)
}

// Change base path to allow switching to mocks
func (c *APIClient) ChangeBasePath(path string) {
func (c *DVCClient) ChangeBasePath(path string) {
c.cfg.BasePath = path
}

// prepareRequest build the request
func (c *APIClient) prepareRequest(
func (c *DVCClient) prepareRequest(
ctx context.Context,
path string, method string,
postBody interface{},
Expand Down Expand Up @@ -326,18 +326,18 @@ func (c *APIClient) prepareRequest(
return localVarRequest, nil
}

func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
if strings.Contains(contentType, "application/xml") {
if err = xml.Unmarshal(b, v); err != nil {
return err
}
return nil
} else if strings.Contains(contentType, "application/json") {
if err = json.Unmarshal(b, v); err != nil {
return err
}
return nil
func (c *DVCClient) decode(v interface{}, b []byte, contentType string) (err error) {
if strings.Contains(contentType, "application/xml") {
if err = xml.Unmarshal(b, v); err != nil {
return err
}
return nil
} else if strings.Contains(contentType, "application/json") {
if err = json.Unmarshal(b, v); err != nil {
return err
}
return nil
}
return errors.New("undefined response type")
}

Expand Down

0 comments on commit c061a85

Please sign in to comment.