goplacetel

package module
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: MIT Imports: 5 Imported by: 0

README

placetel

With this small library you should be able to address some nodes of the Placetel API. Please note that we have only implemented a tiny part of it and will continue to develop it as needed.

Feel free to help us with the development!

Install

go get github.com/jjideenschmiede/goplacetel

How to use it?

Send SMS

With the SMS sent you are able to send sms through your Placetel account. The whole thing works as follows:

// Define body
body := goplacetel.SendSmsBody{"0123456789", "Test message!"}

// Send sms
response, err := goplacetel.SendSms(body, "token")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
Get all contacts

To get a list of all contacts, you must call the following function. This function returns all values in a struct.

// Get all contacts
contacts, err := goplacetel.Contacts("token")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(contacts)
}
Get a contact by id

Damit man einen speziellen Kontakt auslesen kann, wird die ID benötigt. Diese erhalten Sie mit der Funktion goplacetel.Contacts().

// Get a contact by id
contact, err := Contact("id", "token")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(contact)
}
Add a contact

If a new contact is to be created, then this can be done as follows. The field: id (it is the first field) can be ignored.

// Define body
body := goplacetel.ContactBody{
    0,
    "first_name",
    "last_name",
    "email",
    "email_work",
    "company",
    "address",
    "address_work",
    "phone_work",
    "mobile_work",
    "phone",
    "mobile",
    "fax",
    "fax_work",
    "facebook_url",
    "linkedin_url",
    "xing_url",
    "twitter_account",
    false,
}

// Add a new contact
contact, err := goplacetel.AddContact(body, "token")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(contact)
}
Update a contact

This function is identical to the AddContact function. With the difference that the Id must be specified.

// Define body
body := goplacetel.ContactBody{
    id,
    "first_name",
    "last_name",
    "email",
    "email_work",
    "company",
    "address",
    "address_work",
    "phone_work",
    "mobile_work",
    "phone",
    "mobile",
    "fax",
    "fax_work",
    "facebook_url",
    "linkedin_url",
    "xing_url",
    "twitter_account",
    false,
}

// Update a contact
contact, err := goplacetel.UpdateContact(body, "token")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(contact)
}
Remove a contact

To be able to remove a contact, the ID is needed. You get this with the function goplacetel.Contacts().

// Remove a contact
delete, err := goplacetel.DeleteContact("id", "token")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(delete)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContactBody

type ContactBody struct {
	Id             int    `json:"id,omitempty"`
	FirstName      string `json:"first_name"`
	LastName       string `json:"last_name"`
	Email          string `json:"email"`
	EmailWork      string `json:"email_work"`
	Company        string `json:"company"`
	Address        string `json:"address"`
	AddressWork    string `json:"address_work"`
	PhoneWork      string `json:"phone_work"`
	MobileWork     string `json:"mobile_work"`
	Phone          string `json:"phone"`
	Mobile         string `json:"mobile"`
	Fax            string `json:"fax"`
	FaxWork        string `json:"fax_work"`
	FacebookUrl    string `json:"facebook_url"`
	LinkedinUrl    string `json:"linkedin_url"`
	XingUrl        string `json:"xing_url"`
	TwitterAccount string `json:"twitter_account"`
	Blocked        bool   `json:"blocked"`
}

ContactBody is to build a new contact

type ContactReturn

type ContactReturn struct {
	Id             int         `json:"id"`
	UserId         int         `json:"user_id"`
	Speeddial      interface{} `json:"speeddial"`
	FirstName      string      `json:"first_name"`
	LastName       string      `json:"last_name"`
	Email          string      `json:"email"`
	EmailWork      string      `json:"email_work"`
	Company        string      `json:"company"`
	Address        string      `json:"address"`
	AddressWork    string      `json:"address_work"`
	PhoneWork      string      `json:"phone_work"`
	MobileWork     string      `json:"mobile_work"`
	Phone          string      `json:"phone"`
	Mobile         string      `json:"mobile"`
	Fax            string      `json:"fax"`
	FaxWork        string      `json:"fax_work"`
	FacebookUrl    string      `json:"facebook_url"`
	LinkedinUrl    string      `json:"linkedin_url"`
	XingUrl        string      `json:"xing_url"`
	TwitterAccount string      `json:"twitter_account"`
	Blocked        bool        `json:"blocked"`
	UpdatedAt      time.Time   `json:"updated_at"`
	CreatedAt      time.Time   `json:"created_at"`
}

ContactReturn is to decode the json return

func AddContact

func AddContact(body ContactBody, token string) (ContactReturn, error)

AddContact is to add a new contact

func Contact

func Contact(id string, token string) (ContactReturn, error)

Contact is to get a contact by id

func Contacts

func Contacts(token string) ([]ContactReturn, error)

Contacts is to get all contacts from the api

func UpdateContact

func UpdateContact(body ContactBody, token string) (ContactReturn, error)

UpdateContact is to add a new contact

type DeleteContactReturn

type DeleteContactReturn struct {
	Id             int         `json:"id"`
	UserId         int         `json:"user_id"`
	Speeddail      interface{} `json:"speeddail"`
	FirstName      string      `json:"firstName"`
	LastName       string      `json:"lastName"`
	Number1        string      `json:"number1"`
	Number2        string      `json:"number2"`
	Number3        string      `json:"number3"`
	Number4        string      `json:"number4"`
	Number5        string      `json:"number5"`
	IsOnBlacklist  bool        `json:"isOnBlacklist"`
	Email          string      `json:"email"`
	MoreNumbers    interface{} `json:"more_numbers"`
	ClientId       int         `json:"client_id"`
	IsGlobal       bool        `json:"is_global"`
	Company        string      `json:"company"`
	Address        string      `json:"address"`
	ContactBookId  string      `json:"contact_book_id"`
	ImportFrom     interface{} `json:"import_from"`
	ImportId       interface{} `json:"import_id"`
	EmailWork      string      `json:"email_work"`
	AddressWork    string      `json:"address_work"`
	Fax            string      `json:"fax"`
	FaxWork        string      `json:"fax_work"`
	Color          interface{} `json:"color"`
	FacebookUrl    string      `json:"facebook_url"`
	LinkedinUrl    string      `json:"linkedin_url"`
	XingUrl        string      `json:"xing_url"`
	GoogleplusUrl  interface{} `json:"googleplus_url"`
	TwitterAccount string      `json:"twitter_account"`
	CreatedAt      string      `json:"created_at"`
	UpdatedAt      string      `json:"updated_at"`
}

DeleteContactReturn is to decode the json data

func DeleteContact

func DeleteContact(id string, token string) (DeleteContactReturn, error)

DeleteContact is to add a new contact

type Request

type Request struct {
	Path, Method, Token string
	Body                []byte
}

Request is to define the request data

func (Request) Send

func (r Request) Send() (*http.Response, error)

Send is to send a new request

type SendSmsBody

type SendSmsBody struct {
	Recipient string `json:"recipient"`
	Message   string `json:"message"`
}

SendSmsBody is to build the request body

type SendSmsReturn

type SendSmsReturn struct {
	Recipient string `json:"recipient"`
	Message   string `json:"message"`
}

func SendSms

func SendSms(body SendSmsBody, token string) (SendSmsReturn, error)

SendSms is to send a sms via the placetel api

Jump to

Keyboard shortcuts

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