all repos — telegram-bot-api @ 41814af2a03c7d8f8ed5d098c63c9e953f197528

Golang bindings for the Telegram Bot API

Fixes and comments
MrYadro yadrishnikovyaroslav@gmail.com
Sat, 03 Jun 2017 13:59:40 +0700
commit

41814af2a03c7d8f8ed5d098c63c9e953f197528

parent

42d132b90a3e5cf1146827cdd7c2f1f8757221de

4 files changed, 32 insertions(+), 28 deletions(-)

jump to
M bot.gobot.go

@@ -705,12 +705,13 @@

return highScores, err } +// AnswerShippingQuery allows you to reply to Update with shipping_query parameter. func (bot *BotAPI) AnswerShippingQuery(config ShippingConfig) (APIResponse, error) { v := url.Values{} v.Add("shipping_query_id", config.ShippingQueryID) - v.Add("ok", strconv.FormatBool(config.Ok)) - if config.Ok == true { + v.Add("ok", strconv.FormatBool(config.OK)) + if config.OK == true { data, err := json.Marshal(config.ShippingOptions) if err != nil { return APIResponse{}, err

@@ -725,12 +726,13 @@

return bot.MakeRequest("answerShippingQuery", v) } +// AnswerPreCheckoutQuery allows you to reply to Update with pre_checkout_query. func (bot *BotAPI) AnswerPreCheckoutQuery(config PreCheckoutConfig) (APIResponse, error) { v := url.Values{} v.Add("pre_checkout_query_id", config.PreCheckoutQueryID) - v.Add("ok", strconv.FormatBool(config.Ok)) - if config.Ok != true { + v.Add("ok", strconv.FormatBool(config.OK)) + if config.OK != true { v.Add("error", config.ErrorMessage) }
M configs.goconfigs.go

@@ -900,6 +900,7 @@ SuperGroupUsername string

UserID int } +// InvoiceConfig contains information for sendInvoice request. type InvoiceConfig struct { BaseChat Title string // required

@@ -909,7 +910,7 @@ ProviderToken string // required

StartParameter string // required Currency string // required Prices *[]LabeledPrice // required - PhotoUrl string + PhotoURL string PhotoSize int PhotoWidth int PhotoHeight int

@@ -936,8 +937,8 @@ if err != nil {

return v, err } v.Add("prices", string(data)) - if config.PhotoUrl != "" { - v.Add("photo_url", config.PhotoUrl) + if config.PhotoURL != "" { + v.Add("photo_url", config.PhotoURL) } if config.PhotoSize != 0 { v.Add("photo_size", strconv.Itoa(config.PhotoSize))

@@ -971,15 +972,17 @@ func (config InvoiceConfig) method() string {

return "sendInvoice" } +// ShippingConfig contains information for answerShippingQuery request. type ShippingConfig struct { ShippingQueryID string // required - Ok bool // required + OK bool // required ShippingOptions *[]ShippingOption ErrorMessage string } +// PreCheckoutConfig conatins information for answerPreCheckoutQuery request. type PreCheckoutConfig struct { PreCheckoutQueryID string // required - Ok bool // required + OK bool // required ErrorMessage string }
M helpers.gohelpers.go

@@ -641,23 +641,15 @@ ShowAlert: true,

} } -func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice, photoUrl string, photoSize, photoWidth, photoHeight int, needName, needPhoneNumber, needEmail, needShippingAddress, isFlexible bool) InvoiceConfig { +// NewInvoice created a new Invoice request to the user. +func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig { return InvoiceConfig{ - BaseChat: BaseChat{ChatID: chatID}, - Title: title, - Description: description, - Payload: payload, - ProviderToken: providerToken, - StartParameter: startParameter, - Currency: currency, - Prices: prices, - PhotoUrl: photoUrl, - PhotoSize: photoSize, - PhotoWidth: photoWidth, - PhotoHeight: photoHeight, - NeedName: needName, - NeedPhoneNumber: needPhoneNumber, - NeedEmail: needEmail, - NeedShippingAddress: needShippingAddress, - IsFlexible: isFlexible} + BaseChat: BaseChat{ChatID: chatID}, + Title: title, + Description: description, + Payload: payload, + ProviderToken: providerToken, + StartParameter: startParameter, + Currency: currency, + Prices: prices} }
M types.gotypes.go

@@ -652,7 +652,7 @@ FirstName string `json:"first_name"`

LastName string `json:"last_name"` } -// Invoice contains information about invoice +// Invoice contains basic information about an invoice. type Invoice struct { Title string `json:"title"` Description string `json:"description"`

@@ -661,11 +661,13 @@ Currency string `json:"currency"`

TotalAmount int `json:"total_amount"` } +// LabeledPrice represents a portion of the price for goods or services. type LabeledPrice struct { Label string `json:"label"` Amount int `json:"amount"` } +// ShippingAddress represents a shipping address. type ShippingAddress struct { CountryCode string `json:"country_code"` State string `json:"state"`

@@ -675,6 +677,7 @@ StreetLine2 string `json:"street_line2"`

PostCode string `json:"post_code"` } +// OrderInfo represents information about an order. type OrderInfo struct { Name string `json:"name,omitempty"` PhoneNumber string `json:"phone_number,omitempty"`

@@ -682,12 +685,14 @@ Email string `json:"email,omitempty"`

ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"` } +// ShippingOption represents one shipping option. type ShippingOption struct { ID string `json:"id"` Title string `json:"title"` Prices *[]LabeledPrice `json:"prices"` } +// SuccessfulPayment contains basic information about a successful payment. type SuccessfulPayment struct { Currency string `json:"currency"` TotalAmount int `json:"total_amount"`

@@ -698,6 +703,7 @@ TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`

ProviderPaymentChargeID string `json:"provider_payment_charge_id"` } +// ShippingQuery contains information about an incoming shipping query. type ShippingQuery struct { ID string `json:"id"` From *User `json:"from"`

@@ -705,6 +711,7 @@ InvoicePayload string `json:"invoice_payload"`

ShippingAddress *ShippingAddress `json:"shipping_address"` } +// PreCheckoutQuery contains information about an incoming pre-checkout query. type PreCheckoutQuery struct { ID string `json:"id"` From *User `json:"from"`