models

package
v0.0.0-...-429faff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message interface {
	Parse(body *WebhookBody) Message

	ToSheetRow() []interface{}

	SendAsTelegramMessage() (*http.Response, error)
}

type Payment

type Payment struct {
	Date        string      `json:"date"`
	Customer    string      `json:"customer"`
	Method      string      `json:"method"`
	Amount      int64       `json:"amount"`
	WebhookBody WebhookBody `json:"webhhok_body"`
}

func (*Payment) Parse

func (p *Payment) Parse(body *WebhookBody) Message

func (*Payment) SendAsTelegramMessage

func (p *Payment) SendAsTelegramMessage() (*http.Response, error)

func (*Payment) ToSheetRow

func (p *Payment) ToSheetRow() []interface{}

type Transaction

type Transaction struct {
	Date        string      `json:"date"`
	Customer    string      `json:"customer"`
	Product     string      `json:"product"`
	Price       uint64      `json:"price"`
	WebhookBody WebhookBody `json:"webhhok_body"`
}

func (*Transaction) Parse

func (t *Transaction) Parse(body *WebhookBody) Message

func (*Transaction) SendAsTelegramMessage

func (t *Transaction) SendAsTelegramMessage() (*http.Response, error)

func (*Transaction) ToSheetRow

func (t *Transaction) ToSheetRow() []interface{}

type WebhookBody

type WebhookBody struct {
	Message struct {
		From struct {
			ID        int64  `json:"id"`
			FirstName string `json:"first_name"`
		} `json:"from"`
		Date uint64 `json:"date"`
		Text string `json:"text"`
		Chat struct {
			ID int64 `json:"id"`
		} `json:"chat"`
	} `json:"message"`
}

func (*WebhookBody) IsValidUser

func (body *WebhookBody) IsValidUser() bool

func (*WebhookBody) ToMessage

func (body *WebhookBody) ToMessage() (Message, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL