mosn/layotto

sms API definition can't adapt to Tencent cloud service prefectly

Closed this issue · 1 comments

This time I working on develop a new component for Tencent cloud sms. But I found a problem between sms API and Tencent cloud sms API. Now I already have a solution idea, so I create this new issue to talk about the idea.

Problem

When we request sms service, we need to set template parameters to it. The template parameters type defined in sms.proto file is a set of key-value pairs which key is string and value is string too.
But in Tencent cloud sms api, it need a slice of strings, instead a set of key-value pairs. When we apply for short message text template, need to use number to decide where the parameter put in, like

// short message content
Verify code: [1], message: [2]

I also checked Alibaba cloud sms docs, not like Tencent cloud sms api, it need a set of key-value pairs instead a slice of strings. So we should not modify the sms.proto file

Solution Idea

We can add a string to metadata in SendSmsWithTemplateRequest to represent the order of keys, like

// keys order in metadata
var keysOrder = "code,msg,other"
// template parameters, a set of key-value pairs in SendSmsWithTemplateRequest
var templateParams = map[string]string{
	"msg":   "okgogogo",
	"code":  "7890",
	"other": "a...",
}
// result = {"7890", "okgogogo", "a..."}

Use commas to separate every key. According the keys order to generate a slice of strings.

Can this solution idea accept?

Reference the issue #830

Hi @alilestera,
Thanks for opening an issue! 🎉