tilda_go

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 8 Imported by: 0

README

Tilda Golang client

License

This is unofficial Tilda SDK for GO applications. This library contains methods for interacting with the Tilda API.

Installation

go get github.com/dimuska139/tilda-go

Usage

package main

import (
	"context"
	"fmt"
	"net/http"

	tilda "github.com/dimuska139/tilda-go"
)

func main() {
	client := tilda.NewClient(&tilda.Config{
		PublicKey: "your_public_key",
		SecretKey: "your_secret_key",
	}, tilda.WithCustomHttpClient(http.DefaultClient))

	projects, err := client.GetProjectsList(context.Background())
	if err != nil {
		panic(err)
	}

	fmt.Println(projects)
}

The tests should be considered a part of the documentation. Also you can read official docs.

License

Tilda GO is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBaseURL

func WithBaseURL(baseURL string) func(*Client)

WithBaseURL option allows to set custom base url (if you use proxy, for example)

func WithCustomHttpClient

func WithCustomHttpClient(httpClient *http.Client) func(*Client)

WithCustomHttpClient option allows to set custom http client

Types

type CSS

type CSS struct {
	From string `json:"from"`
	To   string `json:"to"`
}

CSS represents information about CSS asset

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *Config, options ...func(*Client)) *Client

NewClient creates new Tilda client

func (*Client) GetPage

func (c *Client) GetPage(ctx context.Context, pageID string) (Page, error)

GetPage returns detailed page information with body HTML code

func (*Client) GetPageExport

func (c *Client) GetPageExport(ctx context.Context, pageID string) (PageExport, error)

GetPageExport returns detailed page information for export with body HTML code

func (*Client) GetPageFull

func (c *Client) GetPageFull(ctx context.Context, pageID string) (PageFull, error)

GetPageFull returns detailed page information without images, js and css but with full HTML code

func (*Client) GetPageFullExport

func (c *Client) GetPageFullExport(ctx context.Context, pageID string) (PageExport, error)

GetPageFullExport returns detailed page information for export with full HTML code

func (*Client) GetProjectInfo

func (c *Client) GetProjectInfo(ctx context.Context, projectID string) (Project, error)

GetProjectInfo returns detailed project information

func (*Client) GetProjectPages

func (c *Client) GetProjectPages(ctx context.Context, projectID string) ([]Page, error)

GetProjectPages returns the list of pages for the project

func (*Client) GetProjectsList

func (c *Client) GetProjectsList(ctx context.Context) ([]Project, error)

GetProjectsList returns the list of projects

type Config

type Config struct {
	PublicKey string
	SecretKey string
}

type DateTime

type DateTime time.Time

DateTime is a custom type for time.Time that allows to unmarshal JSON with a specific format

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(b []byte) error

type Image

type Image struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Image represents information about image

type JS

type JS struct {
	From  string   `json:"from"`
	To    string   `json:"to"`
	Attrs []string `json:"attrs"`
}

JS represents information about JS asset

type Page

type Page struct {
	ID          string   `json:"id"`
	ProjectID   string   `json:"projectid"`
	Title       string   `json:"title"`
	Description string   `json:"descr"`
	Img         string   `json:"img"`
	FeatureImg  string   `json:"featureimg"`
	Alias       string   `json:"alias"`
	Date        DateTime `json:"date"`
	Sort        int      `json:"sort,string"`
	Published   int      `json:"published,string"`
	HTML        string   `json:"html"`
	Filename    string   `json:"filename"`
	JS          []string `json:"js"`
	CSS         []string `json:"css"`
}

Page represents information about page with body HTML code

type PageExport

type PageExport struct {
	ID             string   `json:"id"`
	ProjectID      string   `json:"projectid"`
	Date           DateTime `json:"date"`
	Title          string   `json:"title"`
	Description    string   `json:"descr"`
	Img            string   `json:"img"`
	Sort           int      `json:"sort,string"`
	Published      int      `json:"published,string"`
	FeatureImg     string   `json:"featureimg"`
	Alias          string   `json:"alias"`
	Filename       string   `json:"filename"`
	ExportJSPath   string   `json:"export_jspath"`
	ExportCSSPath  string   `json:"export_csspath"`
	ExportImgPath  string   `json:"export_imgpath"`
	ExportBasePath string   `json:"export_basepath"`
	ProjectAlias   string   `json:"project_alias"`
	PageAlias      string   `json:"page_alias"`
	ProjectDomain  string   `json:"project_domain"`
	HTML           string   `json:"html"`
	Images         []Image  `json:"images"`
	JS             []JS     `json:"js"`
	CSS            []CSS    `json:"css"`
}

PageExport represents information about page for export

type PageFull

type PageFull struct {
	ID          string   `json:"id"`
	ProjectID   string   `json:"projectid"`
	Title       string   `json:"title"`
	Description string   `json:"descr"`
	Img         string   `json:"img"`
	FeatureImg  string   `json:"featureimg"`
	Alias       string   `json:"alias"`
	Date        DateTime `json:"date"`
	Sort        int      `json:"sort,string"`
	Published   int      `json:"published,string"`
	HTML        string   `json:"html"`
	Filename    string   `json:"filename"`
}

PageFull represents information about page without images, js and css but with full HTML code

type Project

type Project struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Description string `json:"descr"`
}

Project represents short information about project in the projects list

type ProjectInfo

type ProjectInfo struct {
	ID                 string    `json:"id"`
	UserID             string    `json:"userid"`
	Date               time.Time `json:"date"`
	Title              string    `json:"title"`
	Description        string    `json:"descr"`
	Img                string    `json:"img"`
	Sort               string    `json:"sort"`
	Alias              string    `json:"alias"`
	IndexpageID        string    `json:"indexpageid"`
	HeaderpageID       string    `json:"headerpageid"`
	FooterpageID       string    `json:"footerpageid"`
	HeadlineFont       string    `json:"headlinefont"`
	TextFont           string    `json:"textfont"`
	HeadlineColor      string    `json:"headlinecolor"`
	TextColor          string    `json:"textcolor"`
	LinkColor          string    `json:"linkcolor"`
	LinkFontWeight     string    `json:"linkfontweight"`
	LinkLineColor      string    `json:"linklinecolor"`
	LinkLineHeight     string    `json:"linklineheight"`
	LineColor          string    `json:"linecolor"`
	BgColor            string    `json:"bgcolor"`
	GoogleAnalyticsID  string    `json:"googleanalyticsid"`
	GoogleTmID         string    `json:"googletmid"`
	CustomDomain       string    `json:"customdomain"`
	URL                string    `json:"url"`
	IsExample          string    `json:"isexample"`
	TextFontSize       string    `json:"textfontsize"`
	TextFontWeight     string    `json:"textfontweight"`
	HeadlineFontWeight string    `json:"headlinefontweight"`
	NoSearch           string    `json:"nosearch"`
	YandexMetrikaID    string    `json:"yandexmetrikaid"`
	ExportImgPath      string    `json:"export_imgpath"`
	ExportCssPath      string    `json:"export_csspath"`
	ExportJsPath       string    `json:"export_jspath"`
	ExportBasePath     string    `json:"export_basepath"`
	ViewLogin          string    `json:"viewlogin"`
	ViewPassword       string    `json:"viewpassword"`
	ViewIPs            string    `json:"viewips"`
	Copyright          string    `json:"copyright"`
	Headcode           string    `json:"headcode"`
	UserPayment        string    `json:"userpayment"`
	FormsKey           string    `json:"formskey"`
	InfoType           string    `json:"info_type"`
	InfoTags           string    `json:"info_tags"`
	Page404ID          string    `json:"page404id"`
	MyfontsJSON        string    `json:"myfonts_json"`
	IsEmail            string    `json:"is_email"`
	Kind               string    `json:"kind"`
	Blocked            string    `json:"blocked"`
	Trash              string    `json:"trash"`
	CntFolders         string    `json:"cnt_folders"`
	CntCollabs         string    `json:"cnt_collabs"`
	Collabs            string    `json:"collabs"`
	DesignerIDn        string    `json:"designeridn"`
	Changed            string    `json:"changed"`
	Images             []Image   `json:"images"`
}

ProjectInfo represents information about project

type TildaError

type TildaError struct {
	HttpCode int    // HTTP status code (https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
	Url      string // URL of Tilda endpoint associated with callable function
	Body     string // Raw body of response
	Err      error  // Error
}

TildaError represents information about errors

func (*TildaError) Error

func (e *TildaError) Error() string

Error() converts error to string

Jump to

Keyboard shortcuts

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