Skip to content

feat: #20220614 smsService #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/main/java/com/codeages/escloud/service/SmsService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.codeages.escloud.service;

import com.codeages.escloud.Auth;

import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

public class SmsService extends BaseService {
protected String host = "sms-service.qiqiuyun.net";

protected String[] leafHost = new String[]{"sms-service-leaf1.qiqiuyun.net", "sms-service-leaf2.qiqiuyun.net"};

public SmsService(Auth auth, Map<String, String> options) {
String host = options.put("host", this.host);
init(auth, options);
}

public String sendToOne(Map<String, String> params) throws UnsupportedEncodingException, URISyntaxException {
return this.request("POST", "/messages", params, new HashMap<>(), "root");
}

public String sendToMany(Map<String, String> params) throws UnsupportedEncodingException, URISyntaxException {
return this.request("POST", "/messages/batch_messages", params, new HashMap<>(), "root");
}

public String addSign(Map<String, String> params) throws UnsupportedEncodingException, URISyntaxException {
return this.request("POST", "/signs", params, new HashMap<>(), "root");
}

public String addTemplate(Map<String, String> params) throws UnsupportedEncodingException, URISyntaxException {
return this.request("POST", "/templates", params, new HashMap<>(), "root");
}
}