repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
stripe/stripe-go | stripe.go | Float64Slice | func Float64Slice(v []float64) []*float64 {
out := make([]*float64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | go | func Float64Slice(v []float64) []*float64 {
out := make([]*float64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | [
"func",
"Float64Slice",
"(",
"v",
"[",
"]",
"float64",
")",
"[",
"]",
"*",
"float64",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"float64",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"v",
"{",
"out",
"[",
"i",
"]",
... | // Float64Slice returns a slice of float64 pointers given a slice of float64s. | [
"Float64Slice",
"returns",
"a",
"slice",
"of",
"float64",
"pointers",
"given",
"a",
"slice",
"of",
"float64s",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L633-L639 | train |
stripe/stripe-go | stripe.go | GetBackend | func GetBackend(backendType SupportedBackend) Backend {
var backend Backend
backends.mu.RLock()
switch backendType {
case APIBackend:
backend = backends.API
case UploadsBackend:
backend = backends.Uploads
}
backends.mu.RUnlock()
if backend != nil {
return backend
}
backend = GetBackendWithConfig(
backendType,
&BackendConfig{
HTTPClient: httpClient,
LeveledLogger: DefaultLeveledLogger,
LogLevel: LogLevel,
Logger: Logger,
MaxNetworkRetries: 0,
URL: "", // Set by GetBackendWithConfiguation when empty
},
)
backends.mu.Lock()
defer backends.mu.Unlock()
switch backendType {
case APIBackend:
backends.API = backend
case UploadsBackend:
backends.Uploads = backend
}
return backend
} | go | func GetBackend(backendType SupportedBackend) Backend {
var backend Backend
backends.mu.RLock()
switch backendType {
case APIBackend:
backend = backends.API
case UploadsBackend:
backend = backends.Uploads
}
backends.mu.RUnlock()
if backend != nil {
return backend
}
backend = GetBackendWithConfig(
backendType,
&BackendConfig{
HTTPClient: httpClient,
LeveledLogger: DefaultLeveledLogger,
LogLevel: LogLevel,
Logger: Logger,
MaxNetworkRetries: 0,
URL: "", // Set by GetBackendWithConfiguation when empty
},
)
backends.mu.Lock()
defer backends.mu.Unlock()
switch backendType {
case APIBackend:
backends.API = backend
case UploadsBackend:
backends.Uploads = backend
}
return backend
} | [
"func",
"GetBackend",
"(",
"backendType",
"SupportedBackend",
")",
"Backend",
"{",
"var",
"backend",
"Backend",
"\n\n",
"backends",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"switch",
"backendType",
"{",
"case",
"APIBackend",
":",
"backend",
"=",
"backends",
... | // GetBackend returns one of the library's supported backends based off of the
// given argument.
//
// It returns an existing default backend if one's already been created. | [
"GetBackend",
"returns",
"one",
"of",
"the",
"library",
"s",
"supported",
"backends",
"based",
"off",
"of",
"the",
"given",
"argument",
".",
"It",
"returns",
"an",
"existing",
"default",
"backend",
"if",
"one",
"s",
"already",
"been",
"created",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L666-L704 | train |
stripe/stripe-go | stripe.go | GetBackendWithConfig | func GetBackendWithConfig(backendType SupportedBackend, config *BackendConfig) Backend {
if config.HTTPClient == nil {
config.HTTPClient = httpClient
}
if config.LeveledLogger == nil {
if config.Logger == nil {
config.Logger = Logger
}
config.LeveledLogger = &leveledLoggerPrintferShim{
level: printferLevel(config.LogLevel),
logger: config.Logger,
}
}
switch backendType {
case APIBackend:
if config.URL == "" {
config.URL = apiURL
}
config.URL = normalizeURL(config.URL)
return newBackendImplementation(backendType, config)
case UploadsBackend:
if config.URL == "" {
config.URL = uploadsURL
}
config.URL = normalizeURL(config.URL)
return newBackendImplementation(backendType, config)
}
return nil
} | go | func GetBackendWithConfig(backendType SupportedBackend, config *BackendConfig) Backend {
if config.HTTPClient == nil {
config.HTTPClient = httpClient
}
if config.LeveledLogger == nil {
if config.Logger == nil {
config.Logger = Logger
}
config.LeveledLogger = &leveledLoggerPrintferShim{
level: printferLevel(config.LogLevel),
logger: config.Logger,
}
}
switch backendType {
case APIBackend:
if config.URL == "" {
config.URL = apiURL
}
config.URL = normalizeURL(config.URL)
return newBackendImplementation(backendType, config)
case UploadsBackend:
if config.URL == "" {
config.URL = uploadsURL
}
config.URL = normalizeURL(config.URL)
return newBackendImplementation(backendType, config)
}
return nil
} | [
"func",
"GetBackendWithConfig",
"(",
"backendType",
"SupportedBackend",
",",
"config",
"*",
"BackendConfig",
")",
"Backend",
"{",
"if",
"config",
".",
"HTTPClient",
"==",
"nil",
"{",
"config",
".",
"HTTPClient",
"=",
"httpClient",
"\n",
"}",
"\n\n",
"if",
"con... | // GetBackendWithConfig is the same as GetBackend except that it can be given a
// configuration struct that will configure certain aspects of the backend
// that's return. | [
"GetBackendWithConfig",
"is",
"the",
"same",
"as",
"GetBackend",
"except",
"that",
"it",
"can",
"be",
"given",
"a",
"configuration",
"struct",
"that",
"will",
"configure",
"certain",
"aspects",
"of",
"the",
"backend",
"that",
"s",
"return",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L709-L746 | train |
stripe/stripe-go | stripe.go | Int64Slice | func Int64Slice(v []int64) []*int64 {
out := make([]*int64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | go | func Int64Slice(v []int64) []*int64 {
out := make([]*int64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | [
"func",
"Int64Slice",
"(",
"v",
"[",
"]",
"int64",
")",
"[",
"]",
"*",
"int64",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"int64",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"v",
"{",
"out",
"[",
"i",
"]",
"=",
"... | // Int64Slice returns a slice of int64 pointers given a slice of int64s. | [
"Int64Slice",
"returns",
"a",
"slice",
"of",
"int64",
"pointers",
"given",
"a",
"slice",
"of",
"int64s",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L763-L769 | train |
stripe/stripe-go | stripe.go | NewBackends | func NewBackends(httpClient *http.Client) *Backends {
apiConfig := &BackendConfig{HTTPClient: httpClient}
uploadConfig := &BackendConfig{HTTPClient: httpClient}
return &Backends{
API: GetBackendWithConfig(APIBackend, apiConfig),
Uploads: GetBackendWithConfig(UploadsBackend, uploadConfig),
}
} | go | func NewBackends(httpClient *http.Client) *Backends {
apiConfig := &BackendConfig{HTTPClient: httpClient}
uploadConfig := &BackendConfig{HTTPClient: httpClient}
return &Backends{
API: GetBackendWithConfig(APIBackend, apiConfig),
Uploads: GetBackendWithConfig(UploadsBackend, uploadConfig),
}
} | [
"func",
"NewBackends",
"(",
"httpClient",
"*",
"http",
".",
"Client",
")",
"*",
"Backends",
"{",
"apiConfig",
":=",
"&",
"BackendConfig",
"{",
"HTTPClient",
":",
"httpClient",
"}",
"\n",
"uploadConfig",
":=",
"&",
"BackendConfig",
"{",
"HTTPClient",
":",
"ht... | // NewBackends creates a new set of backends with the given HTTP client. You
// should only need to use this for testing purposes or on App Engine. | [
"NewBackends",
"creates",
"a",
"new",
"set",
"of",
"backends",
"with",
"the",
"given",
"HTTP",
"client",
".",
"You",
"should",
"only",
"need",
"to",
"use",
"this",
"for",
"testing",
"purposes",
"or",
"on",
"App",
"Engine",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L773-L780 | train |
stripe/stripe-go | stripe.go | SetAppInfo | func SetAppInfo(info *AppInfo) {
if info != nil && info.Name == "" {
panic(fmt.Errorf("App info name cannot be empty"))
}
appInfo = info
// This is run in init, but we need to reinitialize it now that we have
// some app info.
initUserAgent()
} | go | func SetAppInfo(info *AppInfo) {
if info != nil && info.Name == "" {
panic(fmt.Errorf("App info name cannot be empty"))
}
appInfo = info
// This is run in init, but we need to reinitialize it now that we have
// some app info.
initUserAgent()
} | [
"func",
"SetAppInfo",
"(",
"info",
"*",
"AppInfo",
")",
"{",
"if",
"info",
"!=",
"nil",
"&&",
"info",
".",
"Name",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"appInfo",
"=",
"info",
"\... | // SetAppInfo sets app information. See AppInfo. | [
"SetAppInfo",
"sets",
"app",
"information",
".",
"See",
"AppInfo",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L804-L813 | train |
stripe/stripe-go | stripe.go | SetBackend | func SetBackend(backend SupportedBackend, b Backend) {
switch backend {
case APIBackend:
backends.API = b
case UploadsBackend:
backends.Uploads = b
}
} | go | func SetBackend(backend SupportedBackend, b Backend) {
switch backend {
case APIBackend:
backends.API = b
case UploadsBackend:
backends.Uploads = b
}
} | [
"func",
"SetBackend",
"(",
"backend",
"SupportedBackend",
",",
"b",
"Backend",
")",
"{",
"switch",
"backend",
"{",
"case",
"APIBackend",
":",
"backends",
".",
"API",
"=",
"b",
"\n",
"case",
"UploadsBackend",
":",
"backends",
".",
"Uploads",
"=",
"b",
"\n",... | // SetBackend sets the backend used in the binding. | [
"SetBackend",
"sets",
"the",
"backend",
"used",
"in",
"the",
"binding",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L816-L823 | train |
stripe/stripe-go | stripe.go | StringSlice | func StringSlice(v []string) []*string {
out := make([]*string, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | go | func StringSlice(v []string) []*string {
out := make([]*string, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | [
"func",
"StringSlice",
"(",
"v",
"[",
"]",
"string",
")",
"[",
"]",
"*",
"string",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"string",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"v",
"{",
"out",
"[",
"i",
"]",
"=",... | // StringSlice returns a slice of string pointers given a slice of strings. | [
"StringSlice",
"returns",
"a",
"slice",
"of",
"string",
"pointers",
"given",
"a",
"slice",
"of",
"strings",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L847-L853 | train |
stripe/stripe-go | stripe.go | newBackendImplementation | func newBackendImplementation(backendType SupportedBackend, config *BackendConfig) Backend {
var requestMetricsBuffer chan requestMetrics
enableTelemetry := config.EnableTelemetry || EnableTelemetry
// only allocate the requestMetrics buffer if client telemetry is enabled.
if enableTelemetry {
requestMetricsBuffer = make(chan requestMetrics, telemetryBufferSize)
}
return &BackendImplementation{
HTTPClient: config.HTTPClient,
LeveledLogger: config.LeveledLogger,
MaxNetworkRetries: config.MaxNetworkRetries,
Type: backendType,
URL: config.URL,
enableTelemetry: enableTelemetry,
networkRetriesSleep: true,
requestMetricsBuffer: requestMetricsBuffer,
}
} | go | func newBackendImplementation(backendType SupportedBackend, config *BackendConfig) Backend {
var requestMetricsBuffer chan requestMetrics
enableTelemetry := config.EnableTelemetry || EnableTelemetry
// only allocate the requestMetrics buffer if client telemetry is enabled.
if enableTelemetry {
requestMetricsBuffer = make(chan requestMetrics, telemetryBufferSize)
}
return &BackendImplementation{
HTTPClient: config.HTTPClient,
LeveledLogger: config.LeveledLogger,
MaxNetworkRetries: config.MaxNetworkRetries,
Type: backendType,
URL: config.URL,
enableTelemetry: enableTelemetry,
networkRetriesSleep: true,
requestMetricsBuffer: requestMetricsBuffer,
}
} | [
"func",
"newBackendImplementation",
"(",
"backendType",
"SupportedBackend",
",",
"config",
"*",
"BackendConfig",
")",
"Backend",
"{",
"var",
"requestMetricsBuffer",
"chan",
"requestMetrics",
"\n",
"enableTelemetry",
":=",
"config",
".",
"EnableTelemetry",
"||",
"EnableT... | // newBackendImplementation returns a new Backend based off a given type and
// fully initialized BackendConfig struct.
//
// The vast majority of the time you should be calling GetBackendWithConfig
// instead of this function. | [
"newBackendImplementation",
"returns",
"a",
"new",
"Backend",
"based",
"off",
"a",
"given",
"type",
"and",
"fully",
"initialized",
"BackendConfig",
"struct",
".",
"The",
"vast",
"majority",
"of",
"the",
"time",
"you",
"should",
"be",
"calling",
"GetBackendWithConf... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L989-L1008 | train |
stripe/stripe-go | dispute.go | UnmarshalJSON | func (d *Dispute) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type dispute Dispute
var v dispute
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*d = Dispute(v)
return nil
} | go | func (d *Dispute) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type dispute Dispute
var v dispute
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*d = Dispute(v)
return nil
} | [
"func",
"(",
"d",
"*",
"Dispute",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"d",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"... | // UnmarshalJSON handles deserialization of a Dispute.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Dispute",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/dispute.go#L155-L169 | train |
stripe/stripe-go | account/client.go | Get | func (c Client) Get() (*stripe.Account, error) {
account := &stripe.Account{}
err := c.B.Call(http.MethodGet, "/v1/account", c.Key, nil, account)
return account, err
} | go | func (c Client) Get() (*stripe.Account, error) {
account := &stripe.Account{}
err := c.B.Call(http.MethodGet, "/v1/account", c.Key, nil, account)
return account, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
")",
"(",
"*",
"stripe",
".",
"Account",
",",
"error",
")",
"{",
"account",
":=",
"&",
"stripe",
".",
"Account",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet"... | // Get retrieves the authenticating account. | [
"Get",
"retrieves",
"the",
"authenticating",
"account",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account/client.go#L37-L41 | train |
stripe/stripe-go | account/client.go | Del | func (c Client) Del(id string, params *stripe.AccountParams) (*stripe.Account, error) {
path := stripe.FormatURLPath("/v1/accounts/%s", id)
acct := &stripe.Account{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, acct)
return acct, err
} | go | func (c Client) Del(id string, params *stripe.AccountParams) (*stripe.Account, error) {
path := stripe.FormatURLPath("/v1/accounts/%s", id)
acct := &stripe.Account{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, acct)
return acct, err
} | [
"func",
"(",
"c",
"Client",
")",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"AccountParams",
")",
"(",
"*",
"stripe",
".",
"Account",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"i... | // Del deletes an account. | [
"Del",
"deletes",
"an",
"account",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account/client.go#L75-L80 | train |
stripe/stripe-go | account/client.go | Reject | func Reject(id string, params *stripe.AccountRejectParams) (*stripe.Account, error) {
return getC().Reject(id, params)
} | go | func Reject(id string, params *stripe.AccountRejectParams) (*stripe.Account, error) {
return getC().Reject(id, params)
} | [
"func",
"Reject",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"AccountRejectParams",
")",
"(",
"*",
"stripe",
".",
"Account",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Reject",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Reject rejects an account. | [
"Reject",
"rejects",
"an",
"account",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account/client.go#L83-L85 | train |
stripe/stripe-go | reversal/client.go | New | func New(params *stripe.ReversalParams) (*stripe.Reversal, error) {
return getC().New(params)
} | go | func New(params *stripe.ReversalParams) (*stripe.Reversal, error) {
return getC().New(params)
} | [
"func",
"New",
"(",
"params",
"*",
"stripe",
".",
"ReversalParams",
")",
"(",
"*",
"stripe",
".",
"Reversal",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"New",
"(",
"params",
")",
"\n",
"}"
] | // New creates a new transfer reversal. | [
"New",
"creates",
"a",
"new",
"transfer",
"reversal",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/reversal/client.go#L19-L21 | train |
stripe/stripe-go | reversal/client.go | Update | func (c Client) Update(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) {
path := stripe.FormatURLPath("/v1/transfers/%s/reversals/%s",
stripe.StringValue(params.Transfer), id)
reversal := &stripe.Reversal{}
err := c.B.Call(http.MethodPost, path, c.Key, params, reversal)
return reversal, err
} | go | func (c Client) Update(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) {
path := stripe.FormatURLPath("/v1/transfers/%s/reversals/%s",
stripe.StringValue(params.Transfer), id)
reversal := &stripe.Reversal{}
err := c.B.Call(http.MethodPost, path, c.Key, params, reversal)
return reversal, err
} | [
"func",
"(",
"c",
"Client",
")",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ReversalParams",
")",
"(",
"*",
"stripe",
".",
"Reversal",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",... | // Update updates a transfer reversal's properties. | [
"Update",
"updates",
"a",
"transfer",
"reversal",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/reversal/client.go#L55-L61 | train |
stripe/stripe-go | bitcoinreceiver/client.go | Get | func (c Client) Get(id string) (*stripe.BitcoinReceiver, error) {
path := stripe.FormatURLPath("/v1/bitcoin/receivers/%s", id)
bitcoinReceiver := &stripe.BitcoinReceiver{}
err := c.B.Call(http.MethodGet, path, c.Key, nil, bitcoinReceiver)
return bitcoinReceiver, err
} | go | func (c Client) Get(id string) (*stripe.BitcoinReceiver, error) {
path := stripe.FormatURLPath("/v1/bitcoin/receivers/%s", id)
bitcoinReceiver := &stripe.BitcoinReceiver{}
err := c.B.Call(http.MethodGet, path, c.Key, nil, bitcoinReceiver)
return bitcoinReceiver, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
")",
"(",
"*",
"stripe",
".",
"BitcoinReceiver",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"bitcoinReceiver",
":=",
"&",
... | // Get returns the details of a bitcoin receiver. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"bitcoin",
"receiver",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bitcoinreceiver/client.go#L26-L31 | train |
stripe/stripe-go | subitem/client.go | Get | func (c Client) Get(id string, params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) {
path := stripe.FormatURLPath("/v1/subscription_items/%s", id)
item := &stripe.SubscriptionItem{}
err := c.B.Call(http.MethodGet, path, c.Key, params, item)
return item, err
} | go | func (c Client) Get(id string, params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) {
path := stripe.FormatURLPath("/v1/subscription_items/%s", id)
item := &stripe.SubscriptionItem{}
err := c.B.Call(http.MethodGet, path, c.Key, params, item)
return item, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"SubscriptionItemParams",
")",
"(",
"*",
"stripe",
".",
"SubscriptionItem",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
... | // Get returns the details of a subscription item. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"subscription",
"item",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subitem/client.go#L35-L40 | train |
stripe/stripe-go | coupon.go | UnmarshalJSON | func (c *Coupon) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type coupon Coupon
var v coupon
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Coupon(v)
return nil
} | go | func (c *Coupon) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type coupon Coupon
var v coupon
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Coupon(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Coupon",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a Coupon.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Coupon",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/coupon.go#L67-L81 | train |
stripe/stripe-go | balance.go | UnmarshalJSON | func (t *BalanceTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type balanceTransaction BalanceTransaction
var v balanceTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = BalanceTransaction(v)
return nil
} | go | func (t *BalanceTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type balanceTransaction BalanceTransaction
var v balanceTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = BalanceTransaction(v)
return nil
} | [
"func",
"(",
"t",
"*",
"BalanceTransaction",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"t",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",... | // UnmarshalJSON handles deserialization of a Transaction.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Transaction",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
".... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/balance.go#L153-L167 | train |
stripe/stripe-go | balance.go | UnmarshalJSON | func (s *BalanceTransactionSource) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type balanceTransactionSource BalanceTransactionSource
var v balanceTransactionSource
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*s = BalanceTransactionSource(v)
switch s.Type {
case BalanceTransactionSourceTypeApplicationFee:
err = json.Unmarshal(data, &s.ApplicationFee)
case BalanceTransactionSourceTypeCharge:
err = json.Unmarshal(data, &s.Charge)
case BalanceTransactionSourceTypeDispute:
err = json.Unmarshal(data, &s.Dispute)
case BalanceTransactionSourceTypeIssuingAuthorization:
err = json.Unmarshal(data, &s.IssuingAuthorization)
case BalanceTransactionSourceTypeIssuingTransaction:
err = json.Unmarshal(data, &s.IssuingTransaction)
case BalanceTransactionSourceTypePayout:
err = json.Unmarshal(data, &s.Payout)
case BalanceTransactionSourceTypeRecipientTransfer:
err = json.Unmarshal(data, &s.RecipientTransfer)
case BalanceTransactionSourceTypeRefund:
err = json.Unmarshal(data, &s.Refund)
case BalanceTransactionSourceTypeReversal:
err = json.Unmarshal(data, &s.Reversal)
case BalanceTransactionSourceTypeTransfer:
err = json.Unmarshal(data, &s.Transfer)
}
return err
} | go | func (s *BalanceTransactionSource) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type balanceTransactionSource BalanceTransactionSource
var v balanceTransactionSource
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*s = BalanceTransactionSource(v)
switch s.Type {
case BalanceTransactionSourceTypeApplicationFee:
err = json.Unmarshal(data, &s.ApplicationFee)
case BalanceTransactionSourceTypeCharge:
err = json.Unmarshal(data, &s.Charge)
case BalanceTransactionSourceTypeDispute:
err = json.Unmarshal(data, &s.Dispute)
case BalanceTransactionSourceTypeIssuingAuthorization:
err = json.Unmarshal(data, &s.IssuingAuthorization)
case BalanceTransactionSourceTypeIssuingTransaction:
err = json.Unmarshal(data, &s.IssuingTransaction)
case BalanceTransactionSourceTypePayout:
err = json.Unmarshal(data, &s.Payout)
case BalanceTransactionSourceTypeRecipientTransfer:
err = json.Unmarshal(data, &s.RecipientTransfer)
case BalanceTransactionSourceTypeRefund:
err = json.Unmarshal(data, &s.Refund)
case BalanceTransactionSourceTypeReversal:
err = json.Unmarshal(data, &s.Reversal)
case BalanceTransactionSourceTypeTransfer:
err = json.Unmarshal(data, &s.Transfer)
}
return err
} | [
"func",
"(",
"s",
"*",
"BalanceTransactionSource",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
... | // UnmarshalJSON handles deserialization of a BalanceTransactionSource.
// This custom unmarshaling is needed because the specific
// type of transaction source it refers to is specified in the JSON | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"BalanceTransactionSource",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"specific",
"type",
"of",
"transaction",
"source",
"it",
"refers",
"to",
"is",
"specified",
"in",
"the",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/balance.go#L172-L211 | train |
stripe/stripe-go | fee/client.go | Get | func Get(id string, params *stripe.ApplicationFeeParams) (*stripe.ApplicationFee, error) {
return getC().Get(id, params)
} | go | func Get(id string, params *stripe.ApplicationFeeParams) (*stripe.ApplicationFee, error) {
return getC().Get(id, params)
} | [
"func",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ApplicationFeeParams",
")",
"(",
"*",
"stripe",
".",
"ApplicationFee",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Get",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Get returns the details of an application fee. | [
"Get",
"returns",
"the",
"details",
"of",
"an",
"application",
"fee",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/fee/client.go#L18-L20 | train |
stripe/stripe-go | order.go | SetSource | func (op *OrderPayParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
op.Source = source
return err
} | go | func (op *OrderPayParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
op.Source = source
return err
} | [
"func",
"(",
"op",
"*",
"OrderPayParams",
")",
"SetSource",
"(",
"sp",
"interface",
"{",
"}",
")",
"error",
"{",
"source",
",",
"err",
":=",
"SourceParamsFor",
"(",
"sp",
")",
"\n",
"op",
".",
"Source",
"=",
"source",
"\n",
"return",
"err",
"\n",
"}"... | // SetSource adds valid sources to a OrderParams object,
// returning an error for unsupported sources. | [
"SetSource",
"adds",
"valid",
"sources",
"to",
"a",
"OrderParams",
"object",
"returning",
"an",
"error",
"for",
"unsupported",
"sources",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/order.go#L224-L228 | train |
stripe/stripe-go | order.go | UnmarshalJSON | func (p *OrderItemParent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type orderItemParent OrderItemParent
var v orderItemParent
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*p = OrderItemParent(v)
switch p.Type {
case OrderItemParentTypeSKU:
// Currently only SKUs `parent` is returned as an object when expanded.
// For other items only IDs are returned.
if err = json.Unmarshal(data, &p.SKU); err != nil {
return err
}
p.ID = p.SKU.ID
}
return nil
} | go | func (p *OrderItemParent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type orderItemParent OrderItemParent
var v orderItemParent
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*p = OrderItemParent(v)
switch p.Type {
case OrderItemParentTypeSKU:
// Currently only SKUs `parent` is returned as an object when expanded.
// For other items only IDs are returned.
if err = json.Unmarshal(data, &p.SKU); err != nil {
return err
}
p.ID = p.SKU.ID
}
return nil
} | [
"func",
"(",
"p",
"*",
"OrderItemParent",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"p",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of an OrderItemParent.
// This custom unmarshaling is needed because the resulting
// property may be an id or a full SKU struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"OrderItemParent",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"a",
"full",
"SKU",
"struct",
"if",
"it",
"was",
"exp... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/order.go#L233-L259 | train |
stripe/stripe-go | order.go | UnmarshalJSON | func (o *Order) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
o.ID = id
return nil
}
type order Order
var v order
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*o = Order(v)
return nil
} | go | func (o *Order) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
o.ID = id
return nil
}
type order Order
var v order
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*o = Order(v)
return nil
} | [
"func",
"(",
"o",
"*",
"Order",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"o",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n... | // UnmarshalJSON handles deserialization of an Order.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"Order",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/order.go#L264-L278 | train |
stripe/stripe-go | paymentmethod.go | UnmarshalJSON | func (i *PaymentMethod) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type pm PaymentMethod
var v pm
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = PaymentMethod(v)
return nil
} | go | func (i *PaymentMethod) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type pm PaymentMethod
var v pm
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = PaymentMethod(v)
return nil
} | [
"func",
"(",
"i",
"*",
"PaymentMethod",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}... | // UnmarshalJSON handles deserialization of a PaymentMethod.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"PaymentMethod",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentmethod.go#L169-L183 | train |
stripe/stripe-go | form/form.go | AppendTo | func AppendTo(values *Values, i interface{}) {
reflectValue(values, reflect.ValueOf(i), false, nil)
} | go | func AppendTo(values *Values, i interface{}) {
reflectValue(values, reflect.ValueOf(i), false, nil)
} | [
"func",
"AppendTo",
"(",
"values",
"*",
"Values",
",",
"i",
"interface",
"{",
"}",
")",
"{",
"reflectValue",
"(",
"values",
",",
"reflect",
".",
"ValueOf",
"(",
"i",
")",
",",
"false",
",",
"nil",
")",
"\n",
"}"
] | // AppendTo uses reflection to form encode into the given values collection
// based off the form tags that it defines. | [
"AppendTo",
"uses",
"reflection",
"to",
"form",
"encode",
"into",
"the",
"given",
"values",
"collection",
"based",
"off",
"the",
"form",
"tags",
"that",
"it",
"defines",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L104-L106 | train |
stripe/stripe-go | form/form.go | AppendToPrefixed | func AppendToPrefixed(values *Values, i interface{}, keyParts []string) {
reflectValue(values, reflect.ValueOf(i), false, keyParts)
} | go | func AppendToPrefixed(values *Values, i interface{}, keyParts []string) {
reflectValue(values, reflect.ValueOf(i), false, keyParts)
} | [
"func",
"AppendToPrefixed",
"(",
"values",
"*",
"Values",
",",
"i",
"interface",
"{",
"}",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"reflectValue",
"(",
"values",
",",
"reflect",
".",
"ValueOf",
"(",
"i",
")",
",",
"false",
",",
"keyParts",
")",
... | // AppendToPrefixed is the same as AppendTo, but it allows a slice of key parts
// to be specified to prefix the form values.
//
// I was hoping not to have to expose this function, but I ended up needing it
// for recipients. Recipients is going away, and when it does, we can probably
// remove it again. | [
"AppendToPrefixed",
"is",
"the",
"same",
"as",
"AppendTo",
"but",
"it",
"allows",
"a",
"slice",
"of",
"key",
"parts",
"to",
"be",
"specified",
"to",
"prefix",
"the",
"form",
"values",
".",
"I",
"was",
"hoping",
"not",
"to",
"have",
"to",
"expose",
"this"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L114-L116 | train |
stripe/stripe-go | form/form.go | FormatKey | func FormatKey(parts []string) string {
if len(parts) < 1 {
panic("Not allowed 0-length parts slice")
}
key := parts[0]
for i := 1; i < len(parts); i++ {
key += "[" + parts[i] + "]"
}
return key
} | go | func FormatKey(parts []string) string {
if len(parts) < 1 {
panic("Not allowed 0-length parts slice")
}
key := parts[0]
for i := 1; i < len(parts); i++ {
key += "[" + parts[i] + "]"
}
return key
} | [
"func",
"FormatKey",
"(",
"parts",
"[",
"]",
"string",
")",
"string",
"{",
"if",
"len",
"(",
"parts",
")",
"<",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"key",
":=",
"parts",
"[",
"0",
"]",
"\n",
"for",
"i",
":=",
"1",
";",... | // FormatKey takes a series of key parts that may be parameter keyParts, map keys,
// or array indices and unifies them into a single key suitable for Stripe's
// style of form encoding. | [
"FormatKey",
"takes",
"a",
"series",
"of",
"key",
"parts",
"that",
"may",
"be",
"parameter",
"keyParts",
"map",
"keys",
"or",
"array",
"indices",
"and",
"unifies",
"them",
"into",
"a",
"single",
"key",
"suitable",
"for",
"Stripe",
"s",
"style",
"of",
"form... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L121-L131 | train |
stripe/stripe-go | form/form.go | getCachedOrBuildTypeEncoder | func getCachedOrBuildTypeEncoder(t reflect.Type) encoderFunc {
// Just acquire a read lock when extracting a value (note that in Go, a map
// cannot be read while it's also being written).
encoderCache.mu.RLock()
f := encoderCache.m[t]
encoderCache.mu.RUnlock()
if f != nil {
return f
}
// We do the work to get the encoder without holding a lock. This could
// result in duplicate work, but it will help us avoid a deadlock. Encoders
// may be built and stored recursively in the cases of something like an
// array or slice, so we need to make sure that this function is properly
// re-entrant.
f = makeTypeEncoder(t)
encoderCache.mu.Lock()
defer encoderCache.mu.Unlock()
if encoderCache.m == nil {
encoderCache.m = make(map[reflect.Type]encoderFunc)
}
encoderCache.m[t] = f
return f
} | go | func getCachedOrBuildTypeEncoder(t reflect.Type) encoderFunc {
// Just acquire a read lock when extracting a value (note that in Go, a map
// cannot be read while it's also being written).
encoderCache.mu.RLock()
f := encoderCache.m[t]
encoderCache.mu.RUnlock()
if f != nil {
return f
}
// We do the work to get the encoder without holding a lock. This could
// result in duplicate work, but it will help us avoid a deadlock. Encoders
// may be built and stored recursively in the cases of something like an
// array or slice, so we need to make sure that this function is properly
// re-entrant.
f = makeTypeEncoder(t)
encoderCache.mu.Lock()
defer encoderCache.mu.Unlock()
if encoderCache.m == nil {
encoderCache.m = make(map[reflect.Type]encoderFunc)
}
encoderCache.m[t] = f
return f
} | [
"func",
"getCachedOrBuildTypeEncoder",
"(",
"t",
"reflect",
".",
"Type",
")",
"encoderFunc",
"{",
"// Just acquire a read lock when extracting a value (note that in Go, a map",
"// cannot be read while it's also being written).",
"encoderCache",
".",
"mu",
".",
"RLock",
"(",
")",... | // getCachedOrBuildTypeEncoder tries to get an encoderFunc for the type from
// the cache, and falls back to building one if there wasn't a cached one
// available. If an encoder is built, it's stored back to the cache. | [
"getCachedOrBuildTypeEncoder",
"tries",
"to",
"get",
"an",
"encoderFunc",
"for",
"the",
"type",
"from",
"the",
"cache",
"and",
"falls",
"back",
"to",
"building",
"one",
"if",
"there",
"wasn",
"t",
"a",
"cached",
"one",
"available",
".",
"If",
"an",
"encoder"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L260-L287 | train |
stripe/stripe-go | feerefund/client.go | Get | func Get(id string, params *stripe.FeeRefundParams) (*stripe.FeeRefund, error) {
return getC().Get(id, params)
} | go | func Get(id string, params *stripe.FeeRefundParams) (*stripe.FeeRefund, error) {
return getC().Get(id, params)
} | [
"func",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"FeeRefundParams",
")",
"(",
"*",
"stripe",
".",
"FeeRefund",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Get",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Get returns the details of an application fee refund. | [
"Get",
"returns",
"the",
"details",
"of",
"an",
"application",
"fee",
"refund",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/feerefund/client.go#L40-L42 | train |
stripe/stripe-go | bankaccount.go | AppendTo | func (p *BankAccountListParams) AppendTo(body *form.Values, keyParts []string) {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
} | go | func (p *BankAccountListParams) AppendTo(body *form.Values, keyParts []string) {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
} | [
"func",
"(",
"p",
"*",
"BankAccountListParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"\"",
"\"... | // AppendTo implements custom encoding logic for BankAccountListParams
// so that we can send the special required `object` field up along with the
// other specified parameters. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"BankAccountListParams",
"so",
"that",
"we",
"can",
"send",
"the",
"special",
"required",
"object",
"field",
"up",
"along",
"with",
"the",
"other",
"specified",
"parameters",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bankaccount.go#L138-L140 | train |
stripe/stripe-go | bankaccount.go | UnmarshalJSON | func (b *BankAccount) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
b.ID = id
return nil
}
type bankAccount BankAccount
var v bankAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*b = BankAccount(v)
return nil
} | go | func (b *BankAccount) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
b.ID = id
return nil
}
type bankAccount BankAccount
var v bankAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*b = BankAccount(v)
return nil
} | [
"func",
"(",
"b",
"*",
"BankAccount",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"b",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",... | // UnmarshalJSON handles deserialization of a BankAccount.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"BankAccount",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
".... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bankaccount.go#L169-L183 | train |
stripe/stripe-go | filelink/client.go | Get | func (c Client) Get(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
path := stripe.FormatURLPath("/v1/file_links/%s", id)
fileLink := &stripe.FileLink{}
err := c.B.Call(http.MethodGet, path, c.Key, params, fileLink)
return fileLink, err
} | go | func (c Client) Get(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
path := stripe.FormatURLPath("/v1/file_links/%s", id)
fileLink := &stripe.FileLink{}
err := c.B.Call(http.MethodGet, path, c.Key, params, fileLink)
return fileLink, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"FileLinkParams",
")",
"(",
"*",
"stripe",
".",
"FileLink",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
... | // Get retrieves a file link. | [
"Get",
"retrieves",
"a",
"file",
"link",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink/client.go#L37-L42 | train |
stripe/stripe-go | filelink/client.go | Update | func Update(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"FileLinkParams",
")",
"(",
"*",
"stripe",
".",
"FileLink",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Update updates a file link. | [
"Update",
"updates",
"a",
"file",
"link",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink/client.go#L45-L47 | train |
stripe/stripe-go | filelink/client.go | List | func (c Client) List(listParams *stripe.FileLinkListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.FileLinkList{}
err := c.B.CallRaw(http.MethodGet, "/v1/file_links", c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | go | func (c Client) List(listParams *stripe.FileLinkListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.FileLinkList{}
err := c.B.CallRaw(http.MethodGet, "/v1/file_links", c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | [
"func",
"(",
"c",
"Client",
")",
"List",
"(",
"listParams",
"*",
"stripe",
".",
"FileLinkListParams",
")",
"*",
"Iter",
"{",
"return",
"&",
"Iter",
"{",
"stripe",
".",
"GetIter",
"(",
"listParams",
",",
"func",
"(",
"p",
"*",
"stripe",
".",
"Params",
... | // List returns an iterator that iterates all file links. | [
"List",
"returns",
"an",
"iterator",
"that",
"iterates",
"all",
"file",
"links",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink/client.go#L63-L75 | train |
stripe/stripe-go | sku.go | UnmarshalJSON | func (s *SKU) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type sku SKU
var v sku
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SKU(v)
return nil
} | go | func (s *SKU) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type sku SKU
var v sku
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SKU(v)
return nil
} | [
"func",
"(",
"s",
"*",
"SKU",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n... | // UnmarshalJSON handles deserialization of a SKU.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"SKU",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/sku.go#L92-L106 | train |
stripe/stripe-go | feerefund.go | UnmarshalJSON | func (r *FeeRefund) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type feeRefund FeeRefund
var v feeRefund
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = FeeRefund(v)
return nil
} | go | func (r *FeeRefund) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type feeRefund FeeRefund
var v feeRefund
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = FeeRefund(v)
return nil
} | [
"func",
"(",
"r",
"*",
"FeeRefund",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a FeeRefund.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"FeeRefund",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/feerefund.go#L43-L57 | train |
stripe/stripe-go | radar/valuelist/client.go | Update | func (c Client) Update(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
path := stripe.FormatURLPath("/v1/radar/value_lists/%s", id)
vl := &stripe.RadarValueList{}
err := c.B.Call(http.MethodPost, path, c.Key, params, vl)
return vl, err
} | go | func (c Client) Update(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
path := stripe.FormatURLPath("/v1/radar/value_lists/%s", id)
vl := &stripe.RadarValueList{}
err := c.B.Call(http.MethodPost, path, c.Key, params, vl)
return vl, err
} | [
"func",
"(",
"c",
"Client",
")",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"RadarValueListParams",
")",
"(",
"*",
"stripe",
".",
"RadarValueList",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
... | // Update updates a vl's properties. | [
"Update",
"updates",
"a",
"vl",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/radar/valuelist/client.go#L50-L55 | train |
stripe/stripe-go | radar/valuelist/client.go | Del | func Del(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
return getC().Del(id, params)
} | go | func Del(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
return getC().Del(id, params)
} | [
"func",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"RadarValueListParams",
")",
"(",
"*",
"stripe",
".",
"RadarValueList",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Del",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Del removes a value list. | [
"Del",
"removes",
"a",
"value",
"list",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/radar/valuelist/client.go#L58-L60 | train |
stripe/stripe-go | person.go | UnmarshalJSON | func (c *Person) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type person Person
var v person
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Person(v)
return nil
} | go | func (c *Person) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type person Person
var v person
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Person(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Person",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a Person.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Person",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/person.go#L195-L209 | train |
stripe/stripe-go | card.go | AppendTo | func (p *CardListParams) AppendTo(body *form.Values, keyParts []string) {
if p.Account != nil || p.Customer != nil {
body.Add(form.FormatKey(append(keyParts, "object")), "card")
}
} | go | func (p *CardListParams) AppendTo(body *form.Values, keyParts []string) {
if p.Account != nil || p.Customer != nil {
body.Add(form.FormatKey(append(keyParts, "object")), "card")
}
} | [
"func",
"(",
"p",
"*",
"CardListParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"p",
".",
"Account",
"!=",
"nil",
"||",
"p",
".",
"Customer",
"!=",
"nil",
"{",
"body",
".",
"... | // AppendTo implements custom encoding logic for CardListParams
// so that we can send the special required `object` field up along with the
// other specified parameters. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"CardListParams",
"so",
"that",
"we",
"can",
"send",
"the",
"special",
"required",
"object",
"field",
"up",
"along",
"with",
"the",
"other",
"specified",
"parameters",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/card.go#L190-L194 | train |
stripe/stripe-go | card.go | UnmarshalJSON | func (c *Card) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type card Card
var v card
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Card(v)
return nil
} | go | func (c *Card) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type card Card
var v card
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Card(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\... | // UnmarshalJSON handles deserialization of a Card.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Card",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/card.go#L258-L272 | train |
stripe/stripe-go | taxid.go | UnmarshalJSON | func (c *TaxID) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type taxid TaxID
var v taxid
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = TaxID(v)
return nil
} | go | func (c *TaxID) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type taxid TaxID
var v taxid
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = TaxID(v)
return nil
} | [
"func",
"(",
"c",
"*",
"TaxID",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n... | // UnmarshalJSON handles deserialization of a TaxID.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"TaxID",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/taxid.go#L74-L88 | train |
stripe/stripe-go | terminal/location/client.go | Get | func (c Client) Get(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error) {
path := stripe.FormatURLPath("/v1/terminal/locations/%s", id)
location := &stripe.TerminalLocation{}
err := c.B.Call(http.MethodGet, path, c.Key, params, location)
return location, err
} | go | func (c Client) Get(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error) {
path := stripe.FormatURLPath("/v1/terminal/locations/%s", id)
location := &stripe.TerminalLocation{}
err := c.B.Call(http.MethodGet, path, c.Key, params, location)
return location, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"TerminalLocationParams",
")",
"(",
"*",
"stripe",
".",
"TerminalLocation",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
... | // Get returns the details of a terminal location. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"terminal",
"location",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/terminal/location/client.go#L35-L40 | train |
stripe/stripe-go | terminal/location/client.go | Update | func Update(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.TerminalLocationParams) (*stripe.TerminalLocation, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"TerminalLocationParams",
")",
"(",
"*",
"stripe",
".",
"TerminalLocation",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
"\n"... | // Update updates a terminal location. | [
"Update",
"updates",
"a",
"terminal",
"location",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/terminal/location/client.go#L43-L45 | train |
stripe/stripe-go | error.go | Error | func (e *Error) Error() string {
ret, _ := json.Marshal(e)
return string(ret)
} | go | func (e *Error) Error() string {
ret, _ := json.Marshal(e)
return string(ret)
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"ret",
",",
"_",
":=",
"json",
".",
"Marshal",
"(",
"e",
")",
"\n",
"return",
"string",
"(",
"ret",
")",
"\n",
"}"
] | // Error serializes the error object to JSON and returns it as a string. | [
"Error",
"serializes",
"the",
"error",
"object",
"to",
"JSON",
"and",
"returns",
"it",
"as",
"a",
"string",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/error.go#L63-L66 | train |
stripe/stripe-go | recipient/client.go | Get | func (c Client) Get(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) {
path := stripe.FormatURLPath("/v1/recipients/%s", id)
recipient := &stripe.Recipient{}
err := c.B.Call(http.MethodGet, path, c.Key, params, recipient)
return recipient, err
} | go | func (c Client) Get(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) {
path := stripe.FormatURLPath("/v1/recipients/%s", id)
recipient := &stripe.Recipient{}
err := c.B.Call(http.MethodGet, path, c.Key, params, recipient)
return recipient, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"RecipientParams",
")",
"(",
"*",
"stripe",
".",
"Recipient",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
... | // Get returns the details of a recipient. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"recipient",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/recipient/client.go#L26-L31 | train |
stripe/stripe-go | subschedulerevision/client.go | List | func (c Client) List(listParams *stripe.SubscriptionScheduleRevisionListParams) *Iter {
path := stripe.FormatURLPath("/v1/subscription_schedules/%s/revisions",
stripe.StringValue(listParams.Schedule))
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.SubscriptionScheduleRevisionList{}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | go | func (c Client) List(listParams *stripe.SubscriptionScheduleRevisionListParams) *Iter {
path := stripe.FormatURLPath("/v1/subscription_schedules/%s/revisions",
stripe.StringValue(listParams.Schedule))
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.SubscriptionScheduleRevisionList{}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | [
"func",
"(",
"c",
"Client",
")",
"List",
"(",
"listParams",
"*",
"stripe",
".",
"SubscriptionScheduleRevisionListParams",
")",
"*",
"Iter",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"stripe",
".",
"StringValue",
"(",
"listParam... | // List returns a list of subscription schedule revisions. | [
"List",
"returns",
"a",
"list",
"of",
"subscription",
"schedule",
"revisions",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subschedulerevision/client.go#L45-L60 | train |
stripe/stripe-go | checkout_session.go | UnmarshalJSON | func (p *CheckoutSession) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type session CheckoutSession
var v session
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = CheckoutSession(v)
return nil
} | go | func (p *CheckoutSession) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type session CheckoutSession
var v session
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = CheckoutSession(v)
return nil
} | [
"func",
"(",
"p",
"*",
"CheckoutSession",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"p",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of a checkout session.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"checkout",
"session",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expan... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/checkout_session.go#L122-L136 | train |
stripe/stripe-go | product.go | UnmarshalJSON | func (p *Product) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type product Product
var v product
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = Product(v)
return nil
} | go | func (p *Product) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type product Product
var v product
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = Product(v)
return nil
} | [
"func",
"(",
"p",
"*",
"Product",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"p",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"... | // UnmarshalJSON handles deserialization of a Product.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Product",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/product.go#L95-L109 | train |
stripe/stripe-go | filelink.go | UnmarshalJSON | func (c *FileLink) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type fileLink FileLink
var v fileLink
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = FileLink(v)
return nil
} | go | func (c *FileLink) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type fileLink FileLink
var v fileLink
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = FileLink(v)
return nil
} | [
"func",
"(",
"c",
"*",
"FileLink",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a file link.
// This custom unmarshaling is needed because the resulting
// property may be an ID or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"file",
"link",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"ID",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink.go#L40-L54 | train |
stripe/stripe-go | paymentsource.go | AppendTo | func (p *SourceParams) AppendTo(body *form.Values, keyParts []string) {
if p.Card != nil {
p.Card.AppendToAsCardSourceOrExternalAccount(body, keyParts)
}
} | go | func (p *SourceParams) AppendTo(body *form.Values, keyParts []string) {
if p.Card != nil {
p.Card.AppendToAsCardSourceOrExternalAccount(body, keyParts)
}
} | [
"func",
"(",
"p",
"*",
"SourceParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"p",
".",
"Card",
"!=",
"nil",
"{",
"p",
".",
"Card",
".",
"AppendToAsCardSourceOrExternalAccount",
"(... | // AppendTo implements custom encoding logic for SourceParams. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"SourceParams",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentsource.go#L30-L34 | train |
stripe/stripe-go | paymentsource.go | UnmarshalJSON | func (s *PaymentSource) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type paymentSource PaymentSource
var v paymentSource
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*s = PaymentSource(v)
switch s.Type {
case PaymentSourceTypeBankAccount:
err = json.Unmarshal(data, &s.BankAccount)
case PaymentSourceTypeBitcoinReceiver:
err = json.Unmarshal(data, &s.BitcoinReceiver)
case PaymentSourceTypeCard:
err = json.Unmarshal(data, &s.Card)
case PaymentSourceTypeObject:
err = json.Unmarshal(data, &s.SourceObject)
}
return err
} | go | func (s *PaymentSource) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type paymentSource PaymentSource
var v paymentSource
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*s = PaymentSource(v)
switch s.Type {
case PaymentSourceTypeBankAccount:
err = json.Unmarshal(data, &s.BankAccount)
case PaymentSourceTypeBitcoinReceiver:
err = json.Unmarshal(data, &s.BitcoinReceiver)
case PaymentSourceTypeCard:
err = json.Unmarshal(data, &s.Card)
case PaymentSourceTypeObject:
err = json.Unmarshal(data, &s.SourceObject)
}
return err
} | [
"func",
"(",
"s",
"*",
"PaymentSource",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}... | // UnmarshalJSON handles deserialization of a PaymentSource.
// This custom unmarshaling is needed because the specific
// type of payment instrument it refers to is specified in the JSON | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"PaymentSource",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"specific",
"type",
"of",
"payment",
"instrument",
"it",
"refers",
"to",
"is",
"specified",
"in",
"the",
"JSON"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentsource.go#L115-L142 | train |
stripe/stripe-go | paymentsource.go | MarshalJSON | func (s *PaymentSource) MarshalJSON() ([]byte, error) {
var target interface{}
switch s.Type {
case PaymentSourceTypeBitcoinReceiver:
target = struct {
*BitcoinReceiver
Type PaymentSourceType `json:"object"`
}{
BitcoinReceiver: s.BitcoinReceiver,
Type: s.Type,
}
case PaymentSourceTypeCard:
var customerID *string
if s.Card.Customer != nil {
customerID = &s.Card.Customer.ID
}
target = struct {
*Card
Customer *string `json:"customer"`
Type PaymentSourceType `json:"object"`
}{
Card: s.Card,
Customer: customerID,
Type: s.Type,
}
case PaymentSourceTypeAccount:
target = struct {
ID string `json:"id"`
Type PaymentSourceType `json:"object"`
}{
ID: s.ID,
Type: s.Type,
}
case PaymentSourceTypeBankAccount:
var customerID *string
if s.BankAccount.Customer != nil {
customerID = &s.BankAccount.Customer.ID
}
target = struct {
*BankAccount
Customer *string `json:"customer"`
Type PaymentSourceType `json:"object"`
}{
BankAccount: s.BankAccount,
Customer: customerID,
Type: s.Type,
}
case "":
target = s.ID
}
return json.Marshal(target)
} | go | func (s *PaymentSource) MarshalJSON() ([]byte, error) {
var target interface{}
switch s.Type {
case PaymentSourceTypeBitcoinReceiver:
target = struct {
*BitcoinReceiver
Type PaymentSourceType `json:"object"`
}{
BitcoinReceiver: s.BitcoinReceiver,
Type: s.Type,
}
case PaymentSourceTypeCard:
var customerID *string
if s.Card.Customer != nil {
customerID = &s.Card.Customer.ID
}
target = struct {
*Card
Customer *string `json:"customer"`
Type PaymentSourceType `json:"object"`
}{
Card: s.Card,
Customer: customerID,
Type: s.Type,
}
case PaymentSourceTypeAccount:
target = struct {
ID string `json:"id"`
Type PaymentSourceType `json:"object"`
}{
ID: s.ID,
Type: s.Type,
}
case PaymentSourceTypeBankAccount:
var customerID *string
if s.BankAccount.Customer != nil {
customerID = &s.BankAccount.Customer.ID
}
target = struct {
*BankAccount
Customer *string `json:"customer"`
Type PaymentSourceType `json:"object"`
}{
BankAccount: s.BankAccount,
Customer: customerID,
Type: s.Type,
}
case "":
target = s.ID
}
return json.Marshal(target)
} | [
"func",
"(",
"s",
"*",
"PaymentSource",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"target",
"interface",
"{",
"}",
"\n\n",
"switch",
"s",
".",
"Type",
"{",
"case",
"PaymentSourceTypeBitcoinReceiver",
":",
"target... | // MarshalJSON handles serialization of a PaymentSource.
// This custom marshaling is needed because the specific type
// of payment instrument it represents is specified by the Type | [
"MarshalJSON",
"handles",
"serialization",
"of",
"a",
"PaymentSource",
".",
"This",
"custom",
"marshaling",
"is",
"needed",
"because",
"the",
"specific",
"type",
"of",
"payment",
"instrument",
"it",
"represents",
"is",
"specified",
"by",
"the",
"Type"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentsource.go#L147-L202 | train |
stripe/stripe-go | subschedulerevision.go | UnmarshalJSON | func (s *SubscriptionScheduleRevision) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type revision SubscriptionScheduleRevision
var v revision
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SubscriptionScheduleRevision(v)
return nil
} | go | func (s *SubscriptionScheduleRevision) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type revision SubscriptionScheduleRevision
var v revision
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SubscriptionScheduleRevision(v)
return nil
} | [
"func",
"(",
"s",
"*",
"SubscriptionScheduleRevision",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil... | // UnmarshalJSON handles deserialization of a SubscriptionScheduleRevision.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"SubscriptionScheduleRevision",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subschedulerevision.go#L43-L57 | train |
stripe/stripe-go | ephemeralkey.go | UnmarshalJSON | func (e *EphemeralKey) UnmarshalJSON(data []byte) error {
type ephemeralKey EphemeralKey
var ee ephemeralKey
err := json.Unmarshal(data, &ee)
if err == nil {
*e = EphemeralKey(ee)
}
e.RawJSON = data
return nil
} | go | func (e *EphemeralKey) UnmarshalJSON(data []byte) error {
type ephemeralKey EphemeralKey
var ee ephemeralKey
err := json.Unmarshal(data, &ee)
if err == nil {
*e = EphemeralKey(ee)
}
e.RawJSON = data
return nil
} | [
"func",
"(",
"e",
"*",
"EphemeralKey",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"type",
"ephemeralKey",
"EphemeralKey",
"\n",
"var",
"ee",
"ephemeralKey",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
... | // UnmarshalJSON handles deserialization of an EphemeralKey.
// This custom unmarshaling is needed because we need to store the
// raw JSON on the object so it may be passed back to the frontend. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"EphemeralKey",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"we",
"need",
"to",
"store",
"the",
"raw",
"JSON",
"on",
"the",
"object",
"so",
"it",
"may",
"be",
"passed",
"back",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/ephemeralkey.go#L40-L51 | train |
stripe/stripe-go | recipienttransfer.go | UnmarshalJSON | func (t *RecipientTransfer) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type recipientTransfer RecipientTransfer
var v recipientTransfer
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = RecipientTransfer(v)
return nil
} | go | func (t *RecipientTransfer) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type recipientTransfer RecipientTransfer
var v recipientTransfer
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = RecipientTransfer(v)
return nil
} | [
"func",
"(",
"t",
"*",
"RecipientTransfer",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"t",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of a RecipientTransfer.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"RecipientTransfer",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/recipienttransfer.go#L113-L127 | train |
stripe/stripe-go | recipienttransfer.go | UnmarshalJSON | func (d *RecipientTransferDestination) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type recipientTransferDestination RecipientTransferDestination
var v recipientTransferDestination
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*d = RecipientTransferDestination(v)
switch d.Type {
case RecipientTransferDestinationBankAccount:
err = json.Unmarshal(data, &d.BankAccount)
case RecipientTransferDestinationCard:
err = json.Unmarshal(data, &d.Card)
}
return err
} | go | func (d *RecipientTransferDestination) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type recipientTransferDestination RecipientTransferDestination
var v recipientTransferDestination
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*d = RecipientTransferDestination(v)
switch d.Type {
case RecipientTransferDestinationBankAccount:
err = json.Unmarshal(data, &d.BankAccount)
case RecipientTransferDestinationCard:
err = json.Unmarshal(data, &d.Card)
}
return err
} | [
"func",
"(",
"d",
"*",
"RecipientTransferDestination",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"d",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil... | // UnmarshalJSON handles deserialization of a RecipientTransferDestination.
// This custom unmarshaling is needed because the specific
// type of destination it refers to is specified in the JSON | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"RecipientTransferDestination",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"specific",
"type",
"of",
"destination",
"it",
"refers",
"to",
"is",
"specified",
"in",
"the",
"JSON"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/recipienttransfer.go#L132-L155 | train |
stripe/stripe-go | paymentmethod/client.go | Detach | func Detach(id string, params *stripe.PaymentMethodDetachParams) (*stripe.PaymentMethod, error) {
return getC().Detach(id, params)
} | go | func Detach(id string, params *stripe.PaymentMethodDetachParams) (*stripe.PaymentMethod, error) {
return getC().Detach(id, params)
} | [
"func",
"Detach",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PaymentMethodDetachParams",
")",
"(",
"*",
"stripe",
".",
"PaymentMethod",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Detach",
"(",
"id",
",",
"params",
")",
"\n"... | // Detach detaches a PaymentMethod. | [
"Detach",
"detaches",
"a",
"PaymentMethod",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentmethod/client.go#L31-L33 | train |
stripe/stripe-go | paymentmethod/client.go | Get | func (c Client) Get(id string, params *stripe.PaymentMethodParams) (*stripe.PaymentMethod, error) {
path := stripe.FormatURLPath("/v1/payment_methods/%s", id)
fee := &stripe.PaymentMethod{}
err := c.B.Call(http.MethodGet, path, c.Key, params, fee)
return fee, err
} | go | func (c Client) Get(id string, params *stripe.PaymentMethodParams) (*stripe.PaymentMethod, error) {
path := stripe.FormatURLPath("/v1/payment_methods/%s", id)
fee := &stripe.PaymentMethod{}
err := c.B.Call(http.MethodGet, path, c.Key, params, fee)
return fee, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PaymentMethodParams",
")",
"(",
"*",
"stripe",
".",
"PaymentMethod",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",... | // Get returns the details of a PaymentMethod. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"PaymentMethod",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentmethod/client.go#L49-L54 | train |
stripe/stripe-go | paymentmethod/client.go | Update | func Update(id string, params *stripe.PaymentMethodParams) (*stripe.PaymentMethod, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.PaymentMethodParams) (*stripe.PaymentMethod, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PaymentMethodParams",
")",
"(",
"*",
"stripe",
".",
"PaymentMethod",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
"\n",
"}... | // Update updates a PaymentMethod. | [
"Update",
"updates",
"a",
"PaymentMethod",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentmethod/client.go#L89-L91 | train |
stripe/stripe-go | issuing_card.go | UnmarshalJSON | func (i *IssuingCard) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingCard IssuingCard
var v issuingCard
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingCard(v)
return nil
} | go | func (i *IssuingCard) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingCard IssuingCard
var v issuingCard
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingCard(v)
return nil
} | [
"func",
"(",
"i",
"*",
"IssuingCard",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",... | // UnmarshalJSON handles deserialization of an IssuingCard.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"IssuingCard",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing_card.go#L188-L202 | train |
stripe/stripe-go | issuing_dispute.go | UnmarshalJSON | func (i *IssuingDispute) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingDispute IssuingDispute
var v issuingDispute
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingDispute(v)
return nil
} | go | func (i *IssuingDispute) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingDispute IssuingDispute
var v issuingDispute
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingDispute(v)
return nil
} | [
"func",
"(",
"i",
"*",
"IssuingDispute",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"... | // UnmarshalJSON handles deserialization of an IssuingDispute.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"IssuingDispute",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing_dispute.go#L107-L121 | train |
stripe/stripe-go | subschedule.go | UnmarshalJSON | func (s *SubscriptionSchedule) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type schedule SubscriptionSchedule
var v schedule
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SubscriptionSchedule(v)
return nil
} | go | func (s *SubscriptionSchedule) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type schedule SubscriptionSchedule
var v schedule
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SubscriptionSchedule(v)
return nil
} | [
"func",
"(",
"s",
"*",
"SubscriptionSchedule",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n... | // UnmarshalJSON handles deserialization of a SubscriptionSchedule.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"SubscriptionSchedule",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expand... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subschedule.go#L187-L201 | train |
stripe/stripe-go | taxrate.go | UnmarshalJSON | func (c *TaxRate) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type taxrate TaxRate
var v taxrate
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = TaxRate(v)
return nil
} | go | func (c *TaxRate) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type taxrate TaxRate
var v taxrate
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = TaxRate(v)
return nil
} | [
"func",
"(",
"c",
"*",
"TaxRate",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"... | // UnmarshalJSON handles deserialization of a TaxRate.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"TaxRate",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/taxrate.go#L62-L76 | train |
stripe/stripe-go | discount/client.go | DelSubscription | func DelSubscription(subscriptionID string, params *stripe.DiscountParams) (*stripe.Discount, error) {
return getC().DelSub(subscriptionID, params)
} | go | func DelSubscription(subscriptionID string, params *stripe.DiscountParams) (*stripe.Discount, error) {
return getC().DelSub(subscriptionID, params)
} | [
"func",
"DelSubscription",
"(",
"subscriptionID",
"string",
",",
"params",
"*",
"stripe",
".",
"DiscountParams",
")",
"(",
"*",
"stripe",
".",
"Discount",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"DelSub",
"(",
"subscriptionID",
",",
"param... | // DelSubscription removes a discount from a customer's subscription. | [
"DelSubscription",
"removes",
"a",
"discount",
"from",
"a",
"customer",
"s",
"subscription",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/discount/client.go#L30-L32 | train |
stripe/stripe-go | sigma_scheduledqueryrun.go | UnmarshalJSON | func (i *SigmaScheduledQueryRun) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type sigmaScheduledQueryRun SigmaScheduledQueryRun
var v sigmaScheduledQueryRun
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = SigmaScheduledQueryRun(v)
return nil
} | go | func (i *SigmaScheduledQueryRun) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type sigmaScheduledQueryRun SigmaScheduledQueryRun
var v sigmaScheduledQueryRun
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = SigmaScheduledQueryRun(v)
return nil
} | [
"func",
"(",
"i",
"*",
"SigmaScheduledQueryRun",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"... | // UnmarshalJSON handles deserialization of an SigmaScheduledQueryRun.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"SigmaScheduledQueryRun",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"exp... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/sigma_scheduledqueryrun.go#L50-L64 | train |
stripe/stripe-go | customer.go | SetSource | func (cp *CustomerParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
cp.Source = source
return err
} | go | func (cp *CustomerParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
cp.Source = source
return err
} | [
"func",
"(",
"cp",
"*",
"CustomerParams",
")",
"SetSource",
"(",
"sp",
"interface",
"{",
"}",
")",
"error",
"{",
"source",
",",
"err",
":=",
"SourceParamsFor",
"(",
"sp",
")",
"\n",
"cp",
".",
"Source",
"=",
"source",
"\n",
"return",
"err",
"\n",
"}"... | // SetSource adds valid sources to a CustomerParams object,
// returning an error for unsupported sources. | [
"SetSource",
"adds",
"valid",
"sources",
"to",
"a",
"CustomerParams",
"object",
"returning",
"an",
"error",
"for",
"unsupported",
"sources",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/customer.go#L103-L107 | train |
stripe/stripe-go | customer.go | UnmarshalJSON | func (c *Customer) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type customer Customer
var v customer
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Customer(v)
return nil
} | go | func (c *Customer) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type customer Customer
var v customer
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Customer(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Customer",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a Customer.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Customer",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/customer.go#L191-L205 | train |
stripe/stripe-go | sub.go | UnmarshalJSON | func (s *Subscription) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type subscription Subscription
var v subscription
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = Subscription(v)
return nil
} | go | func (s *Subscription) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type subscription Subscription
var v subscription
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = Subscription(v)
return nil
} | [
"func",
"(",
"s",
"*",
"Subscription",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}"... | // UnmarshalJSON handles deserialization of a Subscription.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Subscription",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/sub.go#L194-L208 | train |
stripe/stripe-go | order/client.go | Pay | func Pay(id string, params *stripe.OrderPayParams) (*stripe.Order, error) {
return getC().Pay(id, params)
} | go | func Pay(id string, params *stripe.OrderPayParams) (*stripe.Order, error) {
return getC().Pay(id, params)
} | [
"func",
"Pay",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"OrderPayParams",
")",
"(",
"*",
"stripe",
".",
"Order",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Pay",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Pay pays an order. | [
"Pay",
"pays",
"an",
"order",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/order/client.go#L42-L44 | train |
stripe/stripe-go | issuing/dispute/client.go | Get | func Get(id string, params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute, error) {
return getC().Get(id, params)
} | go | func Get(id string, params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute, error) {
return getC().Get(id, params)
} | [
"func",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"IssuingDisputeParams",
")",
"(",
"*",
"stripe",
".",
"IssuingDispute",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Get",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Get returns the details of an issuing dispute. | [
"Get",
"returns",
"the",
"details",
"of",
"an",
"issuing",
"dispute",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing/dispute/client.go#L32-L34 | train |
stripe/stripe-go | issuing/authorization/client.go | Get | func (c Client) Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id)
authorization := &stripe.IssuingAuthorization{}
err := c.B.Call(http.MethodGet, path, c.Key, params, authorization)
return authorization, err
} | go | func (c Client) Get(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
path := stripe.FormatURLPath("/v1/issuing/authorizations/%s", id)
authorization := &stripe.IssuingAuthorization{}
err := c.B.Call(http.MethodGet, path, c.Key, params, authorization)
return authorization, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"IssuingAuthorizationParams",
")",
"(",
"*",
"stripe",
".",
"IssuingAuthorization",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
... | // Get returns the details of an issuing authorization. | [
"Get",
"returns",
"the",
"details",
"of",
"an",
"issuing",
"authorization",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing/authorization/client.go#L51-L56 | train |
stripe/stripe-go | issuing/authorization/client.go | Update | func Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.IssuingAuthorizationParams) (*stripe.IssuingAuthorization, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"IssuingAuthorizationParams",
")",
"(",
"*",
"stripe",
".",
"IssuingAuthorization",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")"... | // Update updates an issuing authorization. | [
"Update",
"updates",
"an",
"issuing",
"authorization",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing/authorization/client.go#L59-L61 | train |
stripe/stripe-go | refund.go | UnmarshalJSON | func (r *Refund) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type refund Refund
var v refund
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Refund(v)
return nil
} | go | func (r *Refund) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type refund Refund
var v refund
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Refund(v)
return nil
} | [
"func",
"(",
"r",
"*",
"Refund",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a Refund.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Refund",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/refund.go#L74-L88 | train |
stripe/stripe-go | fee.go | UnmarshalJSON | func (f *ApplicationFee) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
f.ID = id
return nil
}
type applicationFee ApplicationFee
var v applicationFee
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*f = ApplicationFee(v)
return nil
} | go | func (f *ApplicationFee) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
f.ID = id
return nil
}
type applicationFee ApplicationFee
var v applicationFee
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*f = ApplicationFee(v)
return nil
} | [
"func",
"(",
"f",
"*",
"ApplicationFee",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"f",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"... | // UnmarshalJSON handles deserialization of an ApplicationFee.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"ApplicationFee",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/fee.go#L47-L61 | train |
stripe/stripe-go | source.go | AppendTo | func (p *SourceObjectParams) AppendTo(body *form.Values, keyParts []string) {
if len(p.TypeData) > 0 && p.Type == nil {
panic("You can not fill TypeData if you don't explicitly set Type")
}
for k, vs := range p.TypeData {
body.Add(form.FormatKey(append(keyParts, StringValue(p.Type), k)), vs)
}
} | go | func (p *SourceObjectParams) AppendTo(body *form.Values, keyParts []string) {
if len(p.TypeData) > 0 && p.Type == nil {
panic("You can not fill TypeData if you don't explicitly set Type")
}
for k, vs := range p.TypeData {
body.Add(form.FormatKey(append(keyParts, StringValue(p.Type), k)), vs)
}
} | [
"func",
"(",
"p",
"*",
"SourceObjectParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"p",
".",
"TypeData",
")",
">",
"0",
"&&",
"p",
".",
"Type",
"==",
"nil",
"{",... | // AppendTo implements custom encoding logic for SourceObjectParams so that the special
// "TypeData" value for is sent as the correct parameter based on the Source type | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"SourceObjectParams",
"so",
"that",
"the",
"special",
"TypeData",
"value",
"for",
"is",
"sent",
"as",
"the",
"correct",
"parameter",
"based",
"on",
"the",
"Source",
"type"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/source.go#L250-L258 | train |
stripe/stripe-go | webhookendpoint.go | UnmarshalJSON | func (c *WebhookEndpoint) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type endpoint WebhookEndpoint
var v endpoint
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = WebhookEndpoint(v)
return nil
} | go | func (c *WebhookEndpoint) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type endpoint WebhookEndpoint
var v endpoint
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = WebhookEndpoint(v)
return nil
} | [
"func",
"(",
"c",
"*",
"WebhookEndpoint",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of a WebhookEndpoint.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"WebhookEndpoint",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/webhookendpoint.go#L53-L67 | train |
stripe/stripe-go | paymentintent.go | UnmarshalJSON | func (p *PaymentIntent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type paymentintent PaymentIntent
var v paymentintent
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = PaymentIntent(v)
return nil
} | go | func (p *PaymentIntent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type paymentintent PaymentIntent
var v paymentintent
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = PaymentIntent(v)
return nil
} | [
"func",
"(",
"p",
"*",
"PaymentIntent",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"p",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}... | // UnmarshalJSON handles deserialization of a Payment Intent.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Payment",
"Intent",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expande... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentintent.go#L201-L215 | train |
stripe/stripe-go | issuing/transaction/client.go | Get | func (c Client) Get(id string, params *stripe.IssuingTransactionParams) (*stripe.IssuingTransaction, error) {
path := stripe.FormatURLPath("/v1/issuing/transactions/%s", id)
transaction := &stripe.IssuingTransaction{}
err := c.B.Call(http.MethodGet, path, c.Key, params, transaction)
return transaction, err
} | go | func (c Client) Get(id string, params *stripe.IssuingTransactionParams) (*stripe.IssuingTransaction, error) {
path := stripe.FormatURLPath("/v1/issuing/transactions/%s", id)
transaction := &stripe.IssuingTransaction{}
err := c.B.Call(http.MethodGet, path, c.Key, params, transaction)
return transaction, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"IssuingTransactionParams",
")",
"(",
"*",
"stripe",
".",
"IssuingTransaction",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"... | // Get returns the details of an issuing transaction. | [
"Get",
"returns",
"the",
"details",
"of",
"an",
"issuing",
"transaction",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing/transaction/client.go#L25-L30 | train |
stripe/stripe-go | issuing/transaction/client.go | Update | func Update(id string, params *stripe.IssuingTransactionParams) (*stripe.IssuingTransaction, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.IssuingTransactionParams) (*stripe.IssuingTransaction, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"IssuingTransactionParams",
")",
"(",
"*",
"stripe",
".",
"IssuingTransaction",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
... | // Update updates an issuing transaction. | [
"Update",
"updates",
"an",
"issuing",
"transaction",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing/transaction/client.go#L33-L35 | train |
stripe/stripe-go | creditnote/client.go | VoidCreditNote | func VoidCreditNote(id string, params *stripe.CreditNoteVoidParams) (*stripe.CreditNote, error) {
return getC().VoidCreditNote(id, params)
} | go | func VoidCreditNote(id string, params *stripe.CreditNoteVoidParams) (*stripe.CreditNote, error) {
return getC().VoidCreditNote(id, params)
} | [
"func",
"VoidCreditNote",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"CreditNoteVoidParams",
")",
"(",
"*",
"stripe",
".",
"CreditNote",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"VoidCreditNote",
"(",
"id",
",",
"params",
")"... | // VoidCreditNote voids a credit note. | [
"VoidCreditNote",
"voids",
"a",
"credit",
"note",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/creditnote/client.go#L76-L78 | train |
stripe/stripe-go | issuing_cardholder.go | UnmarshalJSON | func (i *IssuingCardholder) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingCardholder IssuingCardholder
var v issuingCardholder
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingCardholder(v)
return nil
} | go | func (i *IssuingCardholder) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingCardholder IssuingCardholder
var v issuingCardholder
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingCardholder(v)
return nil
} | [
"func",
"(",
"i",
"*",
"IssuingCardholder",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of an IssuingCardholder.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"IssuingCardholder",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing_cardholder.go#L86-L100 | train |
stripe/stripe-go | person/client.go | New | func New(params *stripe.PersonParams) (*stripe.Person, error) {
return getC().New(params)
} | go | func New(params *stripe.PersonParams) (*stripe.Person, error) {
return getC().New(params)
} | [
"func",
"New",
"(",
"params",
"*",
"stripe",
".",
"PersonParams",
")",
"(",
"*",
"stripe",
".",
"Person",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"New",
"(",
"params",
")",
"\n",
"}"
] | // New creates a new account person. | [
"New",
"creates",
"a",
"new",
"account",
"person",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/person/client.go#L19-L21 | train |
stripe/stripe-go | person/client.go | Get | func (c Client) Get(id string, params *stripe.PersonParams) (*stripe.Person, error) {
if params == nil {
return nil, fmt.Errorf("params cannot be nil, and params.Account must be set")
}
path := stripe.FormatURLPath("/v1/accounts/%s/persons/%s",
stripe.StringValue(params.Account), id)
person := &stripe.Person{}
err := c.B.Call(http.MethodGet, path, c.Key, params, person)
return person, err
} | go | func (c Client) Get(id string, params *stripe.PersonParams) (*stripe.Person, error) {
if params == nil {
return nil, fmt.Errorf("params cannot be nil, and params.Account must be set")
}
path := stripe.FormatURLPath("/v1/accounts/%s/persons/%s",
stripe.StringValue(params.Account), id)
person := &stripe.Person{}
err := c.B.Call(http.MethodGet, path, c.Key, params, person)
return person, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PersonParams",
")",
"(",
"*",
"stripe",
".",
"Person",
",",
"error",
")",
"{",
"if",
"params",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"E... | // Get returns the details of a account person. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"account",
"person",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/person/client.go#L37-L47 | train |
stripe/stripe-go | client/api.go | New | func New(key string, backends *stripe.Backends) *API {
api := API{}
api.Init(key, backends)
return &api
} | go | func New(key string, backends *stripe.Backends) *API {
api := API{}
api.Init(key, backends)
return &api
} | [
"func",
"New",
"(",
"key",
"string",
",",
"backends",
"*",
"stripe",
".",
"Backends",
")",
"*",
"API",
"{",
"api",
":=",
"API",
"{",
"}",
"\n",
"api",
".",
"Init",
"(",
"key",
",",
"backends",
")",
"\n",
"return",
"&",
"api",
"\n",
"}"
] | // New creates a new Stripe client with the appropriate secret key
// as well as providing the ability to override the backends as needed. | [
"New",
"creates",
"a",
"new",
"Stripe",
"client",
"with",
"the",
"appropriate",
"secret",
"key",
"as",
"well",
"as",
"providing",
"the",
"ability",
"to",
"override",
"the",
"backends",
"as",
"needed",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/client/api.go#L282-L286 | train |
stripe/stripe-go | reversal.go | UnmarshalJSON | func (r *Reversal) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type reversal Reversal
var v reversal
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Reversal(v)
return nil
} | go | func (r *Reversal) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type reversal Reversal
var v reversal
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Reversal(v)
return nil
} | [
"func",
"(",
"r",
"*",
"Reversal",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a Reversal.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Reversal",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/reversal.go#L43-L57 | train |
stripe/stripe-go | recipient.go | AppendTo | func (p *RecipientParams) AppendTo(body *form.Values, keyParts []string) {
if p.BankAccount != nil {
if p.BankAccount.Token != nil {
body.Add("bank_account", StringValue(p.BankAccount.Token))
} else {
form.AppendToPrefixed(body, p.BankAccount, append(keyParts, "bank_account"))
}
}
} | go | func (p *RecipientParams) AppendTo(body *form.Values, keyParts []string) {
if p.BankAccount != nil {
if p.BankAccount.Token != nil {
body.Add("bank_account", StringValue(p.BankAccount.Token))
} else {
form.AppendToPrefixed(body, p.BankAccount, append(keyParts, "bank_account"))
}
}
} | [
"func",
"(",
"p",
"*",
"RecipientParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"p",
".",
"BankAccount",
"!=",
"nil",
"{",
"if",
"p",
".",
"BankAccount",
".",
"Token",
"!=",
"... | // AppendTo implements some custom behavior around a recipient's bank account.
// This was probably the wrong way to go about this, but grandfather the
// behavior for the time being. | [
"AppendTo",
"implements",
"some",
"custom",
"behavior",
"around",
"a",
"recipient",
"s",
"bank",
"account",
".",
"This",
"was",
"probably",
"the",
"wrong",
"way",
"to",
"go",
"about",
"this",
"but",
"grandfather",
"the",
"behavior",
"for",
"the",
"time",
"be... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/recipient.go#L37-L45 | train |
stripe/stripe-go | recipient.go | UnmarshalJSON | func (r *Recipient) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type recipient Recipient
var v recipient
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Recipient(v)
return nil
} | go | func (r *Recipient) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type recipient Recipient
var v recipient
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Recipient(v)
return nil
} | [
"func",
"(",
"r",
"*",
"Recipient",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a Recipient.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Recipient",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/recipient.go#L81-L95 | train |
stripe/stripe-go | charge/client.go | Get | func Get(id string, params *stripe.ChargeParams) (*stripe.Charge, error) {
return getC().Get(id, params)
} | go | func Get(id string, params *stripe.ChargeParams) (*stripe.Charge, error) {
return getC().Get(id, params)
} | [
"func",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ChargeParams",
")",
"(",
"*",
"stripe",
".",
"Charge",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Get",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Get retrieves a charge. | [
"Get",
"retrieves",
"a",
"charge",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/charge/client.go#L32-L34 | train |
stripe/stripe-go | invoiceitem.go | UnmarshalJSON | func (i *InvoiceItem) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type invoiceItem InvoiceItem
var v invoiceItem
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = InvoiceItem(v)
return nil
} | go | func (i *InvoiceItem) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type invoiceItem InvoiceItem
var v invoiceItem
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = InvoiceItem(v)
return nil
} | [
"func",
"(",
"i",
"*",
"InvoiceItem",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",... | // UnmarshalJSON handles deserialization of an InvoiceItem.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"InvoiceItem",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoiceitem.go#L71-L85 | train |
stripe/stripe-go | event.go | GetObjectValue | func (e *Event) GetObjectValue(keys ...string) string {
return getValue(e.Data.Object, keys)
} | go | func (e *Event) GetObjectValue(keys ...string) string {
return getValue(e.Data.Object, keys)
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"GetObjectValue",
"(",
"keys",
"...",
"string",
")",
"string",
"{",
"return",
"getValue",
"(",
"e",
".",
"Data",
".",
"Object",
",",
"keys",
")",
"\n",
"}"
] | // GetObjectValue returns the value from the e.Data.Object bag based on the keys hierarchy. | [
"GetObjectValue",
"returns",
"the",
"value",
"from",
"the",
"e",
".",
"Data",
".",
"Object",
"bag",
"based",
"on",
"the",
"keys",
"hierarchy",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/event.go#L68-L70 | train |
stripe/stripe-go | event.go | GetPreviousValue | func (e *Event) GetPreviousValue(keys ...string) string {
return getValue(e.Data.PreviousAttributes, keys)
} | go | func (e *Event) GetPreviousValue(keys ...string) string {
return getValue(e.Data.PreviousAttributes, keys)
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"GetPreviousValue",
"(",
"keys",
"...",
"string",
")",
"string",
"{",
"return",
"getValue",
"(",
"e",
".",
"Data",
".",
"PreviousAttributes",
",",
"keys",
")",
"\n",
"}"
] | // GetPreviousValue returns the value from the e.Data.Prev bag based on the keys hierarchy. | [
"GetPreviousValue",
"returns",
"the",
"value",
"from",
"the",
"e",
".",
"Data",
".",
"Prev",
"bag",
"based",
"on",
"the",
"keys",
"hierarchy",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/event.go#L73-L75 | train |
stripe/stripe-go | event.go | UnmarshalJSON | func (e *EventData) UnmarshalJSON(data []byte) error {
type eventdata EventData
var ee eventdata
err := json.Unmarshal(data, &ee)
if err != nil {
return err
}
*e = EventData(ee)
return json.Unmarshal(e.Raw, &e.Object)
} | go | func (e *EventData) UnmarshalJSON(data []byte) error {
type eventdata EventData
var ee eventdata
err := json.Unmarshal(data, &ee)
if err != nil {
return err
}
*e = EventData(ee)
return json.Unmarshal(e.Raw, &e.Object)
} | [
"func",
"(",
"e",
"*",
"EventData",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"type",
"eventdata",
"EventData",
"\n",
"var",
"ee",
"eventdata",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"ee",
")... | // UnmarshalJSON handles deserialization of the EventData.
// This custom unmarshaling exists so that we can keep both the map and raw data. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"the",
"EventData",
".",
"This",
"custom",
"unmarshaling",
"exists",
"so",
"that",
"we",
"can",
"keep",
"both",
"the",
"map",
"and",
"raw",
"data",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/event.go#L79-L89 | train |
stripe/stripe-go | event.go | getValue | func getValue(m map[string]interface{}, keys []string) string {
node := m[keys[0]]
for i := 1; i < len(keys); i++ {
key := keys[i]
sliceNode, ok := node.([]interface{})
if ok {
intKey, err := strconv.Atoi(key)
if err != nil {
panic(fmt.Sprintf(
"Cannot access nested slice element with non-integer key: %s",
key))
}
node = sliceNode[intKey]
continue
}
mapNode, ok := node.(map[string]interface{})
if ok {
node = mapNode[key]
continue
}
panic(fmt.Sprintf(
"Cannot descend into non-map non-slice object with key: %s", key))
}
if node == nil {
return ""
}
return fmt.Sprintf("%v", node)
} | go | func getValue(m map[string]interface{}, keys []string) string {
node := m[keys[0]]
for i := 1; i < len(keys); i++ {
key := keys[i]
sliceNode, ok := node.([]interface{})
if ok {
intKey, err := strconv.Atoi(key)
if err != nil {
panic(fmt.Sprintf(
"Cannot access nested slice element with non-integer key: %s",
key))
}
node = sliceNode[intKey]
continue
}
mapNode, ok := node.(map[string]interface{})
if ok {
node = mapNode[key]
continue
}
panic(fmt.Sprintf(
"Cannot descend into non-map non-slice object with key: %s", key))
}
if node == nil {
return ""
}
return fmt.Sprintf("%v", node)
} | [
"func",
"getValue",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"keys",
"[",
"]",
"string",
")",
"string",
"{",
"node",
":=",
"m",
"[",
"keys",
"[",
"0",
"]",
"]",
"\n\n",
"for",
"i",
":=",
"1",
";",
"i",
"<",
"len",
"(",... | // getValue returns the value from the m map based on the keys. | [
"getValue",
"returns",
"the",
"value",
"from",
"the",
"m",
"map",
"based",
"on",
"the",
"keys",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/event.go#L92-L125 | train |
stripe/stripe-go | bitcoinreceiver.go | UnmarshalJSON | func (r *BitcoinReceiver) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type bitcoinReceiver BitcoinReceiver
var v bitcoinReceiver
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = BitcoinReceiver(v)
return nil
} | go | func (r *BitcoinReceiver) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type bitcoinReceiver BitcoinReceiver
var v bitcoinReceiver
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = BitcoinReceiver(v)
return nil
} | [
"func",
"(",
"r",
"*",
"BitcoinReceiver",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of a BitcoinReceiver.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"BitcoinReceiver",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bitcoinreceiver.go#L49-L63 | train |
stripe/stripe-go | file.go | GetBody | func (f *FileParams) GetBody() (*bytes.Buffer, string, error) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
if f.Purpose != nil {
err := writer.WriteField("purpose", StringValue(f.Purpose))
if err != nil {
return nil, "", err
}
}
if f.FileReader != nil && f.Filename != nil {
part, err := writer.CreateFormFile("file", filepath.Base(StringValue(f.Filename)))
if err != nil {
return nil, "", err
}
_, err = io.Copy(part, f.FileReader)
if err != nil {
return nil, "", err
}
}
if f.FileLinkData != nil {
values := &form.Values{}
form.AppendToPrefixed(values, f.FileLinkData, []string{"file_link_data"})
params, err := url.ParseQuery(values.Encode())
if err != nil {
return nil, "", err
}
for key, values := range params {
err := writer.WriteField(key, values[0])
if err != nil {
return nil, "", err
}
}
}
err := writer.Close()
if err != nil {
return nil, "", err
}
return body, writer.Boundary(), nil
} | go | func (f *FileParams) GetBody() (*bytes.Buffer, string, error) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
if f.Purpose != nil {
err := writer.WriteField("purpose", StringValue(f.Purpose))
if err != nil {
return nil, "", err
}
}
if f.FileReader != nil && f.Filename != nil {
part, err := writer.CreateFormFile("file", filepath.Base(StringValue(f.Filename)))
if err != nil {
return nil, "", err
}
_, err = io.Copy(part, f.FileReader)
if err != nil {
return nil, "", err
}
}
if f.FileLinkData != nil {
values := &form.Values{}
form.AppendToPrefixed(values, f.FileLinkData, []string{"file_link_data"})
params, err := url.ParseQuery(values.Encode())
if err != nil {
return nil, "", err
}
for key, values := range params {
err := writer.WriteField(key, values[0])
if err != nil {
return nil, "", err
}
}
}
err := writer.Close()
if err != nil {
return nil, "", err
}
return body, writer.Boundary(), nil
} | [
"func",
"(",
"f",
"*",
"FileParams",
")",
"GetBody",
"(",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"string",
",",
"error",
")",
"{",
"body",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"writer",
":=",
"multipart",
".",
"NewWriter",
"(",
... | // GetBody gets an appropriate multipart form payload to use in a request body
// to create a new file. | [
"GetBody",
"gets",
"an",
"appropriate",
"multipart",
"form",
"payload",
"to",
"use",
"in",
"a",
"request",
"body",
"to",
"create",
"a",
"new",
"file",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/file.go#L84-L129 | train |
stripe/stripe-go | file.go | UnmarshalJSON | func (f *File) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
f.ID = id
return nil
}
type file File
var v file
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*f = File(v)
return nil
} | go | func (f *File) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
f.ID = id
return nil
}
type file File
var v file
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*f = File(v)
return nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"f",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\... | // UnmarshalJSON handles deserialization of a File.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"File",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/file.go#L134-L148 | train |
stripe/stripe-go | card/client.go | List | func (c Client) List(listParams *stripe.CardListParams) *Iter {
var path string
var outerErr error
// Because the external accounts and sources endpoints can return non-card
// objects, CardListParam's `AppendTo` will add the filter `object=card` to
// make sure that only cards come back with the response.
if listParams == nil {
outerErr = errors.New("params should not be nil")
} else if listParams.Account != nil {
path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts",
stripe.StringValue(listParams.Account))
} else if listParams.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources",
stripe.StringValue(listParams.Customer))
} else if listParams.Recipient != nil {
path = stripe.FormatURLPath("/v1/recipients/%s/cards", stripe.StringValue(listParams.Recipient))
} else {
outerErr = errors.New("Invalid card params: either account, customer or recipient need to be set")
}
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.CardList{}
if outerErr != nil {
return nil, list.ListMeta, outerErr
}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | go | func (c Client) List(listParams *stripe.CardListParams) *Iter {
var path string
var outerErr error
// Because the external accounts and sources endpoints can return non-card
// objects, CardListParam's `AppendTo` will add the filter `object=card` to
// make sure that only cards come back with the response.
if listParams == nil {
outerErr = errors.New("params should not be nil")
} else if listParams.Account != nil {
path = stripe.FormatURLPath("/v1/accounts/%s/external_accounts",
stripe.StringValue(listParams.Account))
} else if listParams.Customer != nil {
path = stripe.FormatURLPath("/v1/customers/%s/sources",
stripe.StringValue(listParams.Customer))
} else if listParams.Recipient != nil {
path = stripe.FormatURLPath("/v1/recipients/%s/cards", stripe.StringValue(listParams.Recipient))
} else {
outerErr = errors.New("Invalid card params: either account, customer or recipient need to be set")
}
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.CardList{}
if outerErr != nil {
return nil, list.ListMeta, outerErr
}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | [
"func",
"(",
"c",
"Client",
")",
"List",
"(",
"listParams",
"*",
"stripe",
".",
"CardListParams",
")",
"*",
"Iter",
"{",
"var",
"path",
"string",
"\n",
"var",
"outerErr",
"error",
"\n\n",
"// Because the external accounts and sources endpoints can return non-card",
... | // List returns a list of cards. | [
"List",
"returns",
"a",
"list",
"of",
"cards",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/card/client.go#L151-L188 | train |
stripe/stripe-go | application.go | UnmarshalJSON | func (a *Application) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
a.ID = id
return nil
}
type application Application
var v application
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*a = Application(v)
return nil
} | go | func (a *Application) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
a.ID = id
return nil
}
type application Application
var v application
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*a = Application(v)
return nil
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"a",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",... | // UnmarshalJSON handles deserialization of an Application.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"Application",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/application.go#L14-L28 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.