moceansdk

package module
v2.1.1+incompatible Latest Latest
Warning

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

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

README

MoceanAPI Client Library for Go

This is the Go library for use Mocean's API. To use this, you'll need a Mocean account. Sign up for free at moceanapi.com.

Installation

To install the client

go get "gopkg.in/MoceanAPI/mocean-sdk-go.v2"

Usage

Create a client with your API key and secret

import "gopkg.in/MoceanAPI/mocean-sdk-go.v2"

mocean := moceansdk.NewMoceanClient("apiKey", "apiSecret")

Available API

mocean.Message().Send()             //Send SMS
mocean.Message().GetMessageStatus() //Get Message Status
mocean.Account().GetBalance()       //Get Account Balance
mocean.Account().GetPricing()       //Get Account Pricing
mocean.Verify().SendCode()          //Send Verify Code
mocean.Verify().VerifyCode()        //Check Verify Code
mocean.NumberLookup().Inquiry()     //Number Lookup
mocean.Voice().Call()               //Voice Call

Example

To use Mocean's SMS API to send an SMS message, call the mocean.Message.Send() method.

The API can be called directly, using a simple array of parameters, the keys match the parameters of the API.

res, err := mocean.Message().Send(url.Values{
    "mocean-to": {"60123456789"},
    "mocean-from": {"MOCEAN"},
    "mocean-text": {"Hello World"}
})

if err != nil {
    fmt.Println(err)
} else {
    fmt.Printf("res: %v", res)
}

Responses

For your convenient, the API response has been parsed to specific struct

fmt.Printf("res: %v", res)        // show full response string
fmt.Printf("res: %v", res.Status) // show response status, "0" in this case

Documentation

Kindly visit MoceanApi Docs for more usage

License

This library is released under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMoceanClient

func NewMoceanClient(apiKey, apiSecret string) *mocean

func SdkVersion

func SdkVersion() string

SdkVersion

Types

type CommandMcBuilderService

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

builder

func CommandNewMcBuilder

func CommandNewMcBuilder() *CommandMcBuilderService

NewMcBuilder

func (*CommandMcBuilderService) Add

func (s *CommandMcBuilderService) Add(mc interface{}) *CommandMcBuilderService

Add

func (*CommandMcBuilderService) Build

func (s *CommandMcBuilderService) Build() (string, error)

type McBuilderService

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

builder

func NewMcBuilder

func NewMcBuilder() *McBuilderService

NewMcBuilder

func (*McBuilderService) Add

func (s *McBuilderService) Add(mc interface{}) *McBuilderService

func (*McBuilderService) Build

func (s *McBuilderService) Build() (string, error)

type McCollect

type McCollect struct {
	Action      string `json:"action"`
	EventURL    string `json:"event-url"`
	Min         int    `json:"min"`
	Max         int    `json:"max"`
	Terminators string `json:"terminators"`
	Timeout     int    `json:"timeout"`
}

McCollect

func MakeMcCollect

func MakeMcCollect(eventURL string) *McCollect

MakeMcCollect

type McDial

type McDial struct {
	Action           string `json:"action"`
	To               string `json:"to"`
	From             string `json:"from"`
	DialSequentially bool   `json:"dial-sequentially"`
}

McDial

func MakeMcDial

func MakeMcDial(to string) *McDial

simple interface to make mc MakeMcDial

type McPlay

type McPlay struct {
	Action          string `json:"action"`
	File            string `json:"file"`
	BargeIn         bool   `json:"barge-in"`
	ClearDigitCache bool   `json:"clear-digit-cache"`
}

McPlay

func MakeMcPlay

func MakeMcPlay(file string) *McPlay

MakeMcPlay

type McRecord

type McRecord struct {
	Action string `json:"action"`
}

McRecord

func MakeMcRecord

func MakeMcRecord() *McRecord

MakeMcRecord

type McSay

type McSay struct {
	Action          string `json:"action"`
	Language        string `json:"language"`
	Text            string `json:"text"`
	BargeIn         bool   `json:"barge-in"`
	ClearDigitCache bool   `json:"clear-digit-cache"`
}

McSay

func MakeMcSay

func MakeMcSay(text string) *McSay

MakeMcSay

type McSleep

type McSleep struct {
	Action   string `json:"action"`
	Duration int    `json:"duration"`
}

McSleep

func MakeMcSleep

func MakeMcSleep(duration int) *McSleep

MakeMcSleep

type SendSMS

type SendSMS struct {
	Action  string    `json:"action"`
	From    TgFrom    `json:"from"`
	To      TgTo      `json:"to"`
	Content TgContent `json:"content"`
}

func MakeSendSMS

func MakeSendSMS(from string, to string, text string) *SendSMS

type TgContent

type TgContent struct {
	Type         string      `json:"type"`
	Text         interface{} `json:"text"`
	RichMediaUrl interface{} `json:"rich_media_url,omitempty"`
}

type TgFrom

type TgFrom struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

type TgKeyboard

type TgKeyboard struct {
	ButtonRequest string `json:"button_request"`
	ButtonText    string `json:"button_text"`
}

type TgRequestContact

type TgRequestContact struct {
	Action     string     `json:"action"`
	From       TgFrom     `json:"from"`
	To         TgTo       `json:"to"`
	Content    TgContent  `json:"content"`
	TgKeyboard TgKeyboard `json:tg_keyboard`
}

func MakeTgRequestContact

func MakeTgRequestContact(from string, to string, text string, opt ...string) *TgRequestContact

MakeTgRequestContact

type TgSendAnimation

type TgSendAnimation struct {
	Action  string    `json:"action"`
	From    TgFrom    `json:"from"`
	To      TgTo      `json:"to"`
	Content TgContent `json:"content"`
}

func MakeTgSendAnimation

func MakeTgSendAnimation(from string, to string, url string, opt ...string) *TgSendAnimation

MakeTgSendAnimation

type TgSendAudio

type TgSendAudio struct {
	Action  string    `json:"action"`
	From    TgFrom    `json:"from"`
	To      TgTo      `json:"to"`
	Content TgContent `json:"content"`
}

func MakeTgSendAudio

func MakeTgSendAudio(from string, to string, url string, opt ...string) *TgSendAudio

MakeTgSendAudio

type TgSendDocument

type TgSendDocument struct {
	Action  string    `json:"action"`
	From    TgFrom    `json:"from"`
	To      TgTo      `json:"to"`
	Content TgContent `json:"content"`
}

func MakeTgSendDocument

func MakeTgSendDocument(from string, to string, url string, opt ...string) *TgSendDocument

MakeTgSendDocument

type TgSendPhoto

type TgSendPhoto struct {
	Action  string    `json:"action"`
	From    TgFrom    `json:"from"`
	To      TgTo      `json:"to"`
	Content TgContent `json:"content"`
}

func MakeTgSendPhoto

func MakeTgSendPhoto(from string, to string, url string, opt ...string) *TgSendPhoto

MakeTgSendPhoto

type TgSendText

type TgSendText struct {
	Action  string    `json:"action"`
	From    TgFrom    `json:"from"`
	To      TgTo      `json:"to"`
	Content TgContent `json:"content"`
}

TgSendText

func MakeTgSendText

func MakeTgSendText(from string, to string, text string) *TgSendText

MakeTgSendText

type TgSendVideo

type TgSendVideo struct {
	Action  string    `json:"action"`
	From    TgFrom    `json:"from"`
	To      TgTo      `json:"to"`
	Content TgContent `json:"content"`
}

func MakeTgSendVideo

func MakeTgSendVideo(from string, to string, url string, opt ...string) *TgSendVideo

MakeTgSendVideo

type TgTo

type TgTo struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

Jump to

Keyboard shortcuts

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