id
int32 0
167k
| 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
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
148,300 | 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",
";",
"i",
"<",
"len",
"(",
"parts",
")",
";",
"i",
"++",
"{",
"key",
"+=",
"\"",
"\"",
"+",
"parts",
"[",
"i",
"]",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"key",
"\n",
"}"
] | // 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",
"encoding",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L121-L131 |
148,301 | 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",
"(",
")",
"\n",
"f",
":=",
"encoderCache",
".",
"m",
"[",
"t",
"]",
"\n",
"encoderCache",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"f",
"!=",
"nil",
"{",
"return",
"f",
"\n",
"}",
"\n\n",
"// 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",
")",
"\n\n",
"encoderCache",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"encoderCache",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"encoderCache",
".",
"m",
"==",
"nil",
"{",
"encoderCache",
".",
"m",
"=",
"make",
"(",
"map",
"[",
"reflect",
".",
"Type",
"]",
"encoderFunc",
")",
"\n",
"}",
"\n",
"encoderCache",
".",
"m",
"[",
"t",
"]",
"=",
"f",
"\n\n",
"return",
"f",
"\n",
"}"
] | // 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",
"is",
"built",
"it",
"s",
"stored",
"back",
"to",
"the",
"cache",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L260-L287 |
148,302 | 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 |
148,303 | 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",
",",
"\"",
"\"",
")",
")",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // 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 |
148,304 | 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",
"}",
"\n\n",
"type",
"bankAccount",
"BankAccount",
"\n",
"var",
"v",
"bankAccount",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"b",
"=",
"BankAccount",
"(",
"v",
")",
"\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 |
148,305 | 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",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"fileLink",
":=",
"&",
"stripe",
".",
"FileLink",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"fileLink",
")",
"\n",
"return",
"fileLink",
",",
"err",
"\n",
"}"
] | // Get retrieves a file link. | [
"Get",
"retrieves",
"a",
"file",
"link",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink/client.go#L37-L42 |
148,306 | 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 |
148,307 | 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",
",",
"b",
"*",
"form",
".",
"Values",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"stripe",
".",
"ListMeta",
",",
"error",
")",
"{",
"list",
":=",
"&",
"stripe",
".",
"FileLinkList",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"CallRaw",
"(",
"http",
".",
"MethodGet",
",",
"\"",
"\"",
",",
"c",
".",
"Key",
",",
"b",
",",
"p",
",",
"list",
")",
"\n\n",
"ret",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"list",
".",
"Data",
")",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"list",
".",
"Data",
"{",
"ret",
"[",
"i",
"]",
"=",
"v",
"\n",
"}",
"\n\n",
"return",
"ret",
",",
"list",
".",
"ListMeta",
",",
"err",
"\n",
"}",
")",
"}",
"\n",
"}"
] | // 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 |
148,308 | 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",
"type",
"sku",
"SKU",
"\n",
"var",
"v",
"sku",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"s",
"=",
"SKU",
"(",
"v",
")",
"\n",
"return",
"nil",
"\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 |
148,309 | 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",
"}",
"\n\n",
"type",
"feeRefund",
"FeeRefund",
"\n",
"var",
"v",
"feeRefund",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"r",
"=",
"FeeRefund",
"(",
"v",
")",
"\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 |
148,310 | 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",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"vl",
":=",
"&",
"stripe",
".",
"RadarValueList",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodPost",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"vl",
")",
"\n",
"return",
"vl",
",",
"err",
"\n",
"}"
] | // 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 |
148,311 | 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 |
148,312 | 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",
"}",
"\n\n",
"type",
"person",
"Person",
"\n",
"var",
"v",
"person",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"Person",
"(",
"v",
")",
"\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 |
148,313 | 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",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"\"",
"\"",
")",
")",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // 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 |
148,314 | 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\n",
"type",
"card",
"Card",
"\n",
"var",
"v",
"card",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"Card",
"(",
"v",
")",
"\n",
"return",
"nil",
"\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 |
148,315 | 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\n",
"type",
"taxid",
"TaxID",
"\n",
"var",
"v",
"taxid",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"TaxID",
"(",
"v",
")",
"\n",
"return",
"nil",
"\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 |
148,316 | 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",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"location",
":=",
"&",
"stripe",
".",
"TerminalLocation",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"location",
")",
"\n",
"return",
"location",
",",
"err",
"\n",
"}"
] | // 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 |
148,317 | 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 |
148,318 | 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 |
148,319 | 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",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"recipient",
":=",
"&",
"stripe",
".",
"Recipient",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"recipient",
")",
"\n",
"return",
"recipient",
",",
"err",
"\n",
"}"
] | // 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 |
148,320 | 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",
"(",
"listParams",
".",
"Schedule",
")",
")",
"\n\n",
"return",
"&",
"Iter",
"{",
"stripe",
".",
"GetIter",
"(",
"listParams",
",",
"func",
"(",
"p",
"*",
"stripe",
".",
"Params",
",",
"b",
"*",
"form",
".",
"Values",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"stripe",
".",
"ListMeta",
",",
"error",
")",
"{",
"list",
":=",
"&",
"stripe",
".",
"SubscriptionScheduleRevisionList",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"CallRaw",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"b",
",",
"p",
",",
"list",
")",
"\n\n",
"ret",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"list",
".",
"Data",
")",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"list",
".",
"Data",
"{",
"ret",
"[",
"i",
"]",
"=",
"v",
"\n",
"}",
"\n\n",
"return",
"ret",
",",
"list",
".",
"ListMeta",
",",
"err",
"\n",
"}",
")",
"}",
"\n",
"}"
] | // 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 |
148,321 | 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",
"}",
"\n\n",
"type",
"session",
"CheckoutSession",
"\n",
"var",
"v",
"session",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"p",
"=",
"CheckoutSession",
"(",
"v",
")",
"\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",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/checkout_session.go#L122-L136 |
148,322 | 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",
"}",
"\n\n",
"type",
"product",
"Product",
"\n",
"var",
"v",
"product",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"p",
"=",
"Product",
"(",
"v",
")",
"\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 |
148,323 | 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",
"}",
"\n\n",
"type",
"fileLink",
"FileLink",
"\n",
"var",
"v",
"fileLink",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"FileLink",
"(",
"v",
")",
"\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 |
148,324 | 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",
"(",
"body",
",",
"keyParts",
")",
"\n",
"}",
"\n",
"}"
] | // 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 |
148,325 | 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",
"}",
"\n\n",
"type",
"paymentSource",
"PaymentSource",
"\n",
"var",
"v",
"paymentSource",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"err",
"error",
"\n",
"*",
"s",
"=",
"PaymentSource",
"(",
"v",
")",
"\n\n",
"switch",
"s",
".",
"Type",
"{",
"case",
"PaymentSourceTypeBankAccount",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"s",
".",
"BankAccount",
")",
"\n",
"case",
"PaymentSourceTypeBitcoinReceiver",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"s",
".",
"BitcoinReceiver",
")",
"\n",
"case",
"PaymentSourceTypeCard",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"s",
".",
"Card",
")",
"\n",
"case",
"PaymentSourceTypeObject",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"s",
".",
"SourceObject",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\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 |
148,326 | 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",
"=",
"struct",
"{",
"*",
"BitcoinReceiver",
"\n",
"Type",
"PaymentSourceType",
"`json:\"object\"`",
"\n",
"}",
"{",
"BitcoinReceiver",
":",
"s",
".",
"BitcoinReceiver",
",",
"Type",
":",
"s",
".",
"Type",
",",
"}",
"\n",
"case",
"PaymentSourceTypeCard",
":",
"var",
"customerID",
"*",
"string",
"\n",
"if",
"s",
".",
"Card",
".",
"Customer",
"!=",
"nil",
"{",
"customerID",
"=",
"&",
"s",
".",
"Card",
".",
"Customer",
".",
"ID",
"\n",
"}",
"\n\n",
"target",
"=",
"struct",
"{",
"*",
"Card",
"\n",
"Customer",
"*",
"string",
"`json:\"customer\"`",
"\n",
"Type",
"PaymentSourceType",
"`json:\"object\"`",
"\n",
"}",
"{",
"Card",
":",
"s",
".",
"Card",
",",
"Customer",
":",
"customerID",
",",
"Type",
":",
"s",
".",
"Type",
",",
"}",
"\n",
"case",
"PaymentSourceTypeAccount",
":",
"target",
"=",
"struct",
"{",
"ID",
"string",
"`json:\"id\"`",
"\n",
"Type",
"PaymentSourceType",
"`json:\"object\"`",
"\n",
"}",
"{",
"ID",
":",
"s",
".",
"ID",
",",
"Type",
":",
"s",
".",
"Type",
",",
"}",
"\n",
"case",
"PaymentSourceTypeBankAccount",
":",
"var",
"customerID",
"*",
"string",
"\n",
"if",
"s",
".",
"BankAccount",
".",
"Customer",
"!=",
"nil",
"{",
"customerID",
"=",
"&",
"s",
".",
"BankAccount",
".",
"Customer",
".",
"ID",
"\n",
"}",
"\n\n",
"target",
"=",
"struct",
"{",
"*",
"BankAccount",
"\n",
"Customer",
"*",
"string",
"`json:\"customer\"`",
"\n",
"Type",
"PaymentSourceType",
"`json:\"object\"`",
"\n",
"}",
"{",
"BankAccount",
":",
"s",
".",
"BankAccount",
",",
"Customer",
":",
"customerID",
",",
"Type",
":",
"s",
".",
"Type",
",",
"}",
"\n",
"case",
"\"",
"\"",
":",
"target",
"=",
"s",
".",
"ID",
"\n",
"}",
"\n\n",
"return",
"json",
".",
"Marshal",
"(",
"target",
")",
"\n",
"}"
] | // 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 |
148,327 | 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",
"\n",
"}",
"\n\n",
"type",
"revision",
"SubscriptionScheduleRevision",
"\n",
"var",
"v",
"revision",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"s",
"=",
"SubscriptionScheduleRevision",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // 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",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subschedulerevision.go#L43-L57 |
148,328 | 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",
",",
"&",
"ee",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"*",
"e",
"=",
"EphemeralKey",
"(",
"ee",
")",
"\n",
"}",
"\n\n",
"e",
".",
"RawJSON",
"=",
"data",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // 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",
"to",
"the",
"frontend",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/ephemeralkey.go#L40-L51 |
148,329 | 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",
"}",
"\n\n",
"type",
"recipientTransfer",
"RecipientTransfer",
"\n",
"var",
"v",
"recipientTransfer",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"t",
"=",
"RecipientTransfer",
"(",
"v",
")",
"\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 |
148,330 | 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",
"\n",
"}",
"\n\n",
"type",
"recipientTransferDestination",
"RecipientTransferDestination",
"\n",
"var",
"v",
"recipientTransferDestination",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"err",
"error",
"\n",
"*",
"d",
"=",
"RecipientTransferDestination",
"(",
"v",
")",
"\n\n",
"switch",
"d",
".",
"Type",
"{",
"case",
"RecipientTransferDestinationBankAccount",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"d",
".",
"BankAccount",
")",
"\n",
"case",
"RecipientTransferDestinationCard",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"d",
".",
"Card",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // 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 |
148,331 | 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 |
148,332 | 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",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"fee",
":=",
"&",
"stripe",
".",
"PaymentMethod",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"fee",
")",
"\n",
"return",
"fee",
",",
"err",
"\n",
"}"
] | // 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 |
148,333 | 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 |
148,334 | 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",
"}",
"\n\n",
"type",
"issuingCard",
"IssuingCard",
"\n",
"var",
"v",
"issuingCard",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"IssuingCard",
"(",
"v",
")",
"\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 |
148,335 | 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",
"}",
"\n\n",
"type",
"issuingDispute",
"IssuingDispute",
"\n",
"var",
"v",
"issuingDispute",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"IssuingDispute",
"(",
"v",
")",
"\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 |
148,336 | 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",
"}",
"\n\n",
"type",
"schedule",
"SubscriptionSchedule",
"\n",
"var",
"v",
"schedule",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"s",
"=",
"SubscriptionSchedule",
"(",
"v",
")",
"\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",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subschedule.go#L187-L201 |
148,337 | 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",
"}",
"\n\n",
"type",
"taxrate",
"TaxRate",
"\n",
"var",
"v",
"taxrate",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"TaxRate",
"(",
"v",
")",
"\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 |
148,338 | 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",
",",
"params",
")",
"\n",
"}"
] | // 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 |
148,339 | 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",
"\n",
"}",
"\n\n",
"type",
"sigmaScheduledQueryRun",
"SigmaScheduledQueryRun",
"\n",
"var",
"v",
"sigmaScheduledQueryRun",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"SigmaScheduledQueryRun",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // 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",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/sigma_scheduledqueryrun.go#L50-L64 |
148,340 | 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 |
148,341 | 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",
"}",
"\n\n",
"type",
"customer",
"Customer",
"\n",
"var",
"v",
"customer",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"Customer",
"(",
"v",
")",
"\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 |
148,342 | 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",
"}",
"\n\n",
"type",
"subscription",
"Subscription",
"\n",
"var",
"v",
"subscription",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"s",
"=",
"Subscription",
"(",
"v",
")",
"\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 |
148,343 | 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 |
148,344 | 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 |
148,345 | 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",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"authorization",
":=",
"&",
"stripe",
".",
"IssuingAuthorization",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"authorization",
")",
"\n",
"return",
"authorization",
",",
"err",
"\n",
"}"
] | // 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 |
148,346 | 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",
")",
"\n",
"}"
] | // 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 |
148,347 | 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",
"}",
"\n\n",
"type",
"refund",
"Refund",
"\n",
"var",
"v",
"refund",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"r",
"=",
"Refund",
"(",
"v",
")",
"\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 |
148,348 | 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",
"}",
"\n\n",
"type",
"applicationFee",
"ApplicationFee",
"\n",
"var",
"v",
"applicationFee",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"f",
"=",
"ApplicationFee",
"(",
"v",
")",
"\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 |
148,349 | 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",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"for",
"k",
",",
"vs",
":=",
"range",
"p",
".",
"TypeData",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"StringValue",
"(",
"p",
".",
"Type",
")",
",",
"k",
")",
")",
",",
"vs",
")",
"\n",
"}",
"\n",
"}"
] | // 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 |
148,350 | 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",
"}",
"\n\n",
"type",
"endpoint",
"WebhookEndpoint",
"\n",
"var",
"v",
"endpoint",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"WebhookEndpoint",
"(",
"v",
")",
"\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 |
148,351 | 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",
"}",
"\n\n",
"type",
"paymentintent",
"PaymentIntent",
"\n",
"var",
"v",
"paymentintent",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"p",
"=",
"PaymentIntent",
"(",
"v",
")",
"\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",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentintent.go#L201-L215 |
148,352 | 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",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"transaction",
":=",
"&",
"stripe",
".",
"IssuingTransaction",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"transaction",
")",
"\n",
"return",
"transaction",
",",
"err",
"\n",
"}"
] | // 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 |
148,353 | 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",
")",
"\n",
"}"
] | // 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 |
148,354 | 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",
")",
"\n",
"}"
] | // VoidCreditNote voids a credit note. | [
"VoidCreditNote",
"voids",
"a",
"credit",
"note",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/creditnote/client.go#L76-L78 |
148,355 | 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",
"}",
"\n\n",
"type",
"issuingCardholder",
"IssuingCardholder",
"\n",
"var",
"v",
"issuingCardholder",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"IssuingCardholder",
"(",
"v",
")",
"\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 |
148,356 | 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 |
148,357 | 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",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"stripe",
".",
"StringValue",
"(",
"params",
".",
"Account",
")",
",",
"id",
")",
"\n",
"person",
":=",
"&",
"stripe",
".",
"Person",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"person",
")",
"\n",
"return",
"person",
",",
"err",
"\n",
"}"
] | // 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 |
148,358 | 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 |
148,359 | 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",
"}",
"\n\n",
"type",
"reversal",
"Reversal",
"\n",
"var",
"v",
"reversal",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"r",
"=",
"Reversal",
"(",
"v",
")",
"\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 |
148,360 | 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",
"!=",
"nil",
"{",
"body",
".",
"Add",
"(",
"\"",
"\"",
",",
"StringValue",
"(",
"p",
".",
"BankAccount",
".",
"Token",
")",
")",
"\n",
"}",
"else",
"{",
"form",
".",
"AppendToPrefixed",
"(",
"body",
",",
"p",
".",
"BankAccount",
",",
"append",
"(",
"keyParts",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // 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",
"being",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/recipient.go#L37-L45 |
148,361 | 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",
"}",
"\n\n",
"type",
"recipient",
"Recipient",
"\n",
"var",
"v",
"recipient",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"r",
"=",
"Recipient",
"(",
"v",
")",
"\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 |
148,362 | 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 |
148,363 | 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",
"}",
"\n\n",
"type",
"invoiceItem",
"InvoiceItem",
"\n",
"var",
"v",
"invoiceItem",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"InvoiceItem",
"(",
"v",
")",
"\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 |
148,364 | 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 |
148,365 | 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 |
148,366 | 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",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"e",
"=",
"EventData",
"(",
"ee",
")",
"\n",
"return",
"json",
".",
"Unmarshal",
"(",
"e",
".",
"Raw",
",",
"&",
"e",
".",
"Object",
")",
"\n",
"}"
] | // 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 |
148,367 | 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",
"(",
"keys",
")",
";",
"i",
"++",
"{",
"key",
":=",
"keys",
"[",
"i",
"]",
"\n\n",
"sliceNode",
",",
"ok",
":=",
"node",
".",
"(",
"[",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"ok",
"{",
"intKey",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"key",
")",
")",
"\n",
"}",
"\n",
"node",
"=",
"sliceNode",
"[",
"intKey",
"]",
"\n",
"continue",
"\n",
"}",
"\n\n",
"mapNode",
",",
"ok",
":=",
"node",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"if",
"ok",
"{",
"node",
"=",
"mapNode",
"[",
"key",
"]",
"\n",
"continue",
"\n",
"}",
"\n\n",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"key",
")",
")",
"\n",
"}",
"\n\n",
"if",
"node",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"node",
")",
"\n",
"}"
] | // 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 |
148,368 | 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",
"}",
"\n\n",
"type",
"bitcoinReceiver",
"BitcoinReceiver",
"\n",
"var",
"v",
"bitcoinReceiver",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"r",
"=",
"BitcoinReceiver",
"(",
"v",
")",
"\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 |
148,369 | 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",
"(",
"body",
")",
"\n\n",
"if",
"f",
".",
"Purpose",
"!=",
"nil",
"{",
"err",
":=",
"writer",
".",
"WriteField",
"(",
"\"",
"\"",
",",
"StringValue",
"(",
"f",
".",
"Purpose",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"f",
".",
"FileReader",
"!=",
"nil",
"&&",
"f",
".",
"Filename",
"!=",
"nil",
"{",
"part",
",",
"err",
":=",
"writer",
".",
"CreateFormFile",
"(",
"\"",
"\"",
",",
"filepath",
".",
"Base",
"(",
"StringValue",
"(",
"f",
".",
"Filename",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"io",
".",
"Copy",
"(",
"part",
",",
"f",
".",
"FileReader",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"f",
".",
"FileLinkData",
"!=",
"nil",
"{",
"values",
":=",
"&",
"form",
".",
"Values",
"{",
"}",
"\n",
"form",
".",
"AppendToPrefixed",
"(",
"values",
",",
"f",
".",
"FileLinkData",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
")",
"\n\n",
"params",
",",
"err",
":=",
"url",
".",
"ParseQuery",
"(",
"values",
".",
"Encode",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"for",
"key",
",",
"values",
":=",
"range",
"params",
"{",
"err",
":=",
"writer",
".",
"WriteField",
"(",
"key",
",",
"values",
"[",
"0",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"err",
":=",
"writer",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"body",
",",
"writer",
".",
"Boundary",
"(",
")",
",",
"nil",
"\n",
"}"
] | // 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 |
148,370 | 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\n",
"type",
"file",
"File",
"\n",
"var",
"v",
"file",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"f",
"=",
"File",
"(",
"v",
")",
"\n",
"return",
"nil",
"\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 |
148,371 | 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",
"// 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",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"listParams",
".",
"Account",
"!=",
"nil",
"{",
"path",
"=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"stripe",
".",
"StringValue",
"(",
"listParams",
".",
"Account",
")",
")",
"\n",
"}",
"else",
"if",
"listParams",
".",
"Customer",
"!=",
"nil",
"{",
"path",
"=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"stripe",
".",
"StringValue",
"(",
"listParams",
".",
"Customer",
")",
")",
"\n",
"}",
"else",
"if",
"listParams",
".",
"Recipient",
"!=",
"nil",
"{",
"path",
"=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"stripe",
".",
"StringValue",
"(",
"listParams",
".",
"Recipient",
")",
")",
"\n",
"}",
"else",
"{",
"outerErr",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Iter",
"{",
"stripe",
".",
"GetIter",
"(",
"listParams",
",",
"func",
"(",
"p",
"*",
"stripe",
".",
"Params",
",",
"b",
"*",
"form",
".",
"Values",
")",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"stripe",
".",
"ListMeta",
",",
"error",
")",
"{",
"list",
":=",
"&",
"stripe",
".",
"CardList",
"{",
"}",
"\n\n",
"if",
"outerErr",
"!=",
"nil",
"{",
"return",
"nil",
",",
"list",
".",
"ListMeta",
",",
"outerErr",
"\n",
"}",
"\n\n",
"err",
":=",
"c",
".",
"B",
".",
"CallRaw",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"b",
",",
"p",
",",
"list",
")",
"\n\n",
"ret",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"list",
".",
"Data",
")",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"list",
".",
"Data",
"{",
"ret",
"[",
"i",
"]",
"=",
"v",
"\n",
"}",
"\n\n",
"return",
"ret",
",",
"list",
".",
"ListMeta",
",",
"err",
"\n",
"}",
")",
"}",
"\n",
"}"
] | // 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 |
148,372 | 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",
"}",
"\n\n",
"type",
"application",
"Application",
"\n",
"var",
"v",
"application",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"a",
"=",
"Application",
"(",
"v",
")",
"\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 |
148,373 | stripe/stripe-go | customer/client.go | Update | func (c Client) Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
path := stripe.FormatURLPath("/v1/customers/%s", id)
cust := &stripe.Customer{}
err := c.B.Call(http.MethodPost, path, c.Key, params, cust)
return cust, err
} | go | func (c Client) Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
path := stripe.FormatURLPath("/v1/customers/%s", id)
cust := &stripe.Customer{}
err := c.B.Call(http.MethodPost, path, c.Key, params, cust)
return cust, err
} | [
"func",
"(",
"c",
"Client",
")",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"CustomerParams",
")",
"(",
"*",
"stripe",
".",
"Customer",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"cust",
":=",
"&",
"stripe",
".",
"Customer",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodPost",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"cust",
")",
"\n",
"return",
"cust",
",",
"err",
"\n",
"}"
] | // Update updates a customer's properties. | [
"Update",
"updates",
"a",
"customer",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/customer/client.go#L48-L53 |
148,374 | stripe/stripe-go | customer/client.go | Del | func Del(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
return getC().Del(id, params)
} | go | func Del(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
return getC().Del(id, params)
} | [
"func",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"CustomerParams",
")",
"(",
"*",
"stripe",
".",
"Customer",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Del",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Del removes a customer. | [
"Del",
"removes",
"a",
"customer",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/customer/client.go#L56-L58 |
148,375 | stripe/stripe-go | paymentsource/client.go | New | func New(params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
return getC().New(params)
} | go | func New(params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
return getC().New(params)
} | [
"func",
"New",
"(",
"params",
"*",
"stripe",
".",
"CustomerSourceParams",
")",
"(",
"*",
"stripe",
".",
"PaymentSource",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"New",
"(",
"params",
")",
"\n",
"}"
] | // New creates a new source for a customer. | [
"New",
"creates",
"a",
"new",
"source",
"for",
"a",
"customer",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentsource/client.go#L19-L21 |
148,376 | stripe/stripe-go | creditnote.go | UnmarshalJSON | func (i *CreditNote) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type note CreditNote
var v note
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = CreditNote(v)
return nil
} | go | func (i *CreditNote) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type note CreditNote
var v note
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = CreditNote(v)
return nil
} | [
"func",
"(",
"i",
"*",
"CreditNote",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"note",
"CreditNote",
"\n",
"var",
"v",
"note",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"CreditNote",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of a CreditNote.
// 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",
"CreditNote",
".",
"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/creditnote.go#L89-L103 |
148,377 | stripe/stripe-go | bitcointransaction.go | UnmarshalJSON | func (bt *BitcoinTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
bt.ID = id
return nil
}
type bitcoinTransaction BitcoinTransaction
var v bitcoinTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*bt = BitcoinTransaction(v)
return nil
} | go | func (bt *BitcoinTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
bt.ID = id
return nil
}
type bitcoinTransaction BitcoinTransaction
var v bitcoinTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*bt = BitcoinTransaction(v)
return nil
} | [
"func",
"(",
"bt",
"*",
"BitcoinTransaction",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"bt",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"bitcoinTransaction",
"BitcoinTransaction",
"\n",
"var",
"v",
"bitcoinTransaction",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"bt",
"=",
"BitcoinTransaction",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of a BitcoinTransaction.
// 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",
"BitcoinTransaction",
".",
"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/bitcointransaction.go#L35-L49 |
148,378 | stripe/stripe-go | invoice.go | UnmarshalJSON | func (i *Invoice) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type invoice Invoice
var v invoice
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = Invoice(v)
return nil
} | go | func (i *Invoice) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type invoice Invoice
var v invoice
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = Invoice(v)
return nil
} | [
"func",
"(",
"i",
"*",
"Invoice",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"invoice",
"Invoice",
"\n",
"var",
"v",
"invoice",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"Invoice",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of an Invoice.
// 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",
"Invoice",
".",
"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/invoice.go#L340-L354 |
148,379 | stripe/stripe-go | params.go | AppendTo | func (v ExtraValues) AppendTo(body *form.Values, keyParts []string) {
for k, vs := range v.Values {
for _, v := range vs {
body.Add(form.FormatKey(append(keyParts, k)), v)
}
}
} | go | func (v ExtraValues) AppendTo(body *form.Values, keyParts []string) {
for k, vs := range v.Values {
for _, v := range vs {
body.Add(form.FormatKey(append(keyParts, k)), v)
}
}
} | [
"func",
"(",
"v",
"ExtraValues",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"for",
"k",
",",
"vs",
":=",
"range",
"v",
".",
"Values",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"vs",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"k",
")",
")",
",",
"v",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // AppendTo implements custom form encoding for extra parameter values. | [
"AppendTo",
"implements",
"custom",
"form",
"encoding",
"for",
"extra",
"parameter",
"values",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L37-L43 |
148,380 | stripe/stripe-go | params.go | AddFilter | func (f *Filters) AddFilter(key, op, value string) {
filter := &filter{Key: key, Op: op, Val: value}
f.f = append(f.f, filter)
} | go | func (f *Filters) AddFilter(key, op, value string) {
filter := &filter{Key: key, Op: op, Val: value}
f.f = append(f.f, filter)
} | [
"func",
"(",
"f",
"*",
"Filters",
")",
"AddFilter",
"(",
"key",
",",
"op",
",",
"value",
"string",
")",
"{",
"filter",
":=",
"&",
"filter",
"{",
"Key",
":",
"key",
",",
"Op",
":",
"op",
",",
"Val",
":",
"value",
"}",
"\n",
"f",
".",
"f",
"=",
"append",
"(",
"f",
".",
"f",
",",
"filter",
")",
"\n",
"}"
] | // AddFilter adds a new filter with a given key, op and value. | [
"AddFilter",
"adds",
"a",
"new",
"filter",
"with",
"a",
"given",
"key",
"op",
"and",
"value",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L51-L54 |
148,381 | stripe/stripe-go | params.go | AppendTo | func (f Filters) AppendTo(body *form.Values, keyParts []string) {
if len(f.f) > 0 {
for _, v := range f.f {
if len(v.Op) > 0 {
body.Add(form.FormatKey(append(keyParts, v.Key, v.Op)), v.Val)
} else {
body.Add(form.FormatKey(append(keyParts, v.Key)), v.Val)
}
}
}
} | go | func (f Filters) AppendTo(body *form.Values, keyParts []string) {
if len(f.f) > 0 {
for _, v := range f.f {
if len(v.Op) > 0 {
body.Add(form.FormatKey(append(keyParts, v.Key, v.Op)), v.Val)
} else {
body.Add(form.FormatKey(append(keyParts, v.Key)), v.Val)
}
}
}
} | [
"func",
"(",
"f",
"Filters",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"f",
".",
"f",
")",
">",
"0",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"f",
".",
"f",
"{",
"if",
"len",
"(",
"v",
".",
"Op",
")",
">",
"0",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"v",
".",
"Key",
",",
"v",
".",
"Op",
")",
")",
",",
"v",
".",
"Val",
")",
"\n",
"}",
"else",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"v",
".",
"Key",
")",
")",
",",
"v",
".",
"Val",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // AppendTo implements custom form encoding for filters. | [
"AppendTo",
"implements",
"custom",
"form",
"encoding",
"for",
"filters",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L57-L67 |
148,382 | stripe/stripe-go | params.go | ToParams | func (p *ListParams) ToParams() *Params {
return &Params{
Context: p.Context,
StripeAccount: p.StripeAccount,
}
} | go | func (p *ListParams) ToParams() *Params {
return &Params{
Context: p.Context,
StripeAccount: p.StripeAccount,
}
} | [
"func",
"(",
"p",
"*",
"ListParams",
")",
"ToParams",
"(",
")",
"*",
"Params",
"{",
"return",
"&",
"Params",
"{",
"Context",
":",
"p",
".",
"Context",
",",
"StripeAccount",
":",
"p",
".",
"StripeAccount",
",",
"}",
"\n",
"}"
] | // ToParams converts a ListParams to a Params by moving over any fields that
// have valid targets in the new type. This is useful because fields in
// Params can be injected directly into an http.Request while generally
// ListParams is only used to build a set of parameters. | [
"ToParams",
"converts",
"a",
"ListParams",
"to",
"a",
"Params",
"by",
"moving",
"over",
"any",
"fields",
"that",
"have",
"valid",
"targets",
"in",
"the",
"new",
"type",
".",
"This",
"is",
"useful",
"because",
"fields",
"in",
"Params",
"can",
"be",
"injected",
"directly",
"into",
"an",
"http",
".",
"Request",
"while",
"generally",
"ListParams",
"is",
"only",
"used",
"to",
"build",
"a",
"set",
"of",
"parameters",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L139-L144 |
148,383 | stripe/stripe-go | params.go | AddExtra | func (p *Params) AddExtra(key, value string) {
if p.Extra == nil {
p.Extra = &ExtraValues{Values: make(url.Values)}
}
p.Extra.Add(key, value)
} | go | func (p *Params) AddExtra(key, value string) {
if p.Extra == nil {
p.Extra = &ExtraValues{Values: make(url.Values)}
}
p.Extra.Add(key, value)
} | [
"func",
"(",
"p",
"*",
"Params",
")",
"AddExtra",
"(",
"key",
",",
"value",
"string",
")",
"{",
"if",
"p",
".",
"Extra",
"==",
"nil",
"{",
"p",
".",
"Extra",
"=",
"&",
"ExtraValues",
"{",
"Values",
":",
"make",
"(",
"url",
".",
"Values",
")",
"}",
"\n",
"}",
"\n\n",
"p",
".",
"Extra",
".",
"Add",
"(",
"key",
",",
"value",
")",
"\n",
"}"
] | // AddExtra adds a new arbitrary key-value pair to the request data | [
"AddExtra",
"adds",
"a",
"new",
"arbitrary",
"key",
"-",
"value",
"pair",
"to",
"the",
"request",
"data"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L188-L194 |
148,384 | stripe/stripe-go | params.go | AddMetadata | func (p *Params) AddMetadata(key, value string) {
if p.Metadata == nil {
p.Metadata = make(map[string]string)
}
p.Metadata[key] = value
} | go | func (p *Params) AddMetadata(key, value string) {
if p.Metadata == nil {
p.Metadata = make(map[string]string)
}
p.Metadata[key] = value
} | [
"func",
"(",
"p",
"*",
"Params",
")",
"AddMetadata",
"(",
"key",
",",
"value",
"string",
")",
"{",
"if",
"p",
".",
"Metadata",
"==",
"nil",
"{",
"p",
".",
"Metadata",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"}",
"\n\n",
"p",
".",
"Metadata",
"[",
"key",
"]",
"=",
"value",
"\n",
"}"
] | // AddMetadata adds a new key-value pair to the Metadata. | [
"AddMetadata",
"adds",
"a",
"new",
"key",
"-",
"value",
"pair",
"to",
"the",
"Metadata",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L197-L203 |
148,385 | stripe/stripe-go | params.go | NewIdempotencyKey | func NewIdempotencyKey() string {
now := time.Now().UnixNano()
buf := make([]byte, 4)
rand.Read(buf)
return fmt.Sprintf("%v_%v", now, base64.URLEncoding.EncodeToString(buf)[:6])
} | go | func NewIdempotencyKey() string {
now := time.Now().UnixNano()
buf := make([]byte, 4)
rand.Read(buf)
return fmt.Sprintf("%v_%v", now, base64.URLEncoding.EncodeToString(buf)[:6])
} | [
"func",
"NewIdempotencyKey",
"(",
")",
"string",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"rand",
".",
"Read",
"(",
"buf",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"now",
",",
"base64",
".",
"URLEncoding",
".",
"EncodeToString",
"(",
"buf",
")",
"[",
":",
"6",
"]",
")",
"\n",
"}"
] | //
// Public functions
//
// NewIdempotencyKey generates a new idempotency key that
// can be used on a request. | [
"Public",
"functions",
"NewIdempotencyKey",
"generates",
"a",
"new",
"idempotency",
"key",
"that",
"can",
"be",
"used",
"on",
"a",
"request",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L254-L259 |
148,386 | stripe/stripe-go | iter.go | Next | func (it *Iter) Next() bool {
if len(it.values) == 0 && it.meta.HasMore && !it.listParams.Single {
// determine if we're moving forward or backwards in paging
if it.listParams.EndingBefore != nil {
it.listParams.EndingBefore = String(listItemID(it.cur))
it.formValues.Set(EndingBefore, *it.listParams.EndingBefore)
} else {
it.listParams.StartingAfter = String(listItemID(it.cur))
it.formValues.Set(StartingAfter, *it.listParams.StartingAfter)
}
it.getPage()
}
if len(it.values) == 0 {
return false
}
it.cur = it.values[0]
it.values = it.values[1:]
return true
} | go | func (it *Iter) Next() bool {
if len(it.values) == 0 && it.meta.HasMore && !it.listParams.Single {
// determine if we're moving forward or backwards in paging
if it.listParams.EndingBefore != nil {
it.listParams.EndingBefore = String(listItemID(it.cur))
it.formValues.Set(EndingBefore, *it.listParams.EndingBefore)
} else {
it.listParams.StartingAfter = String(listItemID(it.cur))
it.formValues.Set(StartingAfter, *it.listParams.StartingAfter)
}
it.getPage()
}
if len(it.values) == 0 {
return false
}
it.cur = it.values[0]
it.values = it.values[1:]
return true
} | [
"func",
"(",
"it",
"*",
"Iter",
")",
"Next",
"(",
")",
"bool",
"{",
"if",
"len",
"(",
"it",
".",
"values",
")",
"==",
"0",
"&&",
"it",
".",
"meta",
".",
"HasMore",
"&&",
"!",
"it",
".",
"listParams",
".",
"Single",
"{",
"// determine if we're moving forward or backwards in paging",
"if",
"it",
".",
"listParams",
".",
"EndingBefore",
"!=",
"nil",
"{",
"it",
".",
"listParams",
".",
"EndingBefore",
"=",
"String",
"(",
"listItemID",
"(",
"it",
".",
"cur",
")",
")",
"\n",
"it",
".",
"formValues",
".",
"Set",
"(",
"EndingBefore",
",",
"*",
"it",
".",
"listParams",
".",
"EndingBefore",
")",
"\n",
"}",
"else",
"{",
"it",
".",
"listParams",
".",
"StartingAfter",
"=",
"String",
"(",
"listItemID",
"(",
"it",
".",
"cur",
")",
")",
"\n",
"it",
".",
"formValues",
".",
"Set",
"(",
"StartingAfter",
",",
"*",
"it",
".",
"listParams",
".",
"StartingAfter",
")",
"\n",
"}",
"\n",
"it",
".",
"getPage",
"(",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"it",
".",
"values",
")",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"it",
".",
"cur",
"=",
"it",
".",
"values",
"[",
"0",
"]",
"\n",
"it",
".",
"values",
"=",
"it",
".",
"values",
"[",
"1",
":",
"]",
"\n",
"return",
"true",
"\n",
"}"
] | // Next advances the Iter to the next item in the list,
// which will then be available
// through the Current method.
// It returns false when the iterator stops
// at the end of the list. | [
"Next",
"advances",
"the",
"Iter",
"to",
"the",
"next",
"item",
"in",
"the",
"list",
"which",
"will",
"then",
"be",
"available",
"through",
"the",
"Current",
"method",
".",
"It",
"returns",
"false",
"when",
"the",
"iterator",
"stops",
"at",
"the",
"end",
"of",
"the",
"list",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/iter.go#L55-L73 |
148,387 | stripe/stripe-go | iter.go | GetIter | func GetIter(container ListParamsContainer, query Query) *Iter {
var listParams *ListParams
formValues := &form.Values{}
if container != nil {
reflectValue := reflect.ValueOf(container)
// See the comment on Call in stripe.go.
if reflectValue.Kind() == reflect.Ptr && !reflectValue.IsNil() {
listParams = container.GetListParams()
form.AppendTo(formValues, container)
}
}
if listParams == nil {
listParams = &ListParams{}
}
iter := &Iter{
formValues: formValues,
listParams: *listParams,
query: query,
}
iter.getPage()
return iter
} | go | func GetIter(container ListParamsContainer, query Query) *Iter {
var listParams *ListParams
formValues := &form.Values{}
if container != nil {
reflectValue := reflect.ValueOf(container)
// See the comment on Call in stripe.go.
if reflectValue.Kind() == reflect.Ptr && !reflectValue.IsNil() {
listParams = container.GetListParams()
form.AppendTo(formValues, container)
}
}
if listParams == nil {
listParams = &ListParams{}
}
iter := &Iter{
formValues: formValues,
listParams: *listParams,
query: query,
}
iter.getPage()
return iter
} | [
"func",
"GetIter",
"(",
"container",
"ListParamsContainer",
",",
"query",
"Query",
")",
"*",
"Iter",
"{",
"var",
"listParams",
"*",
"ListParams",
"\n",
"formValues",
":=",
"&",
"form",
".",
"Values",
"{",
"}",
"\n\n",
"if",
"container",
"!=",
"nil",
"{",
"reflectValue",
":=",
"reflect",
".",
"ValueOf",
"(",
"container",
")",
"\n\n",
"// See the comment on Call in stripe.go.",
"if",
"reflectValue",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"&&",
"!",
"reflectValue",
".",
"IsNil",
"(",
")",
"{",
"listParams",
"=",
"container",
".",
"GetListParams",
"(",
")",
"\n",
"form",
".",
"AppendTo",
"(",
"formValues",
",",
"container",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"listParams",
"==",
"nil",
"{",
"listParams",
"=",
"&",
"ListParams",
"{",
"}",
"\n",
"}",
"\n",
"iter",
":=",
"&",
"Iter",
"{",
"formValues",
":",
"formValues",
",",
"listParams",
":",
"*",
"listParams",
",",
"query",
":",
"query",
",",
"}",
"\n\n",
"iter",
".",
"getPage",
"(",
")",
"\n\n",
"return",
"iter",
"\n",
"}"
] | //
// Public functions
//
// GetIter returns a new Iter for a given query and its options. | [
"Public",
"functions",
"GetIter",
"returns",
"a",
"new",
"Iter",
"for",
"a",
"given",
"query",
"and",
"its",
"options",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/iter.go#L93-L119 |
148,388 | stripe/stripe-go | orderreturn.go | UnmarshalJSON | func (r *OrderReturn) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type orderReturn OrderReturn
var v orderReturn
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = OrderReturn(v)
return nil
} | go | func (r *OrderReturn) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type orderReturn OrderReturn
var v orderReturn
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = OrderReturn(v)
return nil
} | [
"func",
"(",
"r",
"*",
"OrderReturn",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"orderReturn",
"OrderReturn",
"\n",
"var",
"v",
"orderReturn",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"r",
"=",
"OrderReturn",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of an OrderReturn.
// 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",
"OrderReturn",
".",
"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/orderreturn.go#L35-L49 |
148,389 | stripe/stripe-go | charge.go | SetSource | func (p *ChargeParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
p.Source = source
return err
} | go | func (p *ChargeParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
p.Source = source
return err
} | [
"func",
"(",
"p",
"*",
"ChargeParams",
")",
"SetSource",
"(",
"sp",
"interface",
"{",
"}",
")",
"error",
"{",
"source",
",",
"err",
":=",
"SourceParamsFor",
"(",
"sp",
")",
"\n",
"p",
".",
"Source",
"=",
"source",
"\n",
"return",
"err",
"\n",
"}"
] | // SetSource adds valid sources to a ChargeParams object,
// returning an error for unsupported sources. | [
"SetSource",
"adds",
"valid",
"sources",
"to",
"a",
"ChargeParams",
"object",
"returning",
"an",
"error",
"for",
"unsupported",
"sources",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/charge.go#L112-L116 |
148,390 | stripe/stripe-go | charge.go | UnmarshalJSON | func (c *Charge) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type charge Charge
var v charge
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Charge(v)
return nil
} | go | func (c *Charge) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type charge Charge
var v charge
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Charge(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Charge",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"charge",
"Charge",
"\n",
"var",
"v",
"charge",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"Charge",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of a charge.
// 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",
"charge",
".",
"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/charge.go#L475-L489 |
148,391 | stripe/stripe-go | charge.go | UnmarshalJSON | func (c *ChargeOutcomeRule) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type chargeOutcomeRule ChargeOutcomeRule
var v chargeOutcomeRule
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = ChargeOutcomeRule(v)
return nil
} | go | func (c *ChargeOutcomeRule) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type chargeOutcomeRule ChargeOutcomeRule
var v chargeOutcomeRule
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = ChargeOutcomeRule(v)
return nil
} | [
"func",
"(",
"c",
"*",
"ChargeOutcomeRule",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"chargeOutcomeRule",
"ChargeOutcomeRule",
"\n",
"var",
"v",
"chargeOutcomeRule",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"c",
"=",
"ChargeOutcomeRule",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of a ChargeOutcomeRule.
// 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",
"ChargeOutcomeRule",
".",
"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/charge.go#L536-L550 |
148,392 | stripe/stripe-go | product/client.go | Get | func (c Client) Get(id string, params *stripe.ProductParams) (*stripe.Product, error) {
path := stripe.FormatURLPath("/v1/products/%s", id)
p := &stripe.Product{}
err := c.B.Call(http.MethodGet, path, c.Key, params, p)
return p, err
} | go | func (c Client) Get(id string, params *stripe.ProductParams) (*stripe.Product, error) {
path := stripe.FormatURLPath("/v1/products/%s", id)
p := &stripe.Product{}
err := c.B.Call(http.MethodGet, path, c.Key, params, p)
return p, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ProductParams",
")",
"(",
"*",
"stripe",
".",
"Product",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"p",
":=",
"&",
"stripe",
".",
"Product",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet",
",",
"path",
",",
"c",
".",
"Key",
",",
"params",
",",
"p",
")",
"\n",
"return",
"p",
",",
"err",
"\n",
"}"
] | // Get returns the details of a product. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"product",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/product/client.go#L47-L52 |
148,393 | stripe/stripe-go | product/client.go | Del | func Del(id string, params *stripe.ProductParams) (*stripe.Product, error) {
return getC().Del(id, params)
} | go | func Del(id string, params *stripe.ProductParams) (*stripe.Product, error) {
return getC().Del(id, params)
} | [
"func",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ProductParams",
")",
"(",
"*",
"stripe",
".",
"Product",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Del",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Del deletes a product | [
"Del",
"deletes",
"a",
"product"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/product/client.go#L75-L77 |
148,394 | stripe/stripe-go | issuing_authorization.go | UnmarshalJSON | func (i *IssuingAuthorization) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingAuthorization IssuingAuthorization
var v issuingAuthorization
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingAuthorization(v)
return nil
} | go | func (i *IssuingAuthorization) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingAuthorization IssuingAuthorization
var v issuingAuthorization
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingAuthorization(v)
return nil
} | [
"func",
"(",
"i",
"*",
"IssuingAuthorization",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"issuingAuthorization",
"IssuingAuthorization",
"\n",
"var",
"v",
"issuingAuthorization",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"i",
"=",
"IssuingAuthorization",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of an IssuingAuthorization.
// 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",
"IssuingAuthorization",
".",
"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_authorization.go#L154-L168 |
148,395 | stripe/stripe-go | account.go | AppendTo | func (p *PayoutScheduleParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.DelayDaysMinimum) {
body.Add(form.FormatKey(append(keyParts, "delay_days")), "minimum")
}
} | go | func (p *PayoutScheduleParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.DelayDaysMinimum) {
body.Add(form.FormatKey(append(keyParts, "delay_days")), "minimum")
}
} | [
"func",
"(",
"p",
"*",
"PayoutScheduleParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"BoolValue",
"(",
"p",
".",
"DelayDaysMinimum",
")",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"\"",
"\"",
")",
")",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // AppendTo implements custom encoding logic for PayoutScheduleParams
// so that we can send a special value for `delay_days` field if needed. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"PayoutScheduleParams",
"so",
"that",
"we",
"can",
"send",
"a",
"special",
"value",
"for",
"delay_days",
"field",
"if",
"needed",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account.go#L183-L187 |
148,396 | stripe/stripe-go | account.go | AppendTo | func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []string) {
if p.Token != nil {
body.Add(form.FormatKey(keyParts), StringValue(p.Token))
} else {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
}
} | go | func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []string) {
if p.Token != nil {
body.Add(form.FormatKey(keyParts), StringValue(p.Token))
} else {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
}
} | [
"func",
"(",
"p",
"*",
"AccountExternalAccountParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"p",
".",
"Token",
"!=",
"nil",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"keyParts",
")",
",",
"StringValue",
"(",
"p",
".",
"Token",
")",
")",
"\n",
"}",
"else",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"\"",
"\"",
")",
")",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // AppendTo implements custom encoding logic for AccountExternalAccountParams
// so that we can send the special required `object` field up along with the
// other specified parameters or the token value. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"AccountExternalAccountParams",
"so",
"that",
"we",
"can",
"send",
"the",
"special",
"required",
"object",
"field",
"up",
"along",
"with",
"the",
"other",
"specified",
"parameters",
"or",
"the",
"token",
"value",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account.go#L256-L262 |
148,397 | stripe/stripe-go | account.go | UnmarshalJSON | func (a *Account) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
a.ID = id
return nil
}
type account Account
var v account
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*a = Account(v)
return nil
} | go | func (a *Account) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
a.ID = id
return nil
}
type account Account
var v account
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*a = Account(v)
return nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"a",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"account",
"Account",
"\n",
"var",
"v",
"account",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"a",
"=",
"Account",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of an account.
// 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",
"account",
".",
"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/account.go#L399-L413 |
148,398 | stripe/stripe-go | account.go | UnmarshalJSON | func (ea *ExternalAccount) UnmarshalJSON(data []byte) error {
type externalAccount ExternalAccount
var v externalAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*ea = ExternalAccount(v)
switch ea.Type {
case ExternalAccountTypeBankAccount:
err = json.Unmarshal(data, &ea.BankAccount)
case ExternalAccountTypeCard:
err = json.Unmarshal(data, &ea.Card)
}
return err
} | go | func (ea *ExternalAccount) UnmarshalJSON(data []byte) error {
type externalAccount ExternalAccount
var v externalAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*ea = ExternalAccount(v)
switch ea.Type {
case ExternalAccountTypeBankAccount:
err = json.Unmarshal(data, &ea.BankAccount)
case ExternalAccountTypeCard:
err = json.Unmarshal(data, &ea.Card)
}
return err
} | [
"func",
"(",
"ea",
"*",
"ExternalAccount",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"type",
"externalAccount",
"ExternalAccount",
"\n",
"var",
"v",
"externalAccount",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"err",
"error",
"\n",
"*",
"ea",
"=",
"ExternalAccount",
"(",
"v",
")",
"\n\n",
"switch",
"ea",
".",
"Type",
"{",
"case",
"ExternalAccountTypeBankAccount",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"ea",
".",
"BankAccount",
")",
"\n",
"case",
"ExternalAccountTypeCard",
":",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"ea",
".",
"Card",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // UnmarshalJSON implements Unmarshaler.UnmarshalJSON. | [
"UnmarshalJSON",
"implements",
"Unmarshaler",
".",
"UnmarshalJSON",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account.go#L448-L466 |
148,399 | stripe/stripe-go | review.go | UnmarshalJSON | func (r *Review) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type review Review
var v review
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Review(v)
return nil
} | go | func (r *Review) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type review Review
var v review
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Review(v)
return nil
} | [
"func",
"(",
"r",
"*",
"Review",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"type",
"review",
"Review",
"\n",
"var",
"v",
"review",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"v",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"r",
"=",
"Review",
"(",
"v",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON handles deserialization of a Review.
// 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",
"Review",
".",
"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/review.go#L57-L71 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.