magfa

package module
v0.2.0 Latest Latest
Warning

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

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

README

MagfaGo

Go Report Card GoDoc license

Magfa SDK for Golang

Install
go get github.com/faridgh1991/MagfaGo
Usage
package main

import (
	"fmt"
	"github.com/faridgh1991/MagfaGo"
	"log"
	"time"
)

func main() {
	client, err := magfa.New("username", "domain", "password", time.Second)
	if err != nil {
		log.Fatal(err)
	}

	responses, err := client.Send(magfa.SendRequest{
		Senders:    []string{"3000XXXXX"},
		Recipients: []string{"98912XXXXXXX", "935XXXXXXX"},
		Messages:   []string{"Hi"},
		Encodings:  nil,
		Uids:       []int64{12345},
		Udhs:       nil,
	})
	fmt.Printf("%+v ,%v\n", responses, err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is magfa service client that has multiple methods to communicate with magfa services

func New

func New(username, domain, password string, timeout time.Duration) (*Client, error)

New magfa client

func (*Client) GetBalance

func (c *Client) GetBalance() (int, error)

GetBalance of account from magfa

func (*Client) GetMessages

func (c *Client) GetMessages(count int) ([]Message, error)

GetMessages that received to magfa servers

func (*Client) GetMid

func (c *Client) GetMid(uid int) (int64, error)

GetMid of specific uid that sent

func (*Client) GetStatuses

func (c *Client) GetStatuses(mids []int64) ([]DeliveryStatus, error)

GetStatuses of delivery for a list of mid

func (*Client) Send

func (c *Client) Send(request SendRequest) ([]SendResponse, error)

Send a send request to magfa server

func (*Client) SetBaseUrl

func (c *Client) SetBaseUrl(url string)

SetBaseUrl to magfa client for change url address

type CustomTime

type CustomTime struct {
	time.Time
}

CustomTime structure

func (*CustomTime) UnmarshalJSON

func (ct *CustomTime) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON is custom unmarshaller for Date objects

type DeliveryStatus

type DeliveryStatus struct {
	Mid        int64
	Status     int
	StatusText string
	Date       CustomTime
}

DeliveryStatus is structure that contain status and date of each message

type Message

type Message struct {
	Body            string
	SenderNumber    string
	RecipientNumber string
	Date            CustomTime
}

Message is structure of received message

type SendRequest

type SendRequest struct {
	Senders    []string `json:"senders,omitempty"`
	Recipients []string `json:"recipients,omitempty"`
	Messages   []string `json:"messages,omitempty"`
	Encodings  []int    `json:"encodings,omitempty"`
	Uids       []int64  `json:"uids,omitempty"`
	Udhs       []string `json:"udhs,omitempty"`
}

SendRequest is structure of send sms requests with senders, recipients, messages and etc.

type SendResponse

type SendResponse struct {
	Status     int
	Id         int64
	UserId     int64
	Parts      int
	Tariff     float64
	Alphabet   string
	Recipient  string
	StatusText string
}

SendResponse is result of send Request for each message

Jump to

Keyboard shortcuts

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