-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from mercadopago/feature/CORECH2-2214-return-e…
…rror-on-options Add changes
- Loading branch information
Showing
3 changed files
with
22 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,44 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/mercadopago/sdk-go/pkg/internal/requester" | ||
) | ||
|
||
type Option func(*Config) | ||
type Option func(*Config) error | ||
|
||
// WithHTTTPClient allow to do requests using received http client. | ||
func WithHTTTPClient(r requester.Requester) Option { | ||
return func(c *Config) { | ||
if r != nil { | ||
c.Requester = r | ||
// WithHTTPClient allow to do requests using received http client. | ||
func WithHTTPClient(r requester.Requester) Option { | ||
return func(c *Config) error { | ||
if r == nil { | ||
return fmt.Errorf("received http client can't be nil") | ||
} | ||
c.Requester = r | ||
return nil | ||
} | ||
} | ||
|
||
// WithCorporationID send corporation id to api by headers. | ||
func WithCorporationID(value string) Option { | ||
return func(c *Config) { | ||
return func(c *Config) error { | ||
c.CorporationID = value | ||
return nil | ||
} | ||
} | ||
|
||
// WithIntegratorID send integrator id to api by headers. | ||
func WithIntegratorID(i string) Option { | ||
return func(c *Config) { | ||
return func(c *Config) error { | ||
c.IntegratorID = i | ||
return nil | ||
} | ||
} | ||
|
||
// WithPlatformID send platform id to api by headers. | ||
func WithPlatformID(p string) Option { | ||
return func(c *Config) { | ||
return func(c *Config) error { | ||
c.PlatformID = p | ||
return nil | ||
} | ||
} |