Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix bug when options were nil

  • Loading branch information...
commit 49acf3ada258c36e0e4d05a9d419d62467554b17 1 parent 6368b69
@bgentry authored
View
10 account.go
@@ -55,10 +55,12 @@ func (c *Client) AccountUpdate(password string, options *AccountUpdateOpts) (*Ac
Beta *bool `json:"beta,omitempty"`
Name *string `json:"name,omitempty"`
}{
- Password: password,
- AllowTracking: options.AllowTracking,
- Beta: options.Beta,
- Name: options.Name,
+ Password: password,
+ }
+ if options != nil {
+ params.AllowTracking = options.AllowTracking
+ params.Beta = options.Beta
+ params.Name = options.Name
}
var accountRes Account
return &accountRes, c.Patch(&accountRes, "/account", params)
View
6 addon.go
@@ -39,8 +39,10 @@ func (c *Client) AddonCreate(appIdentity string, plan string, options *AddonCrea
Plan string `json:"plan"`
Config *map[string]string `json:"config,omitempty"`
}{
- Plan: plan,
- Config: options.Config,
+ Plan: plan,
+ }
+ if options != nil {
+ params.Config = options.Config
}
var addonRes Addon
return &addonRes, c.Post(&addonRes, "/apps/"+appIdentity+"/addons", params)
View
6 collaborator.go
@@ -37,8 +37,10 @@ func (c *Client) CollaboratorCreate(appIdentity string, user string, options *Co
User string `json:"user"`
Silent *bool `json:"silent,omitempty"`
}{
- User: user,
- Silent: options.Silent,
+ User: user,
+ }
+ if options != nil {
+ params.Silent = options.Silent
}
var collaboratorRes Collaborator
return &collaboratorRes, c.Post(&collaboratorRes, "/apps/"+appIdentity+"/collaborators", params)
View
8 dyno.go
@@ -57,9 +57,11 @@ func (c *Client) DynoCreate(appIdentity string, command string, options *DynoCre
Size *string `json:"size,omitempty"`
}{
Command: command,
- Attach: options.Attach,
- Env: options.Env,
- Size: options.Size,
+ }
+ if options != nil {
+ params.Attach = options.Attach
+ params.Env = options.Env
+ params.Size = options.Size
}
var dynoRes Dyno
return &dynoRes, c.Post(&dynoRes, "/apps/"+appIdentity+"/dynos", params)
View
10 gen/gen.rb
@@ -192,10 +192,14 @@
<%- required.each do |propname| %>
<%= titlecase(propname) %>: <%= variablecase(propname) %>,
<%- end %>
-<%- optional.each do |propname| %>
- <%= titlecase(propname) %>: options.<%= titlecase(propname) %>,
-<%- end %>
}
+<%- if optional.count > 0 %>
+ if options != nil {
+ <%- optional.each do |propname| %>
+ params.<%= titlecase(propname) %> = options.<%= titlecase(propname) %>
+ <%- end %>
+ }
+<%- end %>
LINK_PARAMS_TEMPLATE
# definition: data,
View
4 heroku.go
@@ -21,7 +21,7 @@ import (
)
const (
- Version = "0.4.1"
+ Version = "0.4.2"
DefaultAPIURL = "https://api.heroku.com"
DefaultUserAgent = "heroku-go/" + Version + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")"
)
@@ -108,7 +108,7 @@ func (c *Client) NewRequest(method, path string, body interface{}) (*http.Reques
default:
if v := reflect.ValueOf(body); v.IsValid() {
t := v.Type()
- if t.Kind() != reflect.Ptr || reflect.Indirect(v).IsValid() {
+ if t.Kind() != reflect.Ptr || (reflect.Indirect(v).IsValid() && !reflect.Indirect(v).IsNil()) {
j, err := json.Marshal(body)
if err != nil {
log.Fatal(err)
View
10 oauth_authorization.go
@@ -64,10 +64,12 @@ func (c *Client) OAuthAuthorizationCreate(scope []string, options *OAuthAuthoriz
Description *string `json:"description,omitempty"`
ExpiresIn *int `json:"expires_in,omitempty"`
}{
- Scope: scope,
- Client: options.Client,
- Description: options.Description,
- ExpiresIn: options.ExpiresIn,
+ Scope: scope,
+ }
+ if options != nil {
+ params.Client = options.Client
+ params.Description = options.Description
+ params.ExpiresIn = options.ExpiresIn
}
var oauthAuthorizationRes OAuthAuthorization
return &oauthAuthorizationRes, c.Post(&oauthAuthorizationRes, "/oauth/authorizations", params)
View
6 release.go
@@ -75,8 +75,10 @@ func (c *Client) ReleaseCreate(appIdentity string, slug string, options *Release
Slug string `json:"slug"`
Description *string `json:"description,omitempty"`
}{
- Slug: slug,
- Description: options.Description,
+ Slug: slug,
+ }
+ if options != nil {
+ params.Description = options.Description
}
var releaseRes Release
return &releaseRes, c.Post(&releaseRes, "/apps/"+appIdentity+"/releases", params)
View
4 slug.go
@@ -51,7 +51,9 @@ func (c *Client) SlugCreate(appIdentity string, processTypes map[string]string,
Commit *string `json:"commit,omitempty"`
}{
ProcessTypes: processTypes,
- Commit: options.Commit,
+ }
+ if options != nil {
+ params.Commit = options.Commit
}
var slugRes Slug
return &slugRes, c.Post(&slugRes, "/apps/"+appIdentity+"/slugs", params)
Please sign in to comment.
Something went wrong with that request. Please try again.