Files
m3o-go/examples/contact/README.md
2022-03-02 10:16:25 +00:00

3.5 KiB
Executable File

Contact

An m3o.com API. For example usage see m3o.com/contact/api.

Endpoints:

Read

Read contact details

https://m3o.com/contact/api#Read

package example

import(
	"fmt"
	"os"

	"go.m3o.com/contact"
)

// Read contact details
func GetAcontact() {
	contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := contactService.Read(&contact.ReadRequest{
		Id: "42e48a3c-6221-11ec-96d2-acde48001122",

	})
	fmt.Println(rsp, err)
	
}

Delete

Delete a contact

https://m3o.com/contact/api#Delete

package example

import(
	"fmt"
	"os"

	"go.m3o.com/contact"
)

// Delete a contact
func DeleteAcontact() {
	contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := contactService.Delete(&contact.DeleteRequest{
		Id: "42e48a3c-6221-11ec-96d2-acde48001122",

	})
	fmt.Println(rsp, err)
	
}

List

List contacts

https://m3o.com/contact/api#List

package example

import(
	"fmt"
	"os"

	"go.m3o.com/contact"
)

// List contacts
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
	contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := contactService.List(&contact.ListRequest{
		
	})
	fmt.Println(rsp, err)
	
}

List

List contacts

https://m3o.com/contact/api#List

package example

import(
	"fmt"
	"os"

	"go.m3o.com/contact"
)

// List contacts
func ListContactsWithSpecificOffsetAndLimit() {
	contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := contactService.List(&contact.ListRequest{
		Limit: 1,
Offset: 1,

	})
	fmt.Println(rsp, err)
	
}

Create

Create a contact

https://m3o.com/contact/api#Create

package example

import(
	"fmt"
	"os"

	"go.m3o.com/contact"
)

// Create a contact
func CreateAcontact() {
	contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := contactService.Create(&contact.CreateRequest{
		Addresses: []contact.Address{
contact.Address{
		Label: "company address",
		Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
		Address: "home@example.com",
		Label: "home",
}},
Links: []contact.Link{
contact.Link{
		Label: "blog",
		Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
		Label: "home",
		Number: "010-12345678",
}},

	})
	fmt.Println(rsp, err)
	
}

Update

Update a contact

https://m3o.com/contact/api#Update

package example

import(
	"fmt"
	"os"

	"go.m3o.com/contact"
)

// Update a contact
func UpdateAcontact() {
	contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := contactService.Update(&contact.UpdateRequest{
		Addresses: []contact.Address{
contact.Address{
		Label: "company address",
		Location: "123 street address",
}},
Birthday: "1995-01-01",
Emails: []contact.Email{
contact.Email{
		Address: "home@example.com",
		Label: "home",
}},
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
Links: []contact.Link{
contact.Link{
		Label: "blog",
		Url: "https://blog.joe.me",
}},
Name: "joe",
Note: "this person is very important",
Phones: []contact.Phone{
contact.Phone{
		Label: "home",
		Number: "010-12345678",
}},

	})
	fmt.Println(rsp, err)
	
}