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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
133,400 | messagebird/go-rest-api | lookup/lookup.go | Read | func Read(c *messagebird.Client, phoneNumber string, params *Params) (*Lookup, error) {
urlParams := paramsForLookup(params)
path := lookupPath + "/" + phoneNumber + "?" + urlParams.Encode()
lookup := &Lookup{}
if err := c.Request(lookup, http.MethodGet, path, nil); err != nil {
return nil, err
}
return looku... | go | func Read(c *messagebird.Client, phoneNumber string, params *Params) (*Lookup, error) {
urlParams := paramsForLookup(params)
path := lookupPath + "/" + phoneNumber + "?" + urlParams.Encode()
lookup := &Lookup{}
if err := c.Request(lookup, http.MethodGet, path, nil); err != nil {
return nil, err
}
return looku... | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"phoneNumber",
"string",
",",
"params",
"*",
"Params",
")",
"(",
"*",
"Lookup",
",",
"error",
")",
"{",
"urlParams",
":=",
"paramsForLookup",
"(",
"params",
")",
"\n",
"path",
":=",
"loo... | // Read performs a new lookup for the specified number. | [
"Read",
"performs",
"a",
"new",
"lookup",
"for",
"the",
"specified",
"number",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/lookup/lookup.go#L48-L58 |
133,401 | messagebird/go-rest-api | lookup/lookup.go | CreateHLR | func CreateHLR(c *messagebird.Client, phoneNumber string, params *Params) (*hlr.HLR, error) {
requestData := requestDataForLookup(params)
path := lookupPath + "/" + phoneNumber + "/" + hlrPath
hlr := &hlr.HLR{}
if err := c.Request(hlr, http.MethodPost, path, requestData); err != nil {
return nil, err
}
return... | go | func CreateHLR(c *messagebird.Client, phoneNumber string, params *Params) (*hlr.HLR, error) {
requestData := requestDataForLookup(params)
path := lookupPath + "/" + phoneNumber + "/" + hlrPath
hlr := &hlr.HLR{}
if err := c.Request(hlr, http.MethodPost, path, requestData); err != nil {
return nil, err
}
return... | [
"func",
"CreateHLR",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"phoneNumber",
"string",
",",
"params",
"*",
"Params",
")",
"(",
"*",
"hlr",
".",
"HLR",
",",
"error",
")",
"{",
"requestData",
":=",
"requestDataForLookup",
"(",
"params",
")",
"\n",... | // CreateHLR creates a new HLR lookup for the specified number. | [
"CreateHLR",
"creates",
"a",
"new",
"HLR",
"lookup",
"for",
"the",
"specified",
"number",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/lookup/lookup.go#L61-L71 |
133,402 | messagebird/go-rest-api | lookup/lookup.go | ReadHLR | func ReadHLR(c *messagebird.Client, phoneNumber string, params *Params) (*hlr.HLR, error) {
urlParams := paramsForLookup(params)
path := lookupPath + "/" + phoneNumber + "/" + hlrPath + "?" + urlParams.Encode()
hlr := &hlr.HLR{}
if err := c.Request(hlr, http.MethodGet, path, nil); err != nil {
return nil, err
}... | go | func ReadHLR(c *messagebird.Client, phoneNumber string, params *Params) (*hlr.HLR, error) {
urlParams := paramsForLookup(params)
path := lookupPath + "/" + phoneNumber + "/" + hlrPath + "?" + urlParams.Encode()
hlr := &hlr.HLR{}
if err := c.Request(hlr, http.MethodGet, path, nil); err != nil {
return nil, err
}... | [
"func",
"ReadHLR",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"phoneNumber",
"string",
",",
"params",
"*",
"Params",
")",
"(",
"*",
"hlr",
".",
"HLR",
",",
"error",
")",
"{",
"urlParams",
":=",
"paramsForLookup",
"(",
"params",
")",
"\n",
"path"... | // ReadHLR performs a HLR lookup for the specified number. | [
"ReadHLR",
"performs",
"a",
"HLR",
"lookup",
"for",
"the",
"specified",
"number",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/lookup/lookup.go#L74-L84 |
133,403 | messagebird/go-rest-api | voice/leg.go | Recordings | func (leg *Leg) Recordings(client *messagebird.Client) *Paginator {
return newPaginator(client, fmt.Sprintf("%s/calls/%s/legs/%s/recordings", apiRoot, leg.CallID, leg.ID), reflect.TypeOf(Recording{}))
} | go | func (leg *Leg) Recordings(client *messagebird.Client) *Paginator {
return newPaginator(client, fmt.Sprintf("%s/calls/%s/legs/%s/recordings", apiRoot, leg.CallID, leg.ID), reflect.TypeOf(Recording{}))
} | [
"func",
"(",
"leg",
"*",
"Leg",
")",
"Recordings",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"*",
"Paginator",
"{",
"return",
"newPaginator",
"(",
"client",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"apiRoot",
",",
"leg",
".",
"C... | // Recordings retrieves the Recording objects associated with a leg. | [
"Recordings",
"retrieves",
"the",
"Recording",
"objects",
"associated",
"with",
"a",
"leg",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/leg.go#L152-L154 |
133,404 | messagebird/go-rest-api | contact/contact.go | List | func List(c *messagebird.Client, options *ListOptions) (*ContactList, error) {
query, err := listQuery(options)
if err != nil {
return nil, err
}
contactList := &ContactList{}
if err = c.Request(contactList, http.MethodGet, path+"?"+query, nil); err != nil {
return nil, err
}
return contactList, nil
} | go | func List(c *messagebird.Client, options *ListOptions) (*ContactList, error) {
query, err := listQuery(options)
if err != nil {
return nil, err
}
contactList := &ContactList{}
if err = c.Request(contactList, http.MethodGet, path+"?"+query, nil); err != nil {
return nil, err
}
return contactList, nil
} | [
"func",
"List",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"options",
"*",
"ListOptions",
")",
"(",
"*",
"ContactList",
",",
"error",
")",
"{",
"query",
",",
"err",
":=",
"listQuery",
"(",
"options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // List retrieves a paginated list of contacts, based on the options provided.
// It's worth noting DefaultListOptions. | [
"List",
"retrieves",
"a",
"paginated",
"list",
"of",
"contacts",
"based",
"on",
"the",
"options",
"provided",
".",
"It",
"s",
"worth",
"noting",
"DefaultListOptions",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/contact/contact.go#L104-L116 |
133,405 | messagebird/go-rest-api | contact/contact.go | Read | func Read(c *messagebird.Client, id string) (*Contact, error) {
contact := &Contact{}
if err := c.Request(contact, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return contact, nil
} | go | func Read(c *messagebird.Client, id string) (*Contact, error) {
contact := &Contact{}
if err := c.Request(contact, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return contact, nil
} | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"Contact",
",",
"error",
")",
"{",
"contact",
":=",
"&",
"Contact",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"contact",
",",
"htt... | // Read retrieves the information of an existing contact. | [
"Read",
"retrieves",
"the",
"information",
"of",
"an",
"existing",
"contact",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/contact/contact.go#L136-L143 |
133,406 | messagebird/go-rest-api | contact/contact.go | Update | func Update(c *messagebird.Client, id string, contactRequest *Request) (*Contact, error) {
contact := &Contact{}
if err := c.Request(contact, http.MethodPatch, path+"/"+id, contactRequest); err != nil {
return nil, err
}
return contact, nil
} | go | func Update(c *messagebird.Client, id string, contactRequest *Request) (*Contact, error) {
contact := &Contact{}
if err := c.Request(contact, http.MethodPatch, path+"/"+id, contactRequest); err != nil {
return nil, err
}
return contact, nil
} | [
"func",
"Update",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
",",
"contactRequest",
"*",
"Request",
")",
"(",
"*",
"Contact",
",",
"error",
")",
"{",
"contact",
":=",
"&",
"Contact",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".... | // Update updates the record referenced by id with any values set in contactRequest.
// Do not set any values that should not be updated. | [
"Update",
"updates",
"the",
"record",
"referenced",
"by",
"id",
"with",
"any",
"values",
"set",
"in",
"contactRequest",
".",
"Do",
"not",
"set",
"any",
"values",
"that",
"should",
"not",
"be",
"updated",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/contact/contact.go#L147-L154 |
133,407 | messagebird/go-rest-api | conversation/conversation.go | List | func List(c *messagebird.Client, options *ListOptions) (*ConversationList, error) {
query := paginationQuery(options)
convList := &ConversationList{}
if err := request(c, convList, http.MethodGet, path+"?"+query, nil); err != nil {
return nil, err
}
return convList, nil
} | go | func List(c *messagebird.Client, options *ListOptions) (*ConversationList, error) {
query := paginationQuery(options)
convList := &ConversationList{}
if err := request(c, convList, http.MethodGet, path+"?"+query, nil); err != nil {
return nil, err
}
return convList, nil
} | [
"func",
"List",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"options",
"*",
"ListOptions",
")",
"(",
"*",
"ConversationList",
",",
"error",
")",
"{",
"query",
":=",
"paginationQuery",
"(",
"options",
")",
"\n\n",
"convList",
":=",
"&",
"ConversationL... | // List gets a collection of Conversations. Pagination can be set in options. | [
"List",
"gets",
"a",
"collection",
"of",
"Conversations",
".",
"Pagination",
"can",
"be",
"set",
"in",
"options",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/conversation.go#L31-L40 |
133,408 | messagebird/go-rest-api | conversation/conversation.go | Read | func Read(c *messagebird.Client, id string) (*Conversation, error) {
conv := &Conversation{}
if err := request(c, conv, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return conv, nil
} | go | func Read(c *messagebird.Client, id string) (*Conversation, error) {
conv := &Conversation{}
if err := request(c, conv, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return conv, nil
} | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"Conversation",
",",
"error",
")",
"{",
"conv",
":=",
"&",
"Conversation",
"{",
"}",
"\n",
"if",
"err",
":=",
"request",
"(",
"c",
",",
"conv",
",",
... | // Read fetches a single Conversation based on its ID. | [
"Read",
"fetches",
"a",
"single",
"Conversation",
"based",
"on",
"its",
"ID",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/conversation.go#L43-L50 |
133,409 | messagebird/go-rest-api | conversation/conversation.go | Start | func Start(c *messagebird.Client, req *StartRequest) (*Conversation, error) {
conv := &Conversation{}
if err := request(c, conv, http.MethodPost, path+"/start", req); err != nil {
return nil, err
}
return conv, nil
} | go | func Start(c *messagebird.Client, req *StartRequest) (*Conversation, error) {
conv := &Conversation{}
if err := request(c, conv, http.MethodPost, path+"/start", req); err != nil {
return nil, err
}
return conv, nil
} | [
"func",
"Start",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"req",
"*",
"StartRequest",
")",
"(",
"*",
"Conversation",
",",
"error",
")",
"{",
"conv",
":=",
"&",
"Conversation",
"{",
"}",
"\n",
"if",
"err",
":=",
"request",
"(",
"c",
",",
"c... | // Start creates a conversation by sending an initial message. If an active
// conversation exists for the recipient, it is resumed. | [
"Start",
"creates",
"a",
"conversation",
"by",
"sending",
"an",
"initial",
"message",
".",
"If",
"an",
"active",
"conversation",
"exists",
"for",
"the",
"recipient",
"it",
"is",
"resumed",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/conversation.go#L54-L61 |
133,410 | messagebird/go-rest-api | client.go | New | func New(accessKey string) *Client {
return &Client{
AccessKey: accessKey,
HTTPClient: &http.Client{
Timeout: httpClientTimeout,
},
}
} | go | func New(accessKey string) *Client {
return &Client{
AccessKey: accessKey,
HTTPClient: &http.Client{
Timeout: httpClientTimeout,
},
}
} | [
"func",
"New",
"(",
"accessKey",
"string",
")",
"*",
"Client",
"{",
"return",
"&",
"Client",
"{",
"AccessKey",
":",
"accessKey",
",",
"HTTPClient",
":",
"&",
"http",
".",
"Client",
"{",
"Timeout",
":",
"httpClientTimeout",
",",
"}",
",",
"}",
"\n",
"}"... | // New creates a new MessageBird client object. | [
"New",
"creates",
"a",
"new",
"MessageBird",
"client",
"object",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/client.go#L59-L66 |
133,411 | messagebird/go-rest-api | client.go | Request | func (c *Client) Request(v interface{}, method, path string, data interface{}) error {
if !strings.HasPrefix(path, "https://") && !strings.HasPrefix(path, "http://") {
path = fmt.Sprintf("%s/%s", Endpoint, path)
}
uri, err := url.Parse(path)
if err != nil {
return err
}
body, contentType, err := prepareReque... | go | func (c *Client) Request(v interface{}, method, path string, data interface{}) error {
if !strings.HasPrefix(path, "https://") && !strings.HasPrefix(path, "http://") {
path = fmt.Sprintf("%s/%s", Endpoint, path)
}
uri, err := url.Parse(path)
if err != nil {
return err
}
body, contentType, err := prepareReque... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Request",
"(",
"v",
"interface",
"{",
"}",
",",
"method",
",",
"path",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"path",
",",
"\"",
"\"",
"... | // Request is for internal use only and unstable. | [
"Request",
"is",
"for",
"internal",
"use",
"only",
"and",
"unstable",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/client.go#L69-L145 |
133,412 | messagebird/go-rest-api | client.go | prepareRequestBody | func prepareRequestBody(data interface{}) ([]byte, contentType, error) {
switch data := data.(type) {
case nil:
// Nil bodies are accepted by `net/http`, so this is not an error.
return nil, contentTypeEmpty, nil
case string:
return []byte(data), contentTypeFormURLEncoded, nil
default:
b, err := json.Marsha... | go | func prepareRequestBody(data interface{}) ([]byte, contentType, error) {
switch data := data.(type) {
case nil:
// Nil bodies are accepted by `net/http`, so this is not an error.
return nil, contentTypeEmpty, nil
case string:
return []byte(data), contentTypeFormURLEncoded, nil
default:
b, err := json.Marsha... | [
"func",
"prepareRequestBody",
"(",
"data",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"contentType",
",",
"error",
")",
"{",
"switch",
"data",
":=",
"data",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",
"// Nil bodies are accepted by `net/ht... | // prepareRequestBody takes untyped data and attempts constructing a meaningful
// request body from it. It also returns the appropriate Content-Type. | [
"prepareRequestBody",
"takes",
"untyped",
"data",
"and",
"attempts",
"constructing",
"a",
"meaningful",
"request",
"body",
"from",
"it",
".",
"It",
"also",
"returns",
"the",
"appropriate",
"Content",
"-",
"Type",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/client.go#L149-L164 |
133,413 | messagebird/go-rest-api | mms/message.go | Create | func Create(c *messagebird.Client, originator string, recipients []string, msgParams *Params) (*Message, error) {
params, err := paramsForMessage(msgParams)
if err != nil {
return nil, err
}
params.Set("originator", originator)
params.Set("recipients", strings.Join(recipients, ","))
mmsMessage := &Message{}
... | go | func Create(c *messagebird.Client, originator string, recipients []string, msgParams *Params) (*Message, error) {
params, err := paramsForMessage(msgParams)
if err != nil {
return nil, err
}
params.Set("originator", originator)
params.Set("recipients", strings.Join(recipients, ","))
mmsMessage := &Message{}
... | [
"func",
"Create",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"originator",
"string",
",",
"recipients",
"[",
"]",
"string",
",",
"msgParams",
"*",
"Params",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"params",
",",
"err",
":=",
"paramsFor... | // Create creates a new MMS message for one or more recipients. | [
"Create",
"creates",
"a",
"new",
"MMS",
"message",
"for",
"one",
"or",
"more",
"recipients",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/mms/message.go#L52-L67 |
133,414 | messagebird/go-rest-api | mms/message.go | paramsForMessage | func paramsForMessage(params *Params) (*url.Values, error) {
urlParams := &url.Values{}
if params.Body == "" && params.MediaUrls == nil {
return nil, errors.New("Body or MediaUrls is required")
}
if params.Body != "" {
urlParams.Set("body", params.Body)
}
if params.MediaUrls != nil {
urlParams.Set("mediaUr... | go | func paramsForMessage(params *Params) (*url.Values, error) {
urlParams := &url.Values{}
if params.Body == "" && params.MediaUrls == nil {
return nil, errors.New("Body or MediaUrls is required")
}
if params.Body != "" {
urlParams.Set("body", params.Body)
}
if params.MediaUrls != nil {
urlParams.Set("mediaUr... | [
"func",
"paramsForMessage",
"(",
"params",
"*",
"Params",
")",
"(",
"*",
"url",
".",
"Values",
",",
"error",
")",
"{",
"urlParams",
":=",
"&",
"url",
".",
"Values",
"{",
"}",
"\n\n",
"if",
"params",
".",
"Body",
"==",
"\"",
"\"",
"&&",
"params",
".... | // paramsForMessage converts the specified Parmas struct to a url.Values
// pointer and returns it. | [
"paramsForMessage",
"converts",
"the",
"specified",
"Parmas",
"struct",
"to",
"a",
"url",
".",
"Values",
"pointer",
"and",
"returns",
"it",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/mms/message.go#L71-L94 |
133,415 | messagebird/go-rest-api | conversation/api.go | paginationQuery | func paginationQuery(options *ListOptions) string {
query := url.Values{}
query.Set("limit", strconv.Itoa(options.Limit))
query.Set("offset", strconv.Itoa(options.Offset))
return query.Encode()
} | go | func paginationQuery(options *ListOptions) string {
query := url.Values{}
query.Set("limit", strconv.Itoa(options.Limit))
query.Set("offset", strconv.Itoa(options.Offset))
return query.Encode()
} | [
"func",
"paginationQuery",
"(",
"options",
"*",
"ListOptions",
")",
"string",
"{",
"query",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"query",
".",
"Set",
"(",
"\"",
"\"",
",",
"strconv",
".",
"Itoa",
"(",
"options",
".",
"Limit",
")",
")",
"\n",
... | // paginationQuery builds the query string for paginated endpoints. | [
"paginationQuery",
"builds",
"the",
"query",
"string",
"for",
"paginated",
"endpoints",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/api.go#L213-L219 |
133,416 | messagebird/go-rest-api | conversation/api.go | UnmarshalJSON | func (c *Contact) UnmarshalJSON(data []byte) error {
target := struct {
ID string
Href string
MSISDN json.Number
FirstName string
LastName string
CustomDetails map[string]interface{}
CreatedAt *time.Time
UpdatedAt *time.Time
}{}
if err := json.Unmarshal(da... | go | func (c *Contact) UnmarshalJSON(data []byte) error {
target := struct {
ID string
Href string
MSISDN json.Number
FirstName string
LastName string
CustomDetails map[string]interface{}
CreatedAt *time.Time
UpdatedAt *time.Time
}{}
if err := json.Unmarshal(da... | [
"func",
"(",
"c",
"*",
"Contact",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"target",
":=",
"struct",
"{",
"ID",
"string",
"\n",
"Href",
"string",
"\n",
"MSISDN",
"json",
".",
"Number",
"\n",
"FirstName",
"string",
"\n",
... | // UnmarshalJSON is used to unmarshal the MSISDN to a string rather than an
// int64. The API returns integers, but this client always uses strings.
// Exposing a json.Number doesn't seem nice. | [
"UnmarshalJSON",
"is",
"used",
"to",
"unmarshal",
"the",
"MSISDN",
"to",
"a",
"string",
"rather",
"than",
"an",
"int64",
".",
"The",
"API",
"returns",
"integers",
"but",
"this",
"client",
"always",
"uses",
"strings",
".",
"Exposing",
"a",
"json",
".",
"Num... | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/api.go#L224-L263 |
133,417 | messagebird/go-rest-api | conversation/webhook.go | CreateWebhook | func CreateWebhook(c *messagebird.Client, req *WebhookCreateRequest) (*Webhook, error) {
webhook := &Webhook{}
if err := request(c, webhook, http.MethodPost, webhooksPath, req); err != nil {
return nil, err
}
return webhook, nil
} | go | func CreateWebhook(c *messagebird.Client, req *WebhookCreateRequest) (*Webhook, error) {
webhook := &Webhook{}
if err := request(c, webhook, http.MethodPost, webhooksPath, req); err != nil {
return nil, err
}
return webhook, nil
} | [
"func",
"CreateWebhook",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"req",
"*",
"WebhookCreateRequest",
")",
"(",
"*",
"Webhook",
",",
"error",
")",
"{",
"webhook",
":=",
"&",
"Webhook",
"{",
"}",
"\n",
"if",
"err",
":=",
"request",
"(",
"c",
... | // CreateWebhook registers a webhook that is invoked when something interesting
// happens. | [
"CreateWebhook",
"registers",
"a",
"webhook",
"that",
"is",
"invoked",
"when",
"something",
"interesting",
"happens",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/webhook.go#L17-L24 |
133,418 | messagebird/go-rest-api | conversation/webhook.go | DeleteWebhook | func DeleteWebhook(c *messagebird.Client, id string) error {
return request(c, nil, http.MethodDelete, webhooksPath+"/"+id, nil)
} | go | func DeleteWebhook(c *messagebird.Client, id string) error {
return request(c, nil, http.MethodDelete, webhooksPath+"/"+id, nil)
} | [
"func",
"DeleteWebhook",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"error",
"{",
"return",
"request",
"(",
"c",
",",
"nil",
",",
"http",
".",
"MethodDelete",
",",
"webhooksPath",
"+",
"\"",
"\"",
"+",
"id",
",",
"nil",
")... | // DeleteWebhook ensures an existing webhook is deleted and no longer
// triggered. If the error is nil, the deletion was successful. | [
"DeleteWebhook",
"ensures",
"an",
"existing",
"webhook",
"is",
"deleted",
"and",
"no",
"longer",
"triggered",
".",
"If",
"the",
"error",
"is",
"nil",
"the",
"deletion",
"was",
"successful",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/webhook.go#L28-L30 |
133,419 | messagebird/go-rest-api | conversation/webhook.go | ListWebhooks | func ListWebhooks(c *messagebird.Client, options *ListOptions) (*WebhookList, error) {
query := paginationQuery(options)
webhookList := &WebhookList{}
if err := request(c, webhookList, http.MethodGet, webhooksPath+"?"+query, nil); err != nil {
return nil, err
}
return webhookList, nil
} | go | func ListWebhooks(c *messagebird.Client, options *ListOptions) (*WebhookList, error) {
query := paginationQuery(options)
webhookList := &WebhookList{}
if err := request(c, webhookList, http.MethodGet, webhooksPath+"?"+query, nil); err != nil {
return nil, err
}
return webhookList, nil
} | [
"func",
"ListWebhooks",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"options",
"*",
"ListOptions",
")",
"(",
"*",
"WebhookList",
",",
"error",
")",
"{",
"query",
":=",
"paginationQuery",
"(",
"options",
")",
"\n\n",
"webhookList",
":=",
"&",
"Webhook... | // ListWebhooks gets a collection of webhooks. Pagination can be set in options. | [
"ListWebhooks",
"gets",
"a",
"collection",
"of",
"webhooks",
".",
"Pagination",
"can",
"be",
"set",
"in",
"options",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/webhook.go#L33-L42 |
133,420 | messagebird/go-rest-api | conversation/webhook.go | ReadWebhook | func ReadWebhook(c *messagebird.Client, id string) (*Webhook, error) {
webhook := &Webhook{}
if err := request(c, webhook, http.MethodGet, webhooksPath+"/"+id, nil); err != nil {
return nil, err
}
return webhook, nil
} | go | func ReadWebhook(c *messagebird.Client, id string) (*Webhook, error) {
webhook := &Webhook{}
if err := request(c, webhook, http.MethodGet, webhooksPath+"/"+id, nil); err != nil {
return nil, err
}
return webhook, nil
} | [
"func",
"ReadWebhook",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"Webhook",
",",
"error",
")",
"{",
"webhook",
":=",
"&",
"Webhook",
"{",
"}",
"\n",
"if",
"err",
":=",
"request",
"(",
"c",
",",
"webhook",
",",... | // ReadWebhook gets a single webhook based on its ID. | [
"ReadWebhook",
"gets",
"a",
"single",
"webhook",
"based",
"on",
"its",
"ID",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/webhook.go#L45-L52 |
133,421 | messagebird/go-rest-api | conversation/hsm.go | CurrencyLocalizableHSMParameter | func CurrencyLocalizableHSMParameter(d string, code string, amount int64) *HSMLocalizableParameter {
return &HSMLocalizableParameter{
Default: d,
Currency: &HSMLocalizableParameterCurrency{
Code: code,
Amount: amount,
},
}
} | go | func CurrencyLocalizableHSMParameter(d string, code string, amount int64) *HSMLocalizableParameter {
return &HSMLocalizableParameter{
Default: d,
Currency: &HSMLocalizableParameterCurrency{
Code: code,
Amount: amount,
},
}
} | [
"func",
"CurrencyLocalizableHSMParameter",
"(",
"d",
"string",
",",
"code",
"string",
",",
"amount",
"int64",
")",
"*",
"HSMLocalizableParameter",
"{",
"return",
"&",
"HSMLocalizableParameter",
"{",
"Default",
":",
"d",
",",
"Currency",
":",
"&",
"HSMLocalizablePa... | // CurrencyLocalizableHSMParameter gets a parameter that localizes a currency.
// Code is the currency code in ISO 4217 format and amount is the total amount,
// including cents, multiplied by 1000. E.g. 12.34 becomes 12340. | [
"CurrencyLocalizableHSMParameter",
"gets",
"a",
"parameter",
"that",
"localizes",
"a",
"currency",
".",
"Code",
"is",
"the",
"currency",
"code",
"in",
"ISO",
"4217",
"format",
"and",
"amount",
"is",
"the",
"total",
"amount",
"including",
"cents",
"multiplied",
"... | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/hsm.go#L70-L78 |
133,422 | messagebird/go-rest-api | conversation/hsm.go | DateTimeLocalizableHSMParameter | func DateTimeLocalizableHSMParameter(d string, dateTime time.Time) *HSMLocalizableParameter {
return &HSMLocalizableParameter{
Default: d,
DateTime: &dateTime,
}
} | go | func DateTimeLocalizableHSMParameter(d string, dateTime time.Time) *HSMLocalizableParameter {
return &HSMLocalizableParameter{
Default: d,
DateTime: &dateTime,
}
} | [
"func",
"DateTimeLocalizableHSMParameter",
"(",
"d",
"string",
",",
"dateTime",
"time",
".",
"Time",
")",
"*",
"HSMLocalizableParameter",
"{",
"return",
"&",
"HSMLocalizableParameter",
"{",
"Default",
":",
"d",
",",
"DateTime",
":",
"&",
"dateTime",
",",
"}",
... | // DateTimeLocalizableHSMParameter gets a parameter that localizes a DateTime. | [
"DateTimeLocalizableHSMParameter",
"gets",
"a",
"parameter",
"that",
"localizes",
"a",
"DateTime",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/hsm.go#L81-L86 |
133,423 | messagebird/go-rest-api | voicemessage/voice_message.go | Read | func Read(c *messagebird.Client, id string) (*VoiceMessage, error) {
message := &VoiceMessage{}
if err := c.Request(message, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return message, nil
} | go | func Read(c *messagebird.Client, id string) (*VoiceMessage, error) {
message := &VoiceMessage{}
if err := c.Request(message, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return message, nil
} | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"VoiceMessage",
",",
"error",
")",
"{",
"message",
":=",
"&",
"VoiceMessage",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"message",
"... | // Read retrieves the information of an existing VoiceMessage. | [
"Read",
"retrieves",
"the",
"information",
"of",
"an",
"existing",
"VoiceMessage",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voicemessage/voice_message.go#L65-L72 |
133,424 | messagebird/go-rest-api | voicemessage/voice_message.go | List | func List(c *messagebird.Client) (*VoiceMessageList, error) {
messageList := &VoiceMessageList{}
if err := c.Request(messageList, http.MethodGet, path, nil); err != nil {
return nil, err
}
return messageList, nil
} | go | func List(c *messagebird.Client) (*VoiceMessageList, error) {
messageList := &VoiceMessageList{}
if err := c.Request(messageList, http.MethodGet, path, nil); err != nil {
return nil, err
}
return messageList, nil
} | [
"func",
"List",
"(",
"c",
"*",
"messagebird",
".",
"Client",
")",
"(",
"*",
"VoiceMessageList",
",",
"error",
")",
"{",
"messageList",
":=",
"&",
"VoiceMessageList",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"messageList",
",",
"http... | // List retrieves all VoiceMessages of the user. | [
"List",
"retrieves",
"all",
"VoiceMessages",
"of",
"the",
"user",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voicemessage/voice_message.go#L75-L82 |
133,425 | messagebird/go-rest-api | voicemessage/voice_message.go | Create | func Create(c *messagebird.Client, recipients []string, body string, params *Params) (*VoiceMessage, error) {
requestData, err := requestDataForVoiceMessage(recipients, body, params)
if err != nil {
return nil, err
}
message := &VoiceMessage{}
if err := c.Request(message, http.MethodPost, path, requestData); er... | go | func Create(c *messagebird.Client, recipients []string, body string, params *Params) (*VoiceMessage, error) {
requestData, err := requestDataForVoiceMessage(recipients, body, params)
if err != nil {
return nil, err
}
message := &VoiceMessage{}
if err := c.Request(message, http.MethodPost, path, requestData); er... | [
"func",
"Create",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"recipients",
"[",
"]",
"string",
",",
"body",
"string",
",",
"params",
"*",
"Params",
")",
"(",
"*",
"VoiceMessage",
",",
"error",
")",
"{",
"requestData",
",",
"err",
":=",
"requestD... | // Create a new voice message for one or more recipients. | [
"Create",
"a",
"new",
"voice",
"message",
"for",
"one",
"or",
"more",
"recipients",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voicemessage/voice_message.go#L85-L97 |
133,426 | messagebird/go-rest-api | voice/webhook.go | Webhooks | func Webhooks(client *messagebird.Client) *Paginator {
return newPaginator(client, apiRoot+"/webhooks/", reflect.TypeOf(Webhook{}))
} | go | func Webhooks(client *messagebird.Client) *Paginator {
return newPaginator(client, apiRoot+"/webhooks/", reflect.TypeOf(Webhook{}))
} | [
"func",
"Webhooks",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"*",
"Paginator",
"{",
"return",
"newPaginator",
"(",
"client",
",",
"apiRoot",
"+",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"Webhook",
"{",
"}",
")",
")",
"\n",
"}"
] | // Webhooks returns a paginator over all webhooks. | [
"Webhooks",
"returns",
"a",
"paginator",
"over",
"all",
"webhooks",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/webhook.go#L68-L70 |
133,427 | messagebird/go-rest-api | voice/webhook.go | CreateWebHook | func CreateWebHook(client *messagebird.Client, url, token string) (*Webhook, error) {
data := struct {
URL string `json:"url"`
Token string `json:"token,omitempty"`
}{
URL: url,
Token: token,
}
var resp struct {
Data []Webhook `json:"data"`
}
if err := client.Request(&resp, http.MethodPost, apiRoot+... | go | func CreateWebHook(client *messagebird.Client, url, token string) (*Webhook, error) {
data := struct {
URL string `json:"url"`
Token string `json:"token,omitempty"`
}{
URL: url,
Token: token,
}
var resp struct {
Data []Webhook `json:"data"`
}
if err := client.Request(&resp, http.MethodPost, apiRoot+... | [
"func",
"CreateWebHook",
"(",
"client",
"*",
"messagebird",
".",
"Client",
",",
"url",
",",
"token",
"string",
")",
"(",
"*",
"Webhook",
",",
"error",
")",
"{",
"data",
":=",
"struct",
"{",
"URL",
"string",
"`json:\"url\"`",
"\n",
"Token",
"string",
"`js... | // CreateWebHook creates a new webhook the specified url that will be called
// and security token. | [
"CreateWebHook",
"creates",
"a",
"new",
"webhook",
"the",
"specified",
"url",
"that",
"will",
"be",
"called",
"and",
"security",
"token",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/webhook.go#L74-L89 |
133,428 | messagebird/go-rest-api | voice/webhook.go | Update | func (wh *Webhook) Update(client *messagebird.Client) error {
var data struct {
Data []Webhook `json:"data"`
}
if err := client.Request(&data, http.MethodPut, apiRoot+"/webhooks/"+wh.ID, wh); err != nil {
return err
}
*wh = data.Data[0]
return nil
} | go | func (wh *Webhook) Update(client *messagebird.Client) error {
var data struct {
Data []Webhook `json:"data"`
}
if err := client.Request(&data, http.MethodPut, apiRoot+"/webhooks/"+wh.ID, wh); err != nil {
return err
}
*wh = data.Data[0]
return nil
} | [
"func",
"(",
"wh",
"*",
"Webhook",
")",
"Update",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"error",
"{",
"var",
"data",
"struct",
"{",
"Data",
"[",
"]",
"Webhook",
"`json:\"data\"`",
"\n",
"}",
"\n",
"if",
"err",
":=",
"client",
".",
"R... | // Update syncs hte local state of a webhook to the MessageBird API. | [
"Update",
"syncs",
"hte",
"local",
"state",
"of",
"a",
"webhook",
"to",
"the",
"MessageBird",
"API",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/webhook.go#L92-L101 |
133,429 | messagebird/go-rest-api | voice/webhook.go | Delete | func (wh *Webhook) Delete(client *messagebird.Client) error {
return client.Request(nil, http.MethodDelete, apiRoot+"/webhooks/"+wh.ID, nil)
} | go | func (wh *Webhook) Delete(client *messagebird.Client) error {
return client.Request(nil, http.MethodDelete, apiRoot+"/webhooks/"+wh.ID, nil)
} | [
"func",
"(",
"wh",
"*",
"Webhook",
")",
"Delete",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"error",
"{",
"return",
"client",
".",
"Request",
"(",
"nil",
",",
"http",
".",
"MethodDelete",
",",
"apiRoot",
"+",
"\"",
"\"",
"+",
"wh",
".",
... | // Delete deletes a webhook. | [
"Delete",
"deletes",
"a",
"webhook",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/webhook.go#L104-L106 |
133,430 | messagebird/go-rest-api | group/group.go | List | func List(c *messagebird.Client, options *ListOptions) (*GroupList, error) {
query, err := listQuery(options)
if err != nil {
return nil, err
}
groupList := &GroupList{}
if err := c.Request(groupList, http.MethodGet, path+"?"+query, nil); err != nil {
return nil, err
}
return groupList, nil
} | go | func List(c *messagebird.Client, options *ListOptions) (*GroupList, error) {
query, err := listQuery(options)
if err != nil {
return nil, err
}
groupList := &GroupList{}
if err := c.Request(groupList, http.MethodGet, path+"?"+query, nil); err != nil {
return nil, err
}
return groupList, nil
} | [
"func",
"List",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"options",
"*",
"ListOptions",
")",
"(",
"*",
"GroupList",
",",
"error",
")",
"{",
"query",
",",
"err",
":=",
"listQuery",
"(",
"options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // List retrieves a paginated list of groups, based on the options provided.
// It's worth noting DefaultListOptions. | [
"List",
"retrieves",
"a",
"paginated",
"list",
"of",
"groups",
"based",
"on",
"the",
"options",
"provided",
".",
"It",
"s",
"worth",
"noting",
"DefaultListOptions",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/group/group.go#L101-L113 |
133,431 | messagebird/go-rest-api | group/group.go | Read | func Read(c *messagebird.Client, id string) (*Group, error) {
group := &Group{}
if err := c.Request(group, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return group, nil
} | go | func Read(c *messagebird.Client, id string) (*Group, error) {
group := &Group{}
if err := c.Request(group, http.MethodGet, path+"/"+id, nil); err != nil {
return nil, err
}
return group, nil
} | [
"func",
"Read",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"group",
":=",
"&",
"Group",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"group",
",",
"http",
".... | // Read retrieves the information of an existing group. | [
"Read",
"retrieves",
"the",
"information",
"of",
"an",
"existing",
"group",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/group/group.go#L132-L139 |
133,432 | messagebird/go-rest-api | group/group.go | Update | func Update(c *messagebird.Client, id string, request *Request) error {
if err := validateUpdate(request); err != nil {
return err
}
return c.Request(nil, http.MethodPatch, path+"/"+id, request)
} | go | func Update(c *messagebird.Client, id string, request *Request) error {
if err := validateUpdate(request); err != nil {
return err
}
return c.Request(nil, http.MethodPatch, path+"/"+id, request)
} | [
"func",
"Update",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
",",
"request",
"*",
"Request",
")",
"error",
"{",
"if",
"err",
":=",
"validateUpdate",
"(",
"request",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",... | // Update overrides the group with any values provided in request. | [
"Update",
"overrides",
"the",
"group",
"with",
"any",
"values",
"provided",
"in",
"request",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/group/group.go#L142-L148 |
133,433 | messagebird/go-rest-api | group/group.go | AddContacts | func AddContacts(c *messagebird.Client, groupID string, contactIDs []string) error {
if err := validateAddContacts(contactIDs); err != nil {
return err
}
data := addContactsData(contactIDs)
return c.Request(nil, http.MethodPut, path+"/"+groupID+"/"+contactPath, data)
} | go | func AddContacts(c *messagebird.Client, groupID string, contactIDs []string) error {
if err := validateAddContacts(contactIDs); err != nil {
return err
}
data := addContactsData(contactIDs)
return c.Request(nil, http.MethodPut, path+"/"+groupID+"/"+contactPath, data)
} | [
"func",
"AddContacts",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"groupID",
"string",
",",
"contactIDs",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"validateAddContacts",
"(",
"contactIDs",
")",
";",
"err",
"!=",
"nil",
"{",
"retur... | // AddContacts adds a maximum of 50 contacts to the group. | [
"AddContacts",
"adds",
"a",
"maximum",
"of",
"50",
"contacts",
"to",
"the",
"group",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/group/group.go#L159-L167 |
133,434 | messagebird/go-rest-api | group/group.go | ListContacts | func ListContacts(c *messagebird.Client, groupID string, options *ListOptions) (*contact.ContactList, error) {
query, err := listQuery(options)
if err != nil {
return nil, err
}
formattedPath := fmt.Sprintf("%s/%s/%s?%s", path, groupID, contactPath, query)
contacts := &contact.ContactList{}
if err = c.Request... | go | func ListContacts(c *messagebird.Client, groupID string, options *ListOptions) (*contact.ContactList, error) {
query, err := listQuery(options)
if err != nil {
return nil, err
}
formattedPath := fmt.Sprintf("%s/%s/%s?%s", path, groupID, contactPath, query)
contacts := &contact.ContactList{}
if err = c.Request... | [
"func",
"ListContacts",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"groupID",
"string",
",",
"options",
"*",
"ListOptions",
")",
"(",
"*",
"contact",
".",
"ContactList",
",",
"error",
")",
"{",
"query",
",",
"err",
":=",
"listQuery",
"(",
"options... | // ListContacts lists the contacts that are a member of a group. | [
"ListContacts",
"lists",
"the",
"contacts",
"that",
"are",
"a",
"member",
"of",
"a",
"group",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/group/group.go#L199-L213 |
133,435 | messagebird/go-rest-api | group/group.go | RemoveContact | func RemoveContact(c *messagebird.Client, groupID, contactID string) error {
formattedPath := fmt.Sprintf("%s/%s/contacts/%s", path, groupID, contactID)
return c.Request(nil, http.MethodDelete, formattedPath, nil)
} | go | func RemoveContact(c *messagebird.Client, groupID, contactID string) error {
formattedPath := fmt.Sprintf("%s/%s/contacts/%s", path, groupID, contactID)
return c.Request(nil, http.MethodDelete, formattedPath, nil)
} | [
"func",
"RemoveContact",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"groupID",
",",
"contactID",
"string",
")",
"error",
"{",
"formattedPath",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"path",
",",
"groupID",
",",
"contactID",
")",
"\n\n"... | // RemoveContact removes the contact from a group. If nil is returned, the
// operation was successful. | [
"RemoveContact",
"removes",
"the",
"contact",
"from",
"a",
"group",
".",
"If",
"nil",
"is",
"returned",
"the",
"operation",
"was",
"successful",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/group/group.go#L217-L221 |
133,436 | messagebird/go-rest-api | voice/paginator.go | newPaginator | func newPaginator(client *messagebird.Client, endpoint string, typ reflect.Type) *Paginator {
return &Paginator{
endpoint: endpoint,
nextPage: 1, // Page indices start at 1.
structType: typ,
client: client,
}
} | go | func newPaginator(client *messagebird.Client, endpoint string, typ reflect.Type) *Paginator {
return &Paginator{
endpoint: endpoint,
nextPage: 1, // Page indices start at 1.
structType: typ,
client: client,
}
} | [
"func",
"newPaginator",
"(",
"client",
"*",
"messagebird",
".",
"Client",
",",
"endpoint",
"string",
",",
"typ",
"reflect",
".",
"Type",
")",
"*",
"Paginator",
"{",
"return",
"&",
"Paginator",
"{",
"endpoint",
":",
"endpoint",
",",
"nextPage",
":",
"1",
... | // newPaginator creates a new paginator.
//
// endpoint is called with the `page` query parameter until no more pages are
// available.
//
// typ is the non-pointer type of a single element returned by a page. | [
"newPaginator",
"creates",
"a",
"new",
"paginator",
".",
"endpoint",
"is",
"called",
"with",
"the",
"page",
"query",
"parameter",
"until",
"no",
"more",
"pages",
"are",
"available",
".",
"typ",
"is",
"the",
"non",
"-",
"pointer",
"type",
"of",
"a",
"single... | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/paginator.go#L29-L36 |
133,437 | messagebird/go-rest-api | voice/paginator.go | Stream | func (pag *Paginator) Stream() <-chan interface{} {
out := make(chan interface{})
go func() {
defer close(out)
for {
page, err := pag.NextPage()
if err != nil {
if err != io.EOF {
out <- err
}
break
}
v := reflect.ValueOf(page)
for i, l := 0, v.Len(); i < l; i++ {
out <- v.Inde... | go | func (pag *Paginator) Stream() <-chan interface{} {
out := make(chan interface{})
go func() {
defer close(out)
for {
page, err := pag.NextPage()
if err != nil {
if err != io.EOF {
out <- err
}
break
}
v := reflect.ValueOf(page)
for i, l := 0, v.Len(); i < l; i++ {
out <- v.Inde... | [
"func",
"(",
"pag",
"*",
"Paginator",
")",
"Stream",
"(",
")",
"<-",
"chan",
"interface",
"{",
"}",
"{",
"out",
":=",
"make",
"(",
"chan",
"interface",
"{",
"}",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"close",
"(",
"out",
")",
"\n",
"... | // Stream creates a channel which streams the contents of all remaining pages
// ony by one.
//
// The Paginator is consumed in the process, meaning that after elements have
// been received, NextPage will return EOF. It is invalid to mix calls to
// NextPage an Stream, even after the stream channel was closed.
//
// I... | [
"Stream",
"creates",
"a",
"channel",
"which",
"streams",
"the",
"contents",
"of",
"all",
"remaining",
"pages",
"ony",
"by",
"one",
".",
"The",
"Paginator",
"is",
"consumed",
"in",
"the",
"process",
"meaning",
"that",
"after",
"elements",
"have",
"been",
"rec... | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/paginator.go#L90-L109 |
133,438 | messagebird/go-rest-api | voice/callflow.go | CallFlowByID | func CallFlowByID(client *messagebird.Client, id string) (*CallFlow, error) {
var data struct {
Data []CallFlow `json:"data"`
}
if err := client.Request(&data, http.MethodGet, apiRoot+"/call-flows/"+id, nil); err != nil {
return nil, err
}
return &data.Data[0], nil
} | go | func CallFlowByID(client *messagebird.Client, id string) (*CallFlow, error) {
var data struct {
Data []CallFlow `json:"data"`
}
if err := client.Request(&data, http.MethodGet, apiRoot+"/call-flows/"+id, nil); err != nil {
return nil, err
}
return &data.Data[0], nil
} | [
"func",
"CallFlowByID",
"(",
"client",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"CallFlow",
",",
"error",
")",
"{",
"var",
"data",
"struct",
"{",
"Data",
"[",
"]",
"CallFlow",
"`json:\"data\"`",
"\n",
"}",
"\n",
"if",
"err... | // CallFlowByID fetches a callflow by it's ID.
//
// An error is returned if no such call flow exists or is accessible. | [
"CallFlowByID",
"fetches",
"a",
"callflow",
"by",
"it",
"s",
"ID",
".",
"An",
"error",
"is",
"returned",
"if",
"no",
"such",
"call",
"flow",
"exists",
"or",
"is",
"accessible",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/callflow.go#L116-L124 |
133,439 | messagebird/go-rest-api | voice/callflow.go | CallFlows | func CallFlows(client *messagebird.Client) *Paginator {
return newPaginator(client, apiRoot+"/call-flows/", reflect.TypeOf(CallFlow{}))
} | go | func CallFlows(client *messagebird.Client) *Paginator {
return newPaginator(client, apiRoot+"/call-flows/", reflect.TypeOf(CallFlow{}))
} | [
"func",
"CallFlows",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"*",
"Paginator",
"{",
"return",
"newPaginator",
"(",
"client",
",",
"apiRoot",
"+",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"CallFlow",
"{",
"}",
")",
")",
"\n",
"}"
] | // CallFlows returns a Paginator which iterates over all CallFlows. | [
"CallFlows",
"returns",
"a",
"Paginator",
"which",
"iterates",
"over",
"all",
"CallFlows",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/callflow.go#L127-L129 |
133,440 | messagebird/go-rest-api | voice/callflow.go | Create | func (callflow *CallFlow) Create(client *messagebird.Client) error {
var data struct {
Data []CallFlow `json:"data"`
}
if err := client.Request(&data, http.MethodPost, apiRoot+"/call-flows/", callflow); err != nil {
return err
}
*callflow = data.Data[0]
return nil
} | go | func (callflow *CallFlow) Create(client *messagebird.Client) error {
var data struct {
Data []CallFlow `json:"data"`
}
if err := client.Request(&data, http.MethodPost, apiRoot+"/call-flows/", callflow); err != nil {
return err
}
*callflow = data.Data[0]
return nil
} | [
"func",
"(",
"callflow",
"*",
"CallFlow",
")",
"Create",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"error",
"{",
"var",
"data",
"struct",
"{",
"Data",
"[",
"]",
"CallFlow",
"`json:\"data\"`",
"\n",
"}",
"\n",
"if",
"err",
":=",
"client",
"... | // Create creates the callflow remotely.
//
// The callflow is updated in-place. | [
"Create",
"creates",
"the",
"callflow",
"remotely",
".",
"The",
"callflow",
"is",
"updated",
"in",
"-",
"place",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/callflow.go#L134-L143 |
133,441 | messagebird/go-rest-api | voice/callflow.go | Update | func (callflow *CallFlow) Update(client *messagebird.Client) error {
var data struct {
Data []CallFlow `json:"data"`
}
if err := client.Request(&data, http.MethodPut, apiRoot+"/call-flows/"+callflow.ID, callflow); err != nil {
return err
}
*callflow = data.Data[0]
return nil
} | go | func (callflow *CallFlow) Update(client *messagebird.Client) error {
var data struct {
Data []CallFlow `json:"data"`
}
if err := client.Request(&data, http.MethodPut, apiRoot+"/call-flows/"+callflow.ID, callflow); err != nil {
return err
}
*callflow = data.Data[0]
return nil
} | [
"func",
"(",
"callflow",
"*",
"CallFlow",
")",
"Update",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"error",
"{",
"var",
"data",
"struct",
"{",
"Data",
"[",
"]",
"CallFlow",
"`json:\"data\"`",
"\n",
"}",
"\n",
"if",
"err",
":=",
"client",
"... | // Update updates the call flow by overwriting it.
//
// An error is returned if no such call flow exists or is accessible. | [
"Update",
"updates",
"the",
"call",
"flow",
"by",
"overwriting",
"it",
".",
"An",
"error",
"is",
"returned",
"if",
"no",
"such",
"call",
"flow",
"exists",
"or",
"is",
"accessible",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/callflow.go#L148-L157 |
133,442 | messagebird/go-rest-api | voice/callflow.go | Delete | func (callflow *CallFlow) Delete(client *messagebird.Client) error {
return client.Request(nil, http.MethodDelete, apiRoot+"/call-flows/"+callflow.ID, nil)
} | go | func (callflow *CallFlow) Delete(client *messagebird.Client) error {
return client.Request(nil, http.MethodDelete, apiRoot+"/call-flows/"+callflow.ID, nil)
} | [
"func",
"(",
"callflow",
"*",
"CallFlow",
")",
"Delete",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"error",
"{",
"return",
"client",
".",
"Request",
"(",
"nil",
",",
"http",
".",
"MethodDelete",
",",
"apiRoot",
"+",
"\"",
"\"",
"+",
"callf... | // Delete deletes the CallFlow. | [
"Delete",
"deletes",
"the",
"CallFlow",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/callflow.go#L160-L162 |
133,443 | messagebird/go-rest-api | signature/signature.go | stringToTime | func stringToTime(s string) (time.Time, error) {
sec, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return time.Time{}, err
}
return time.Unix(sec, 0), nil
} | go | func stringToTime(s string) (time.Time, error) {
sec, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return time.Time{}, err
}
return time.Unix(sec, 0), nil
} | [
"func",
"stringToTime",
"(",
"s",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"sec",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"s",
",",
"10",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"time",
... | // StringToTime converts from Unicode Epoch encoded timestamps to the time.Time type. | [
"StringToTime",
"converts",
"from",
"Unicode",
"Epoch",
"encoded",
"timestamps",
"to",
"the",
"time",
".",
"Time",
"type",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/signature/signature.go#L46-L52 |
133,444 | messagebird/go-rest-api | signature/signature.go | validTimestamp | func (v *Validator) validTimestamp(ts string) bool {
t, err := stringToTime(ts)
if err != nil {
return false
}
diff := time.Now().Add(ValidityWindow / 2).Sub(t)
return diff < ValidityWindow && diff > 0
} | go | func (v *Validator) validTimestamp(ts string) bool {
t, err := stringToTime(ts)
if err != nil {
return false
}
diff := time.Now().Add(ValidityWindow / 2).Sub(t)
return diff < ValidityWindow && diff > 0
} | [
"func",
"(",
"v",
"*",
"Validator",
")",
"validTimestamp",
"(",
"ts",
"string",
")",
"bool",
"{",
"t",
",",
"err",
":=",
"stringToTime",
"(",
"ts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"diff",
":=",
"time",
... | // validTimestamp validates if the MessageBird-Request-Timestamp is a valid
// date and if the request is older than the validator Period. | [
"validTimestamp",
"validates",
"if",
"the",
"MessageBird",
"-",
"Request",
"-",
"Timestamp",
"is",
"a",
"valid",
"date",
"and",
"if",
"the",
"request",
"is",
"older",
"than",
"the",
"validator",
"Period",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/signature/signature.go#L68-L75 |
133,445 | messagebird/go-rest-api | signature/signature.go | validSignature | func (v *Validator) validSignature(ts, rqp string, b []byte, rs string) bool {
uqp, err := url.Parse("?" + rqp)
if err != nil {
return false
}
es, err := v.calculateSignature(ts, uqp.Query().Encode(), b)
if err != nil {
return false
}
drs, err := base64.StdEncoding.DecodeString(rs)
if err != nil {
return ... | go | func (v *Validator) validSignature(ts, rqp string, b []byte, rs string) bool {
uqp, err := url.Parse("?" + rqp)
if err != nil {
return false
}
es, err := v.calculateSignature(ts, uqp.Query().Encode(), b)
if err != nil {
return false
}
drs, err := base64.StdEncoding.DecodeString(rs)
if err != nil {
return ... | [
"func",
"(",
"v",
"*",
"Validator",
")",
"validSignature",
"(",
"ts",
",",
"rqp",
"string",
",",
"b",
"[",
"]",
"byte",
",",
"rs",
"string",
")",
"bool",
"{",
"uqp",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"\"",
"\"",
"+",
"rqp",
")",
"\n",... | // validSignature takes the timestamp, query params and body from the request,
// calculates the expected signature and compares it to the one sent by MessageBird. | [
"validSignature",
"takes",
"the",
"timestamp",
"query",
"params",
"and",
"body",
"from",
"the",
"request",
"calculates",
"the",
"expected",
"signature",
"and",
"compares",
"it",
"to",
"the",
"one",
"sent",
"by",
"MessageBird",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/signature/signature.go#L95-L109 |
133,446 | messagebird/go-rest-api | signature/signature.go | ValidRequest | func (v *Validator) ValidRequest(r *http.Request) error {
ts := r.Header.Get(tsHeader)
rs := r.Header.Get(sHeader)
if ts == "" || rs == "" {
return fmt.Errorf("Unknown host: %s", r.Host)
}
b, _ := ioutil.ReadAll(r.Body)
if v.validTimestamp(ts) == false || v.validSignature(ts, r.URL.RawQuery, b, rs) == false {
... | go | func (v *Validator) ValidRequest(r *http.Request) error {
ts := r.Header.Get(tsHeader)
rs := r.Header.Get(sHeader)
if ts == "" || rs == "" {
return fmt.Errorf("Unknown host: %s", r.Host)
}
b, _ := ioutil.ReadAll(r.Body)
if v.validTimestamp(ts) == false || v.validSignature(ts, r.URL.RawQuery, b, rs) == false {
... | [
"func",
"(",
"v",
"*",
"Validator",
")",
"ValidRequest",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"ts",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"tsHeader",
")",
"\n",
"rs",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"sHeader",... | // ValidRequest is a method that takes care of the signature validation of
// incoming requests. | [
"ValidRequest",
"is",
"a",
"method",
"that",
"takes",
"care",
"of",
"the",
"signature",
"validation",
"of",
"incoming",
"requests",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/signature/signature.go#L113-L125 |
133,447 | messagebird/go-rest-api | signature/signature.go | Validate | func (v *Validator) Validate(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if err := v.ValidRequest(r); err != nil {
http.Error(w, "", http.StatusUnauthorized)
return
}
h.ServeHTTP(w, r)
})
} | go | func (v *Validator) Validate(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if err := v.ValidRequest(r); err != nil {
http.Error(w, "", http.StatusUnauthorized)
return
}
h.ServeHTTP(w, r)
})
} | [
"func",
"(",
"v",
"*",
"Validator",
")",
"Validate",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request"... | // Validate is a handler wrapper that takes care of the signature validation of
// incoming requests and rejects them if invalid or pass them on to your handler
// otherwise. | [
"Validate",
"is",
"a",
"handler",
"wrapper",
"that",
"takes",
"care",
"of",
"the",
"signature",
"validation",
"of",
"incoming",
"requests",
"and",
"rejects",
"them",
"if",
"invalid",
"or",
"pass",
"them",
"on",
"to",
"your",
"handler",
"otherwise",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/signature/signature.go#L130-L138 |
133,448 | messagebird/go-rest-api | sms/message.go | Delete | func Delete(c *messagebird.Client, id string) (*Message, error) {
message := &Message{}
if err := c.Request(message, http.MethodDelete, path+"/"+id, nil); err != nil {
return nil, err
}
return message, nil
} | go | func Delete(c *messagebird.Client, id string) (*Message, error) {
message := &Message{}
if err := c.Request(message, http.MethodDelete, path+"/"+id, nil); err != nil {
return nil, err
}
return message, nil
} | [
"func",
"Delete",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"message",
":=",
"&",
"Message",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"Request",
"(",
"message",
",",
"h... | // Cancel sending Scheduled Sms | [
"Cancel",
"sending",
"Scheduled",
"Sms"
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/sms/message.go#L97-L104 |
133,449 | messagebird/go-rest-api | sms/message.go | List | func List(c *messagebird.Client, msgListParams *ListParams) (*MessageList, error) {
messageList := &MessageList{}
params, err := paramsForMessageList(msgListParams)
if err != nil {
return messageList, err
}
if err := c.Request(messageList, http.MethodGet, path+"?"+params.Encode(), nil); err != nil {
return ni... | go | func List(c *messagebird.Client, msgListParams *ListParams) (*MessageList, error) {
messageList := &MessageList{}
params, err := paramsForMessageList(msgListParams)
if err != nil {
return messageList, err
}
if err := c.Request(messageList, http.MethodGet, path+"?"+params.Encode(), nil); err != nil {
return ni... | [
"func",
"List",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"msgListParams",
"*",
"ListParams",
")",
"(",
"*",
"MessageList",
",",
"error",
")",
"{",
"messageList",
":=",
"&",
"MessageList",
"{",
"}",
"\n",
"params",
",",
"err",
":=",
"paramsForMes... | // List retrieves all messages of the user represented as a MessageList object. | [
"List",
"retrieves",
"all",
"messages",
"of",
"the",
"user",
"represented",
"as",
"a",
"MessageList",
"object",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/sms/message.go#L107-L119 |
133,450 | messagebird/go-rest-api | sms/message.go | Create | func Create(c *messagebird.Client, originator string, recipients []string, body string, msgParams *Params) (*Message, error) {
requestData, err := requestDataForMessage(originator, recipients, body, msgParams)
if err != nil {
return nil, err
}
message := &Message{}
if err := c.Request(message, http.MethodPost, ... | go | func Create(c *messagebird.Client, originator string, recipients []string, body string, msgParams *Params) (*Message, error) {
requestData, err := requestDataForMessage(originator, recipients, body, msgParams)
if err != nil {
return nil, err
}
message := &Message{}
if err := c.Request(message, http.MethodPost, ... | [
"func",
"Create",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"originator",
"string",
",",
"recipients",
"[",
"]",
"string",
",",
"body",
"string",
",",
"msgParams",
"*",
"Params",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"requestData",
... | // Create creates a new message for one or more recipients. | [
"Create",
"creates",
"a",
"new",
"message",
"for",
"one",
"or",
"more",
"recipients",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/sms/message.go#L122-L134 |
133,451 | messagebird/go-rest-api | sms/message.go | paramsForMessageList | func paramsForMessageList(params *ListParams) (*url.Values, error) {
urlParams := &url.Values{}
if params == nil {
return urlParams, nil
}
if params.Direction != "" {
urlParams.Set("direction", params.Direction)
}
if params.Originator != "" {
urlParams.Set("originator", params.Originator)
}
if params.Li... | go | func paramsForMessageList(params *ListParams) (*url.Values, error) {
urlParams := &url.Values{}
if params == nil {
return urlParams, nil
}
if params.Direction != "" {
urlParams.Set("direction", params.Direction)
}
if params.Originator != "" {
urlParams.Set("originator", params.Originator)
}
if params.Li... | [
"func",
"paramsForMessageList",
"(",
"params",
"*",
"ListParams",
")",
"(",
"*",
"url",
".",
"Values",
",",
"error",
")",
"{",
"urlParams",
":=",
"&",
"url",
".",
"Values",
"{",
"}",
"\n\n",
"if",
"params",
"==",
"nil",
"{",
"return",
"urlParams",
",",... | // paramsForMessageList converts the specified MessageListParams struct to a
// url.Values pointer and returns it. | [
"paramsForMessageList",
"converts",
"the",
"specified",
"MessageListParams",
"struct",
"to",
"a",
"url",
".",
"Values",
"pointer",
"and",
"returns",
"it",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/sms/message.go#L180-L199 |
133,452 | messagebird/go-rest-api | conversation/message.go | ListMessages | func ListMessages(c *messagebird.Client, conversationID string, options *ListOptions) (*MessageList, error) {
query := paginationQuery(options)
uri := fmt.Sprintf("%s/%s/%s?%s", path, conversationID, messagesPath, query)
messageList := &MessageList{}
if err := request(c, messageList, http.MethodGet, uri, nil); err... | go | func ListMessages(c *messagebird.Client, conversationID string, options *ListOptions) (*MessageList, error) {
query := paginationQuery(options)
uri := fmt.Sprintf("%s/%s/%s?%s", path, conversationID, messagesPath, query)
messageList := &MessageList{}
if err := request(c, messageList, http.MethodGet, uri, nil); err... | [
"func",
"ListMessages",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"conversationID",
"string",
",",
"options",
"*",
"ListOptions",
")",
"(",
"*",
"MessageList",
",",
"error",
")",
"{",
"query",
":=",
"paginationQuery",
"(",
"options",
")",
"\n",
"ur... | // ListMessages gets a collection of messages from a conversation. Pagination
// can be set in the options. | [
"ListMessages",
"gets",
"a",
"collection",
"of",
"messages",
"from",
"a",
"conversation",
".",
"Pagination",
"can",
"be",
"set",
"in",
"the",
"options",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/message.go#L31-L41 |
133,453 | messagebird/go-rest-api | conversation/message.go | ReadMessage | func ReadMessage(c *messagebird.Client, messageID string) (*Message, error) {
message := &Message{}
if err := request(c, message, http.MethodGet, messagesPath+"/"+messageID, nil); err != nil {
return nil, err
}
return message, nil
} | go | func ReadMessage(c *messagebird.Client, messageID string) (*Message, error) {
message := &Message{}
if err := request(c, message, http.MethodGet, messagesPath+"/"+messageID, nil); err != nil {
return nil, err
}
return message, nil
} | [
"func",
"ReadMessage",
"(",
"c",
"*",
"messagebird",
".",
"Client",
",",
"messageID",
"string",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"message",
":=",
"&",
"Message",
"{",
"}",
"\n",
"if",
"err",
":=",
"request",
"(",
"c",
",",
"message",... | // ReadMessage gets a single message based on its ID. | [
"ReadMessage",
"gets",
"a",
"single",
"message",
"based",
"on",
"its",
"ID",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/conversation/message.go#L44-L51 |
133,454 | messagebird/go-rest-api | voice/transcription.go | Contents | func (trans *Transcription) Contents(client *messagebird.Client) (string, error) {
req, err := http.NewRequest(http.MethodGet, apiRoot+trans.links["file"], nil)
if err != nil {
return "", err
}
req.Header.Set("Accept", "text/plain")
req.Header.Set("Authorization", "AccessKey "+client.AccessKey)
req.Header.Set("... | go | func (trans *Transcription) Contents(client *messagebird.Client) (string, error) {
req, err := http.NewRequest(http.MethodGet, apiRoot+trans.links["file"], nil)
if err != nil {
return "", err
}
req.Header.Set("Accept", "text/plain")
req.Header.Set("Authorization", "AccessKey "+client.AccessKey)
req.Header.Set("... | [
"func",
"(",
"trans",
"*",
"Transcription",
")",
"Contents",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"http",
".",
"MethodGet",
",",
"apiRoot"... | // Contents gets the transcription file.
//
// This is a plain text file. | [
"Contents",
"gets",
"the",
"transcription",
"file",
".",
"This",
"is",
"a",
"plain",
"text",
"file",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/transcription.go#L74-L94 |
133,455 | messagebird/go-rest-api | voice/call.go | CallByID | func CallByID(client *messagebird.Client, id string) (*Call, error) {
var resp struct {
Data []Call `json:"data"`
}
if err := client.Request(&resp, http.MethodGet, apiRoot+"/calls/"+id, nil); err != nil {
return nil, err
}
return &resp.Data[0], nil
} | go | func CallByID(client *messagebird.Client, id string) (*Call, error) {
var resp struct {
Data []Call `json:"data"`
}
if err := client.Request(&resp, http.MethodGet, apiRoot+"/calls/"+id, nil); err != nil {
return nil, err
}
return &resp.Data[0], nil
} | [
"func",
"CallByID",
"(",
"client",
"*",
"messagebird",
".",
"Client",
",",
"id",
"string",
")",
"(",
"*",
"Call",
",",
"error",
")",
"{",
"var",
"resp",
"struct",
"{",
"Data",
"[",
"]",
"Call",
"`json:\"data\"`",
"\n",
"}",
"\n",
"if",
"err",
":=",
... | // CallByID fetches a call by it's ID.
//
// An error is returned if no such call flow exists or is accessible. | [
"CallByID",
"fetches",
"a",
"call",
"by",
"it",
"s",
"ID",
".",
"An",
"error",
"is",
"returned",
"if",
"no",
"such",
"call",
"flow",
"exists",
"or",
"is",
"accessible",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/call.go#L109-L117 |
133,456 | messagebird/go-rest-api | voice/call.go | Calls | func Calls(client *messagebird.Client) *Paginator {
return newPaginator(client, apiRoot+"/calls/", reflect.TypeOf(Call{}))
} | go | func Calls(client *messagebird.Client) *Paginator {
return newPaginator(client, apiRoot+"/calls/", reflect.TypeOf(Call{}))
} | [
"func",
"Calls",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"*",
"Paginator",
"{",
"return",
"newPaginator",
"(",
"client",
",",
"apiRoot",
"+",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"Call",
"{",
"}",
")",
")",
"\n",
"}"
] | // Calls returns a Paginator which iterates over all Calls. | [
"Calls",
"returns",
"a",
"Paginator",
"which",
"iterates",
"over",
"all",
"Calls",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/call.go#L120-L122 |
133,457 | messagebird/go-rest-api | voice/call.go | Delete | func (call *Call) Delete(client *messagebird.Client) error {
return client.Request(nil, http.MethodDelete, apiRoot+"/calls/"+call.ID, nil)
} | go | func (call *Call) Delete(client *messagebird.Client) error {
return client.Request(nil, http.MethodDelete, apiRoot+"/calls/"+call.ID, nil)
} | [
"func",
"(",
"call",
"*",
"Call",
")",
"Delete",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"error",
"{",
"return",
"client",
".",
"Request",
"(",
"nil",
",",
"http",
".",
"MethodDelete",
",",
"apiRoot",
"+",
"\"",
"\"",
"+",
"call",
".",... | // Delete deletes the Call.
//
// If the call is in progress, it hangs up all legs. | [
"Delete",
"deletes",
"the",
"Call",
".",
"If",
"the",
"call",
"is",
"in",
"progress",
"it",
"hangs",
"up",
"all",
"legs",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/call.go#L159-L161 |
133,458 | messagebird/go-rest-api | voice/call.go | Legs | func (call *Call) Legs(client *messagebird.Client) *Paginator {
return newPaginator(client, fmt.Sprintf("%s/calls/%s/legs", apiRoot, call.ID), reflect.TypeOf(Leg{}))
} | go | func (call *Call) Legs(client *messagebird.Client) *Paginator {
return newPaginator(client, fmt.Sprintf("%s/calls/%s/legs", apiRoot, call.ID), reflect.TypeOf(Leg{}))
} | [
"func",
"(",
"call",
"*",
"Call",
")",
"Legs",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"*",
"Paginator",
"{",
"return",
"newPaginator",
"(",
"client",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"apiRoot",
",",
"call",
".",
"ID",... | // Legs returns a paginator over all Legs associated with a call. | [
"Legs",
"returns",
"a",
"paginator",
"over",
"all",
"Legs",
"associated",
"with",
"a",
"call",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/call.go#L164-L166 |
133,459 | messagebird/go-rest-api | voice/recording.go | Transcriptions | func (rec *Recording) Transcriptions(client *messagebird.Client) *Paginator {
path := rec.links["self"] + "/transcriptions"
return newPaginator(client, path, reflect.TypeOf(Transcription{}))
} | go | func (rec *Recording) Transcriptions(client *messagebird.Client) *Paginator {
path := rec.links["self"] + "/transcriptions"
return newPaginator(client, path, reflect.TypeOf(Transcription{}))
} | [
"func",
"(",
"rec",
"*",
"Recording",
")",
"Transcriptions",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"*",
"Paginator",
"{",
"path",
":=",
"rec",
".",
"links",
"[",
"\"",
"\"",
"]",
"+",
"\"",
"\"",
"\n",
"return",
"newPaginator",
"(",
... | // Transcriptions returns a paginator for retrieving all Transcription objects. | [
"Transcriptions",
"returns",
"a",
"paginator",
"for",
"retrieving",
"all",
"Transcription",
"objects",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/recording.go#L97-L100 |
133,460 | messagebird/go-rest-api | voice/recording.go | DownloadFile | func (rec *Recording) DownloadFile(client *messagebird.Client) (io.ReadCloser, error) {
req, err := http.NewRequest(http.MethodGet, apiRoot+rec.links["file"], nil)
if err != nil {
return nil, err
}
req.Header.Set("Accept", "audio/*")
req.Header.Set("Authorization", "AccessKey "+client.AccessKey)
req.Header.Set(... | go | func (rec *Recording) DownloadFile(client *messagebird.Client) (io.ReadCloser, error) {
req, err := http.NewRequest(http.MethodGet, apiRoot+rec.links["file"], nil)
if err != nil {
return nil, err
}
req.Header.Set("Accept", "audio/*")
req.Header.Set("Authorization", "AccessKey "+client.AccessKey)
req.Header.Set(... | [
"func",
"(",
"rec",
"*",
"Recording",
")",
"DownloadFile",
"(",
"client",
"*",
"messagebird",
".",
"Client",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"http",
".",
"MethodGet",
... | // DownloadFile streams the recorded WAV file. | [
"DownloadFile",
"streams",
"the",
"recorded",
"WAV",
"file",
"."
] | fd48d63984e1cde9946be190d3a34e1a34e75e34 | https://github.com/messagebird/go-rest-api/blob/fd48d63984e1cde9946be190d3a34e1a34e75e34/voice/recording.go#L103-L120 |
133,461 | verdverm/frisby | global.go | SetData | func (G *global_data) SetData(key, value string) *global_data {
if G.Req.Data == nil {
G.Req.Data = make(map[string]string)
}
G.Req.Data[key] = value
return G
} | go | func (G *global_data) SetData(key, value string) *global_data {
if G.Req.Data == nil {
G.Req.Data = make(map[string]string)
}
G.Req.Data[key] = value
return G
} | [
"func",
"(",
"G",
"*",
"global_data",
")",
"SetData",
"(",
"key",
",",
"value",
"string",
")",
"*",
"global_data",
"{",
"if",
"G",
".",
"Req",
".",
"Data",
"==",
"nil",
"{",
"G",
".",
"Req",
".",
"Data",
"=",
"make",
"(",
"map",
"[",
"string",
... | // Set a Gorm data for the coming request | [
"Set",
"a",
"Gorm",
"data",
"for",
"the",
"coming",
"request"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/global.go#L88-L94 |
133,462 | verdverm/frisby | global.go | SetDatas | func (G *global_data) SetDatas(datas map[string]string) *global_data {
if G.Req.Data == nil {
G.Req.Data = make(map[string]string)
}
for key, value := range datas {
G.Req.Data[key] = value
}
return G
} | go | func (G *global_data) SetDatas(datas map[string]string) *global_data {
if G.Req.Data == nil {
G.Req.Data = make(map[string]string)
}
for key, value := range datas {
G.Req.Data[key] = value
}
return G
} | [
"func",
"(",
"G",
"*",
"global_data",
")",
"SetDatas",
"(",
"datas",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"global_data",
"{",
"if",
"G",
".",
"Req",
".",
"Data",
"==",
"nil",
"{",
"G",
".",
"Req",
".",
"Data",
"=",
"make",
"(",
"map",
... | // Set several Gorm data for the coming request | [
"Set",
"several",
"Gorm",
"data",
"for",
"the",
"coming",
"request"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/global.go#L97-L105 |
133,463 | verdverm/frisby | global.go | AddFile | func (G *global_data) AddFile(filename string) *global_data {
file, err := os.Open(filename)
if err != nil {
G.AddError("Global", err.Error())
fmt.Println("Error adding file to global")
} else {
fileField := request.FileField{"file", filename, file}
G.Req.Files = append(G.Req.Files, fileField)
}
return G
} | go | func (G *global_data) AddFile(filename string) *global_data {
file, err := os.Open(filename)
if err != nil {
G.AddError("Global", err.Error())
fmt.Println("Error adding file to global")
} else {
fileField := request.FileField{"file", filename, file}
G.Req.Files = append(G.Req.Files, fileField)
}
return G
} | [
"func",
"(",
"G",
"*",
"global_data",
")",
"AddFile",
"(",
"filename",
"string",
")",
"*",
"global_data",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"G",
".",
"AddError",
"(",
"\"",
... | // Add a file to the Gorm data for the coming request | [
"Add",
"a",
"file",
"to",
"the",
"Gorm",
"data",
"for",
"the",
"coming",
"request"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/global.go#L134-L144 |
133,464 | verdverm/frisby | global.go | PrintReport | func (G *global_data) PrintReport() *global_data {
fmt.Printf("\nFor %d requests made\n", G.NumRequest)
if len(G.Errs) == 0 {
fmt.Printf(" All tests passed\n")
} else {
fmt.Printf(" FAILED [%d/%d]\n", G.NumErrored, G.NumAsserts)
for key, val := range G.Errs {
fmt.Printf(" [%s]\n", key)
for _, e :... | go | func (G *global_data) PrintReport() *global_data {
fmt.Printf("\nFor %d requests made\n", G.NumRequest)
if len(G.Errs) == 0 {
fmt.Printf(" All tests passed\n")
} else {
fmt.Printf(" FAILED [%d/%d]\n", G.NumErrored, G.NumAsserts)
for key, val := range G.Errs {
fmt.Printf(" [%s]\n", key)
for _, e :... | [
"func",
"(",
"G",
"*",
"global_data",
")",
"PrintReport",
"(",
")",
"*",
"global_data",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"G",
".",
"NumRequest",
")",
"\n",
"if",
"len",
"(",
"G",
".",
"Errs",
")",
"==",
"0",
"{",
"... | // Prints a report for the FrisbyGlobal Object
//
// If there are any errors, they will all be printed as well | [
"Prints",
"a",
"report",
"for",
"the",
"FrisbyGlobal",
"Object",
"If",
"there",
"are",
"any",
"errors",
"they",
"will",
"all",
"be",
"printed",
"as",
"well"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/global.go#L164-L179 |
133,465 | verdverm/frisby | expect.go | Expect | func (F *Frisby) Expect(foo ExpectFunc) *Frisby {
Global.NumAsserts++
if ok, err_str := foo(F); !ok {
F.AddError(err_str)
}
return F
} | go | func (F *Frisby) Expect(foo ExpectFunc) *Frisby {
Global.NumAsserts++
if ok, err_str := foo(F); !ok {
F.AddError(err_str)
}
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Expect",
"(",
"foo",
"ExpectFunc",
")",
"*",
"Frisby",
"{",
"Global",
".",
"NumAsserts",
"++",
"\n",
"if",
"ok",
",",
"err_str",
":=",
"foo",
"(",
"F",
")",
";",
"!",
"ok",
"{",
"F",
".",
"AddError",
"(",
... | // Expect Checks according to the given function, which allows you to describe any kind of assertion. | [
"Expect",
"Checks",
"according",
"to",
"the",
"given",
"function",
"which",
"allows",
"you",
"to",
"describe",
"any",
"kind",
"of",
"assertion",
"."
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/expect.go#L16-L22 |
133,466 | verdverm/frisby | expect.go | ExpectStatus | func (F *Frisby) ExpectStatus(code int) *Frisby {
Global.NumAsserts++
status := F.Resp.StatusCode
if status != code {
err_str := fmt.Sprintf("Expected Status %d, but got %d: %q", code, status, F.Resp.Status)
F.AddError(err_str)
}
return F
} | go | func (F *Frisby) ExpectStatus(code int) *Frisby {
Global.NumAsserts++
status := F.Resp.StatusCode
if status != code {
err_str := fmt.Sprintf("Expected Status %d, but got %d: %q", code, status, F.Resp.Status)
F.AddError(err_str)
}
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"ExpectStatus",
"(",
"code",
"int",
")",
"*",
"Frisby",
"{",
"Global",
".",
"NumAsserts",
"++",
"\n",
"status",
":=",
"F",
".",
"Resp",
".",
"StatusCode",
"\n",
"if",
"status",
"!=",
"code",
"{",
"err_str",
":=",... | // Checks the response status code | [
"Checks",
"the",
"response",
"status",
"code"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/expect.go#L25-L33 |
133,467 | verdverm/frisby | expect.go | ExpectHeader | func (F *Frisby) ExpectHeader(key, value string) *Frisby {
Global.NumAsserts++
chk_val := F.Resp.Header.Get(key)
if chk_val == "" {
err_str := fmt.Sprintf("Expected Header %q, but it was missing", key)
F.AddError(err_str)
} else if chk_val != value {
err_str := fmt.Sprintf("Expected Header %q to be %q, but go... | go | func (F *Frisby) ExpectHeader(key, value string) *Frisby {
Global.NumAsserts++
chk_val := F.Resp.Header.Get(key)
if chk_val == "" {
err_str := fmt.Sprintf("Expected Header %q, but it was missing", key)
F.AddError(err_str)
} else if chk_val != value {
err_str := fmt.Sprintf("Expected Header %q to be %q, but go... | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"ExpectHeader",
"(",
"key",
",",
"value",
"string",
")",
"*",
"Frisby",
"{",
"Global",
".",
"NumAsserts",
"++",
"\n",
"chk_val",
":=",
"F",
".",
"Resp",
".",
"Header",
".",
"Get",
"(",
"key",
")",
"\n",
"if",
... | // Checks for header and if values match | [
"Checks",
"for",
"header",
"and",
"if",
"values",
"match"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/expect.go#L36-L47 |
133,468 | verdverm/frisby | expect.go | ExpectContent | func (F *Frisby) ExpectContent(content string) *Frisby {
Global.NumAsserts++
text, err := F.Resp.Text()
if err != nil {
F.AddError(err.Error())
return F
}
contains := strings.Contains(text, content)
if !contains {
err_str := fmt.Sprintf("Expected Body to contain %q, but it was missing", content)
F.AddErro... | go | func (F *Frisby) ExpectContent(content string) *Frisby {
Global.NumAsserts++
text, err := F.Resp.Text()
if err != nil {
F.AddError(err.Error())
return F
}
contains := strings.Contains(text, content)
if !contains {
err_str := fmt.Sprintf("Expected Body to contain %q, but it was missing", content)
F.AddErro... | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"ExpectContent",
"(",
"content",
"string",
")",
"*",
"Frisby",
"{",
"Global",
".",
"NumAsserts",
"++",
"\n",
"text",
",",
"err",
":=",
"F",
".",
"Resp",
".",
"Text",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Checks the response body for the given string | [
"Checks",
"the",
"response",
"body",
"for",
"the",
"given",
"string"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/expect.go#L50-L63 |
133,469 | verdverm/frisby | expect.go | PrintBody | func (F *Frisby) PrintBody() *Frisby {
str, err := F.Resp.Text()
if err != nil {
F.AddError(err.Error())
return F
}
fmt.Println(str)
return F
} | go | func (F *Frisby) PrintBody() *Frisby {
str, err := F.Resp.Text()
if err != nil {
F.AddError(err.Error())
return F
}
fmt.Println(str)
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"PrintBody",
"(",
")",
"*",
"Frisby",
"{",
"str",
",",
"err",
":=",
"F",
".",
"Resp",
".",
"Text",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"F",
".",
"AddError",
"(",
"err",
".",
"Error",
"(",
")",
... | // Prints the body of the response | [
"Prints",
"the",
"body",
"of",
"the",
"response"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/expect.go#L238-L246 |
133,470 | verdverm/frisby | expect.go | PrintReport | func (F *Frisby) PrintReport() *Frisby {
if len(F.Errs) == 0 {
fmt.Printf("Pass [%s]\n", F.Name)
} else {
fmt.Printf("FAIL [%s]\n", F.Name)
for _, e := range F.Errs {
fmt.Println(" - ", e)
}
}
return F
} | go | func (F *Frisby) PrintReport() *Frisby {
if len(F.Errs) == 0 {
fmt.Printf("Pass [%s]\n", F.Name)
} else {
fmt.Printf("FAIL [%s]\n", F.Name)
for _, e := range F.Errs {
fmt.Println(" - ", e)
}
}
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"PrintReport",
"(",
")",
"*",
"Frisby",
"{",
"if",
"len",
"(",
"F",
".",
"Errs",
")",
"==",
"0",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"F",
".",
"Name",
")",
"\n",
"}",
"else",
"{",
"f... | // Prints a report for the Frisby Object
//
// If there are any errors, they will all be printed as well | [
"Prints",
"a",
"report",
"for",
"the",
"Frisby",
"Object",
"If",
"there",
"are",
"any",
"errors",
"they",
"will",
"all",
"be",
"printed",
"as",
"well"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/expect.go#L251-L262 |
133,471 | verdverm/frisby | frisby.go | Get | func (F *Frisby) Get(url string) *Frisby {
F.Method = "GET"
F.Url = url
return F
} | go | func (F *Frisby) Get(url string) *Frisby {
F.Method = "GET"
F.Url = url
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Get",
"(",
"url",
"string",
")",
"*",
"Frisby",
"{",
"F",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"F",
".",
"Url",
"=",
"url",
"\n",
"return",
"F",
"\n",
"}"
] | // Set the HTTP method to GET for the given URL | [
"Set",
"the",
"HTTP",
"method",
"to",
"GET",
"for",
"the",
"given",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L55-L59 |
133,472 | verdverm/frisby | frisby.go | Post | func (F *Frisby) Post(url string) *Frisby {
F.Method = "POST"
F.Url = url
return F
} | go | func (F *Frisby) Post(url string) *Frisby {
F.Method = "POST"
F.Url = url
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Post",
"(",
"url",
"string",
")",
"*",
"Frisby",
"{",
"F",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"F",
".",
"Url",
"=",
"url",
"\n",
"return",
"F",
"\n",
"}"
] | // Set the HTTP method to POST for the given URL | [
"Set",
"the",
"HTTP",
"method",
"to",
"POST",
"for",
"the",
"given",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L62-L66 |
133,473 | verdverm/frisby | frisby.go | Put | func (F *Frisby) Put(url string) *Frisby {
F.Method = "PUT"
F.Url = url
return F
} | go | func (F *Frisby) Put(url string) *Frisby {
F.Method = "PUT"
F.Url = url
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Put",
"(",
"url",
"string",
")",
"*",
"Frisby",
"{",
"F",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"F",
".",
"Url",
"=",
"url",
"\n",
"return",
"F",
"\n",
"}"
] | // Set the HTTP method to PUT for the given URL | [
"Set",
"the",
"HTTP",
"method",
"to",
"PUT",
"for",
"the",
"given",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L69-L73 |
133,474 | verdverm/frisby | frisby.go | Patch | func (F *Frisby) Patch(url string) *Frisby {
F.Method = "PATCH"
F.Url = url
return F
} | go | func (F *Frisby) Patch(url string) *Frisby {
F.Method = "PATCH"
F.Url = url
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Patch",
"(",
"url",
"string",
")",
"*",
"Frisby",
"{",
"F",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"F",
".",
"Url",
"=",
"url",
"\n",
"return",
"F",
"\n",
"}"
] | // Set the HTTP method to PATCH for the given URL | [
"Set",
"the",
"HTTP",
"method",
"to",
"PATCH",
"for",
"the",
"given",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L76-L80 |
133,475 | verdverm/frisby | frisby.go | Delete | func (F *Frisby) Delete(url string) *Frisby {
F.Method = "DELETE"
F.Url = url
return F
} | go | func (F *Frisby) Delete(url string) *Frisby {
F.Method = "DELETE"
F.Url = url
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Delete",
"(",
"url",
"string",
")",
"*",
"Frisby",
"{",
"F",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"F",
".",
"Url",
"=",
"url",
"\n",
"return",
"F",
"\n",
"}"
] | // Set the HTTP method to DELETE for the given URL | [
"Set",
"the",
"HTTP",
"method",
"to",
"DELETE",
"for",
"the",
"given",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L83-L87 |
133,476 | verdverm/frisby | frisby.go | Head | func (F *Frisby) Head(url string) *Frisby {
F.Method = "HEAD"
F.Url = url
return F
} | go | func (F *Frisby) Head(url string) *Frisby {
F.Method = "HEAD"
F.Url = url
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Head",
"(",
"url",
"string",
")",
"*",
"Frisby",
"{",
"F",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"F",
".",
"Url",
"=",
"url",
"\n",
"return",
"F",
"\n",
"}"
] | // Set the HTTP method to HEAD for the given URL | [
"Set",
"the",
"HTTP",
"method",
"to",
"HEAD",
"for",
"the",
"given",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L90-L94 |
133,477 | verdverm/frisby | frisby.go | Options | func (F *Frisby) Options(url string) *Frisby {
F.Method = "OPTIONS"
F.Url = url
return F
} | go | func (F *Frisby) Options(url string) *Frisby {
F.Method = "OPTIONS"
F.Url = url
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Options",
"(",
"url",
"string",
")",
"*",
"Frisby",
"{",
"F",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"F",
".",
"Url",
"=",
"url",
"\n",
"return",
"F",
"\n",
"}"
] | // Set the HTTP method to OPTIONS for the given URL | [
"Set",
"the",
"HTTP",
"method",
"to",
"OPTIONS",
"for",
"the",
"given",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L97-L101 |
133,478 | verdverm/frisby | frisby.go | SetData | func (F *Frisby) SetData(key, value string) *Frisby {
if F.Req.Data == nil {
F.Req.Data = make(map[string]string)
}
F.Req.Data[key] = value
return F
} | go | func (F *Frisby) SetData(key, value string) *Frisby {
if F.Req.Data == nil {
F.Req.Data = make(map[string]string)
}
F.Req.Data[key] = value
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"SetData",
"(",
"key",
",",
"value",
"string",
")",
"*",
"Frisby",
"{",
"if",
"F",
".",
"Req",
".",
"Data",
"==",
"nil",
"{",
"F",
".",
"Req",
".",
"Data",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"st... | // Set a Form data for the coming request | [
"Set",
"a",
"Form",
"data",
"for",
"the",
"coming",
"request"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L156-L162 |
133,479 | verdverm/frisby | frisby.go | SetDatas | func (F *Frisby) SetDatas(datas map[string]string) *Frisby {
if F.Req.Data == nil {
F.Req.Data = make(map[string]string)
}
for key, value := range datas {
F.Req.Data[key] = value
}
return F
} | go | func (F *Frisby) SetDatas(datas map[string]string) *Frisby {
if F.Req.Data == nil {
F.Req.Data = make(map[string]string)
}
for key, value := range datas {
F.Req.Data[key] = value
}
return F
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"SetDatas",
"(",
"datas",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Frisby",
"{",
"if",
"F",
".",
"Req",
".",
"Data",
"==",
"nil",
"{",
"F",
".",
"Req",
".",
"Data",
"=",
"make",
"(",
"map",
"[",
"s... | // Set several Form data for the coming request | [
"Set",
"several",
"Form",
"data",
"for",
"the",
"coming",
"request"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L165-L173 |
133,480 | verdverm/frisby | frisby.go | AddFile | func (F *Frisby) AddFile(filename string) *Frisby {
file, err := os.Open(filename)
if err != nil {
F.Errs = append(F.Errs, err)
} else {
fileField := request.FileField{
FieldName: defaultFileKey,
FileName: filepath.Base(filename),
File: file}
F.Req.Files = append(F.Req.Files, fileField)
}
retu... | go | func (F *Frisby) AddFile(filename string) *Frisby {
file, err := os.Open(filename)
if err != nil {
F.Errs = append(F.Errs, err)
} else {
fileField := request.FileField{
FieldName: defaultFileKey,
FileName: filepath.Base(filename),
File: file}
F.Req.Files = append(F.Req.Files, fileField)
}
retu... | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"AddFile",
"(",
"filename",
"string",
")",
"*",
"Frisby",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"F",
".",
"Errs",
"=",
"append",
"(",
"... | // Add a file to the Form data for the coming request | [
"Add",
"a",
"file",
"to",
"the",
"Form",
"data",
"for",
"the",
"coming",
"request"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L202-L214 |
133,481 | verdverm/frisby | frisby.go | Send | func (F *Frisby) Send() *Frisby {
Global.NumRequest++
if Global.PrintProgressName {
fmt.Println(F.Name)
} else if Global.PrintProgressDot {
fmt.Printf("")
}
start := time.Now()
var err error
switch F.Method {
case "GET":
F.Resp, err = F.Req.Get(F.Url)
case "POST":
F.Resp, err = F.Req.Post(F.Url)
cas... | go | func (F *Frisby) Send() *Frisby {
Global.NumRequest++
if Global.PrintProgressName {
fmt.Println(F.Name)
} else if Global.PrintProgressDot {
fmt.Printf("")
}
start := time.Now()
var err error
switch F.Method {
case "GET":
F.Resp, err = F.Req.Get(F.Url)
case "POST":
F.Resp, err = F.Req.Post(F.Url)
cas... | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Send",
"(",
")",
"*",
"Frisby",
"{",
"Global",
".",
"NumRequest",
"++",
"\n",
"if",
"Global",
".",
"PrintProgressName",
"{",
"fmt",
".",
"Println",
"(",
"F",
".",
"Name",
")",
"\n",
"}",
"else",
"if",
"Global"... | // Send the actual request to the URL | [
"Send",
"the",
"actual",
"request",
"to",
"the",
"URL"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L235-L270 |
133,482 | verdverm/frisby | frisby.go | Error | func (F *Frisby) Error() error {
if len(F.Errs) > 0 {
return F.Errs[len(F.Errs)-1]
}
return nil
} | go | func (F *Frisby) Error() error {
if len(F.Errs) > 0 {
return F.Errs[len(F.Errs)-1]
}
return nil
} | [
"func",
"(",
"F",
"*",
"Frisby",
")",
"Error",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"F",
".",
"Errs",
")",
">",
"0",
"{",
"return",
"F",
".",
"Errs",
"[",
"len",
"(",
"F",
".",
"Errs",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"... | // Get the most recent error for the Frisby object
//
// This function should be called last | [
"Get",
"the",
"most",
"recent",
"error",
"for",
"the",
"Frisby",
"object",
"This",
"function",
"should",
"be",
"called",
"last"
] | b16556248a9a21a8166936e49771527189661abe | https://github.com/verdverm/frisby/blob/b16556248a9a21a8166936e49771527189661abe/frisby.go#L283-L288 |
133,483 | tevino/abool | bool.go | NewBool | func NewBool(ok bool) *AtomicBool {
ab := New()
if ok {
ab.Set()
}
return ab
} | go | func NewBool(ok bool) *AtomicBool {
ab := New()
if ok {
ab.Set()
}
return ab
} | [
"func",
"NewBool",
"(",
"ok",
"bool",
")",
"*",
"AtomicBool",
"{",
"ab",
":=",
"New",
"(",
")",
"\n",
"if",
"ok",
"{",
"ab",
".",
"Set",
"(",
")",
"\n",
"}",
"\n",
"return",
"ab",
"\n",
"}"
] | // NewBool creates an AtomicBool with given default value | [
"NewBool",
"creates",
"an",
"AtomicBool",
"with",
"given",
"default",
"value"
] | 9b9efcf221b50905aab9bbabd3daed56dc10f339 | https://github.com/tevino/abool/blob/9b9efcf221b50905aab9bbabd3daed56dc10f339/bool.go#L13-L19 |
133,484 | tevino/abool | bool.go | SetTo | func (ab *AtomicBool) SetTo(yes bool) {
if yes {
atomic.StoreInt32((*int32)(ab), 1)
} else {
atomic.StoreInt32((*int32)(ab), 0)
}
} | go | func (ab *AtomicBool) SetTo(yes bool) {
if yes {
atomic.StoreInt32((*int32)(ab), 1)
} else {
atomic.StoreInt32((*int32)(ab), 0)
}
} | [
"func",
"(",
"ab",
"*",
"AtomicBool",
")",
"SetTo",
"(",
"yes",
"bool",
")",
"{",
"if",
"yes",
"{",
"atomic",
".",
"StoreInt32",
"(",
"(",
"*",
"int32",
")",
"(",
"ab",
")",
",",
"1",
")",
"\n",
"}",
"else",
"{",
"atomic",
".",
"StoreInt32",
"(... | // SetTo sets the boolean with given Boolean | [
"SetTo",
"sets",
"the",
"boolean",
"with",
"given",
"Boolean"
] | 9b9efcf221b50905aab9bbabd3daed56dc10f339 | https://github.com/tevino/abool/blob/9b9efcf221b50905aab9bbabd3daed56dc10f339/bool.go#L44-L50 |
133,485 | tevino/abool | bool.go | SetToIf | func (ab *AtomicBool) SetToIf(old, new bool) (set bool) {
var o, n int32
if old {
o = 1
}
if new {
n = 1
}
return atomic.CompareAndSwapInt32((*int32)(ab), o, n)
} | go | func (ab *AtomicBool) SetToIf(old, new bool) (set bool) {
var o, n int32
if old {
o = 1
}
if new {
n = 1
}
return atomic.CompareAndSwapInt32((*int32)(ab), o, n)
} | [
"func",
"(",
"ab",
"*",
"AtomicBool",
")",
"SetToIf",
"(",
"old",
",",
"new",
"bool",
")",
"(",
"set",
"bool",
")",
"{",
"var",
"o",
",",
"n",
"int32",
"\n",
"if",
"old",
"{",
"o",
"=",
"1",
"\n",
"}",
"\n",
"if",
"new",
"{",
"n",
"=",
"1",... | // SetToIf sets the Boolean to new only if the Boolean matches the old
// Returns whether the set was done | [
"SetToIf",
"sets",
"the",
"Boolean",
"to",
"new",
"only",
"if",
"the",
"Boolean",
"matches",
"the",
"old",
"Returns",
"whether",
"the",
"set",
"was",
"done"
] | 9b9efcf221b50905aab9bbabd3daed56dc10f339 | https://github.com/tevino/abool/blob/9b9efcf221b50905aab9bbabd3daed56dc10f339/bool.go#L54-L63 |
133,486 | square/goprotowrap | wrapper/generate.go | Generate | func Generate(pkg *PackageInfo, importDirs []string, protocCommand string, protocFlags []string, printOnly bool) (err error) {
args := protocFlags[0:len(protocFlags):len(protocFlags)]
files := make([]string, 0, len(pkg.Files))
for _, f := range pkg.Files {
files = append(files, f.FullPath)
}
sort.Strings(files)... | go | func Generate(pkg *PackageInfo, importDirs []string, protocCommand string, protocFlags []string, printOnly bool) (err error) {
args := protocFlags[0:len(protocFlags):len(protocFlags)]
files := make([]string, 0, len(pkg.Files))
for _, f := range pkg.Files {
files = append(files, f.FullPath)
}
sort.Strings(files)... | [
"func",
"Generate",
"(",
"pkg",
"*",
"PackageInfo",
",",
"importDirs",
"[",
"]",
"string",
",",
"protocCommand",
"string",
",",
"protocFlags",
"[",
"]",
"string",
",",
"printOnly",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"args",
":=",
"protocFlags",
... | // Generate does the actual generation of protos. | [
"Generate",
"does",
"the",
"actual",
"generation",
"of",
"protos",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/generate.go#L30-L51 |
133,487 | square/goprotowrap | wrapper/generate.go | CopyAndChangePackage | func CopyAndChangePackage(in, out, pkg string) error {
inf, err := os.Open(in)
if err != nil {
return err
}
defer inf.Close()
outf, err := os.Create(out)
if err != nil {
return err
}
defer outf.Close()
scanner := bufio.NewScanner(inf)
matched := false
for scanner.Scan() {
line := scanner.Text()
if !m... | go | func CopyAndChangePackage(in, out, pkg string) error {
inf, err := os.Open(in)
if err != nil {
return err
}
defer inf.Close()
outf, err := os.Create(out)
if err != nil {
return err
}
defer outf.Close()
scanner := bufio.NewScanner(inf)
matched := false
for scanner.Scan() {
line := scanner.Text()
if !m... | [
"func",
"CopyAndChangePackage",
"(",
"in",
",",
"out",
",",
"pkg",
"string",
")",
"error",
"{",
"inf",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"in",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"inf",
"."... | // CopyAndChangePackage copies file `in` to file `out`, rewriting the
// `package` declaration to `pkg`. | [
"CopyAndChangePackage",
"copies",
"file",
"in",
"to",
"file",
"out",
"rewriting",
"the",
"package",
"declaration",
"to",
"pkg",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/generate.go#L57-L82 |
133,488 | square/goprotowrap | wrapper/packages.go | PackageDir | func (f FileInfo) PackageDir() string {
parts := strings.Split(f.ComputedPackage, ".")
return filepath.Join(parts...)
} | go | func (f FileInfo) PackageDir() string {
parts := strings.Split(f.ComputedPackage, ".")
return filepath.Join(parts...)
} | [
"func",
"(",
"f",
"FileInfo",
")",
"PackageDir",
"(",
")",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"f",
".",
"ComputedPackage",
",",
"\"",
"\"",
")",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"parts",
"...",
")",
"\n",
"}"
] | // PackageDir returns the desired directory location for the given
// file; ComputedPackage, with dots replaced by slashes. | [
"PackageDir",
"returns",
"the",
"desired",
"directory",
"location",
"for",
"the",
"given",
"file",
";",
"ComputedPackage",
"with",
"dots",
"replaced",
"by",
"slashes",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L51-L54 |
133,489 | square/goprotowrap | wrapper/packages.go | GoPluginOutputFilename | func (f FileInfo) GoPluginOutputFilename() string {
name := f.Name
ext := path.Ext(name)
if ext == ".proto" || ext == ".protodevel" {
name = name[0 : len(name)-len(ext)]
}
return name + ".pb.go"
} | go | func (f FileInfo) GoPluginOutputFilename() string {
name := f.Name
ext := path.Ext(name)
if ext == ".proto" || ext == ".protodevel" {
name = name[0 : len(name)-len(ext)]
}
return name + ".pb.go"
} | [
"func",
"(",
"f",
"FileInfo",
")",
"GoPluginOutputFilename",
"(",
")",
"string",
"{",
"name",
":=",
"f",
".",
"Name",
"\n",
"ext",
":=",
"path",
".",
"Ext",
"(",
"name",
")",
"\n",
"if",
"ext",
"==",
"\"",
"\"",
"||",
"ext",
"==",
"\"",
"\"",
"{"... | // GoPluginOutputFilename returns the filename the vanilla go protoc
// plugin will use when generating output for this file. | [
"GoPluginOutputFilename",
"returns",
"the",
"filename",
"the",
"vanilla",
"go",
"protoc",
"plugin",
"will",
"use",
"when",
"generating",
"output",
"for",
"this",
"file",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L58-L65 |
133,490 | square/goprotowrap | wrapper/packages.go | PackageDir | func (p PackageInfo) PackageDir() string {
parts := strings.Split(p.ComputedPackage, ".")
return filepath.Join(parts...)
} | go | func (p PackageInfo) PackageDir() string {
parts := strings.Split(p.ComputedPackage, ".")
return filepath.Join(parts...)
} | [
"func",
"(",
"p",
"PackageInfo",
")",
"PackageDir",
"(",
")",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"p",
".",
"ComputedPackage",
",",
"\"",
"\"",
")",
"\n",
"return",
"filepath",
".",
"Join",
"(",
"parts",
"...",
")",
"\n",
"}"
... | // PackageDir returns the desired directory location for the given
// package; ComputedPackage, with dots replaced by slashes. | [
"PackageDir",
"returns",
"the",
"desired",
"directory",
"location",
"for",
"the",
"given",
"package",
";",
"ComputedPackage",
"with",
"dots",
"replaced",
"by",
"slashes",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L81-L84 |
133,491 | square/goprotowrap | wrapper/packages.go | PackageName | func (p PackageInfo) PackageName() string {
parts := strings.Split(p.ComputedPackage, ".")
return parts[len(parts)-1]
} | go | func (p PackageInfo) PackageName() string {
parts := strings.Split(p.ComputedPackage, ".")
return parts[len(parts)-1]
} | [
"func",
"(",
"p",
"PackageInfo",
")",
"PackageName",
"(",
")",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"p",
".",
"ComputedPackage",
",",
"\"",
"\"",
")",
"\n",
"return",
"parts",
"[",
"len",
"(",
"parts",
")",
"-",
"1",
"]",
"\n... | // PackageName returns the desired package name for the given package;
// whatever follows the last dot in ComputedPackage. | [
"PackageName",
"returns",
"the",
"desired",
"package",
"name",
"for",
"the",
"given",
"package",
";",
"whatever",
"follows",
"the",
"last",
"dot",
"in",
"ComputedPackage",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L88-L91 |
133,492 | square/goprotowrap | wrapper/packages.go | ImportedPackageComputedNames | func (p PackageInfo) ImportedPackageComputedNames() []string {
result := []string{}
seen := map[string]bool{
p.ComputedPackage: true,
}
for _, d := range p.Deps {
pkg := d.ComputedPackage
if seen[pkg] {
continue
}
seen[pkg] = true
result = append(result, pkg)
}
return result
} | go | func (p PackageInfo) ImportedPackageComputedNames() []string {
result := []string{}
seen := map[string]bool{
p.ComputedPackage: true,
}
for _, d := range p.Deps {
pkg := d.ComputedPackage
if seen[pkg] {
continue
}
seen[pkg] = true
result = append(result, pkg)
}
return result
} | [
"func",
"(",
"p",
"PackageInfo",
")",
"ImportedPackageComputedNames",
"(",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"seen",
":=",
"map",
"[",
"string",
"]",
"bool",
"{",
"p",
".",
"ComputedPackage",
":",
"true",... | //ImportedPackageComputedNames returns the list of packages imported by this
//package. | [
"ImportedPackageComputedNames",
"returns",
"the",
"list",
"of",
"packages",
"imported",
"by",
"this",
"package",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L95-L109 |
133,493 | square/goprotowrap | wrapper/packages.go | GetFileInfos | func GetFileInfos(importPaths []string, protos []string, protocCommand string) (info map[string]*FileInfo, err error) {
if len(importPaths) == 0 {
return nil, fmt.Errorf("GetFileInfos: empty importPaths")
}
if len(protos) == 0 {
return nil, fmt.Errorf("GetFileInfos: empty protos")
}
info = map[string]*FileInfo... | go | func GetFileInfos(importPaths []string, protos []string, protocCommand string) (info map[string]*FileInfo, err error) {
if len(importPaths) == 0 {
return nil, fmt.Errorf("GetFileInfos: empty importPaths")
}
if len(protos) == 0 {
return nil, fmt.Errorf("GetFileInfos: empty protos")
}
info = map[string]*FileInfo... | [
"func",
"GetFileInfos",
"(",
"importPaths",
"[",
"]",
"string",
",",
"protos",
"[",
"]",
"string",
",",
"protocCommand",
"string",
")",
"(",
"info",
"map",
"[",
"string",
"]",
"*",
"FileInfo",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"importPat... | // GetFileInfos gets the FileInfo struct for every proto passed in. | [
"GetFileInfos",
"gets",
"the",
"FileInfo",
"struct",
"for",
"every",
"proto",
"passed",
"in",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L112-L177 |
133,494 | square/goprotowrap | wrapper/packages.go | CollectPackages | func CollectPackages(infos map[string]*FileInfo, protos []string, importDirs []string) (map[string]*PackageInfo, error) {
pkgMap := map[string]*PackageInfo{}
// Collect into packages.
for _, info := range infos {
packageInfo, ok := pkgMap[info.ComputedPackage]
if !ok {
packageInfo = &PackageInfo{ComputedPack... | go | func CollectPackages(infos map[string]*FileInfo, protos []string, importDirs []string) (map[string]*PackageInfo, error) {
pkgMap := map[string]*PackageInfo{}
// Collect into packages.
for _, info := range infos {
packageInfo, ok := pkgMap[info.ComputedPackage]
if !ok {
packageInfo = &PackageInfo{ComputedPack... | [
"func",
"CollectPackages",
"(",
"infos",
"map",
"[",
"string",
"]",
"*",
"FileInfo",
",",
"protos",
"[",
"]",
"string",
",",
"importDirs",
"[",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"PackageInfo",
",",
"error",
")",
"{",
"pkgMap",
... | // CollectPackages returns a map of PackageInfos. | [
"CollectPackages",
"returns",
"a",
"map",
"of",
"PackageInfos",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L224-L251 |
133,495 | square/goprotowrap | wrapper/packages.go | FileDescriptorName | func FileDescriptorName(protoFile string, importDirs []string) string {
isAbs := path.IsAbs(protoFile)
for _, imp := range importDirs {
// Handle import dirs of "." - the FileDescriptorProtos don't have the "./" prefix.
if imp == "." && !isAbs {
if strings.HasPrefix(protoFile, "./") {
return protoFile[2:]
... | go | func FileDescriptorName(protoFile string, importDirs []string) string {
isAbs := path.IsAbs(protoFile)
for _, imp := range importDirs {
// Handle import dirs of "." - the FileDescriptorProtos don't have the "./" prefix.
if imp == "." && !isAbs {
if strings.HasPrefix(protoFile, "./") {
return protoFile[2:]
... | [
"func",
"FileDescriptorName",
"(",
"protoFile",
"string",
",",
"importDirs",
"[",
"]",
"string",
")",
"string",
"{",
"isAbs",
":=",
"path",
".",
"IsAbs",
"(",
"protoFile",
")",
"\n",
"for",
"_",
",",
"imp",
":=",
"range",
"importDirs",
"{",
"// Handle impo... | // FileDescriptorName computes the import-dir-relative Name that the
// FileDescriptor for a full filename will have. | [
"FileDescriptorName",
"computes",
"the",
"import",
"-",
"dir",
"-",
"relative",
"Name",
"that",
"the",
"FileDescriptor",
"for",
"a",
"full",
"filename",
"will",
"have",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L255-L274 |
133,496 | square/goprotowrap | wrapper/packages.go | AnnotateFullPaths | func AnnotateFullPaths(infos map[string]*FileInfo, allProtos []string, importDirs []string) {
for _, proto := range allProtos {
name := FileDescriptorName(proto, importDirs)
info, ok := infos[name]
if !ok {
panic(fmt.Sprintf("Unable to find file information for %q", name))
}
info.FullPath = proto
}
} | go | func AnnotateFullPaths(infos map[string]*FileInfo, allProtos []string, importDirs []string) {
for _, proto := range allProtos {
name := FileDescriptorName(proto, importDirs)
info, ok := infos[name]
if !ok {
panic(fmt.Sprintf("Unable to find file information for %q", name))
}
info.FullPath = proto
}
} | [
"func",
"AnnotateFullPaths",
"(",
"infos",
"map",
"[",
"string",
"]",
"*",
"FileInfo",
",",
"allProtos",
"[",
"]",
"string",
",",
"importDirs",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"proto",
":=",
"range",
"allProtos",
"{",
"name",
":=",
"File... | // AnnotateFullPaths annotates an existing set of FileInfos with their
// full paths. | [
"AnnotateFullPaths",
"annotates",
"an",
"existing",
"set",
"of",
"FileInfos",
"with",
"their",
"full",
"paths",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/packages.go#L278-L287 |
133,497 | square/goprotowrap | wrapper/flags.go | Int | func (fv FlagValues) Int(name string, defaultValue int) (int, error) {
value, found := fv[name]
if !found {
return defaultValue, nil
}
i, err := strconv.Atoi(value)
if err != nil {
return 0, fmt.Errorf("flag %q: cannot parse integer from %q", name, value)
}
return i, nil
} | go | func (fv FlagValues) Int(name string, defaultValue int) (int, error) {
value, found := fv[name]
if !found {
return defaultValue, nil
}
i, err := strconv.Atoi(value)
if err != nil {
return 0, fmt.Errorf("flag %q: cannot parse integer from %q", name, value)
}
return i, nil
} | [
"func",
"(",
"fv",
"FlagValues",
")",
"Int",
"(",
"name",
"string",
",",
"defaultValue",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"value",
",",
"found",
":=",
"fv",
"[",
"name",
"]",
"\n",
"if",
"!",
"found",
"{",
"return",
"defaultValue",
"... | // Int returns the integer version of a flag, if set. | [
"Int",
"returns",
"the",
"integer",
"version",
"of",
"a",
"flag",
"if",
"set",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/flags.go#L128-L138 |
133,498 | square/goprotowrap | wrapper/flags.go | Bool | func (fv FlagValues) Bool(name string, defaultValue bool) (bool, error) {
value, found := fv[name]
if !found {
return defaultValue, nil
}
switch value {
case "", "t", "T", "true", "True", "1":
return true, nil
case "f", "F", "false", "False", "0":
return false, nil
}
return false, fmt.Errorf("flag %q: can... | go | func (fv FlagValues) Bool(name string, defaultValue bool) (bool, error) {
value, found := fv[name]
if !found {
return defaultValue, nil
}
switch value {
case "", "t", "T", "true", "True", "1":
return true, nil
case "f", "F", "false", "False", "0":
return false, nil
}
return false, fmt.Errorf("flag %q: can... | [
"func",
"(",
"fv",
"FlagValues",
")",
"Bool",
"(",
"name",
"string",
",",
"defaultValue",
"bool",
")",
"(",
"bool",
",",
"error",
")",
"{",
"value",
",",
"found",
":=",
"fv",
"[",
"name",
"]",
"\n",
"if",
"!",
"found",
"{",
"return",
"defaultValue",
... | // Bool returns the boolean version of a flag, if set. | [
"Bool",
"returns",
"the",
"boolean",
"version",
"of",
"a",
"flag",
"if",
"set",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/flags.go#L141-L153 |
133,499 | square/goprotowrap | wrapper/flags.go | Has | func (fv FlagValues) Has(name string) bool {
_, found := fv[name]
return found
} | go | func (fv FlagValues) Has(name string) bool {
_, found := fv[name]
return found
} | [
"func",
"(",
"fv",
"FlagValues",
")",
"Has",
"(",
"name",
"string",
")",
"bool",
"{",
"_",
",",
"found",
":=",
"fv",
"[",
"name",
"]",
"\n",
"return",
"found",
"\n",
"}"
] | // Has returns true if the given flag was specified at all. | [
"Has",
"returns",
"true",
"if",
"the",
"given",
"flag",
"was",
"specified",
"at",
"all",
"."
] | bb93590db2dbd7d818a83f78996e160fa9e3a423 | https://github.com/square/goprotowrap/blob/bb93590db2dbd7d818a83f78996e160fa9e3a423/wrapper/flags.go#L156-L159 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.