sdk

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

README

English | 简体中文

uspeedo Go SDK

GitHub release Go Report Card GoDoc GitHub

Installation

Requirements

  • Go 1.10+

Use go get

go get github.com/uspeedo/uspeedo-sdk-go

Note if meet network problem, you can use go proxy to speed up the downloaded, eg: use GOPROXY environment variable

export GOPROXY=https://goproxy.io

Replay the command to retry installation.

Use go mod

Add the following snippet to any code.

import _ "github.com/uspeedo/uspeedo-sdk-go"

And execute this commands:

go mod init
go mod tidy

Use dep

dep ensure -add github.com/uspeedo/uspeedo-sdk-go

First Using

Currently, Go SDK use PublicKey/PrivateKey as authentication method, the key can be found from:

Here is a simple example:

package main

import (
	"fmt"

	"github.com/uspeedo/uspeedo-sdk-go/uspeedo"
	"github.com/uspeedo/uspeedo-sdk-go/uspeedo/auth"
	"github.com/uspeedo/uspeedo-sdk-go/services/asms"
)

func main() {
	cfg := uspeedo.NewConfig()

	// replace the public/private key by your own
	credential := auth.NewCredential()
	credential.PrivateKey = "my_private_key"
	credential.PublicKey = "my_public_key"

	asmsClient := asms.NewClient(&cfg, &credential)

	req := asmsClient.NewSendBatchUSMSMessageRequest()
	req.ChargeType = uspeedo.String("Dynamic")
	req.TaskContent = []asms.SendBatchInfo{
		{
			TemplateId: "...",
			SenderId:   "",
			Target: []asms.SendBatchTarget{
				{
					Phone: "130xxxx1321",
				},
				{
					Phone: "130xxxx1321",
				},
			},
		},
	}

	// send request
	resp, err := asmsClient.SendBatchUSMSMessage(req)
	if err != nil {
		fmt.Printf("something bad happened: %s\n", err)
	} else {
		fmt.Printf("response of the request: %v\n", resp)
	}
}

Feedback & Contribution

Documentation

Overview

Package sdk is a toolkit for developer to create custom infrastructure via uspeedo open api.

Directories

Path Synopsis
examples
mms
services
mms
Package uspeedo is a package of utilities to setup uspeedo sdk and improve using experience
Package uspeedo is a package of utilities to setup uspeedo sdk and improve using experience
auth
Package auth is the credential utilities of sdk
Package auth is the credential utilities of sdk
error
Package uerr is the error definition of service and sdk
Package uerr is the error definition of service and sdk
helpers/waiter
Package waiter is a helper package use for waiting remote state is transformed into target state.
Package waiter is a helper package use for waiting remote state is transformed into target state.
http
Package http is an implementation of http protocol
Package http is an implementation of http protocol
log
Package log is the log utilities of sdk
Package log is the log utilities of sdk
request
Package request is the request of service
Package request is the request of service
response
Package response is the response of service
Package response is the response of service
utils
Package utils is the utilities to process internal data of sdk
Package utils is the utilities to process internal data of sdk

Jump to

Keyboard shortcuts

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