SMS送信(即時送信)
import jp.karaden.Config;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.model.Message;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.param.message.MessageCreateParams;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import java.util.List;
public class TestSend {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxx-yyyy-zzzz-xxxx-123456789012";
MessageCreateParams params = MessageCreateParams.newBuilder()
.withServiceId(1)
.withTo("090********")
.withBody("テスト本文です。\nJava")
.build();
try {
Message message = Message.create(params);
System.out.println(ToStringBuilder.reflectionToString(message, MULTI_LINE_STYLE));
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}
SMS送信(予約送信)
import jp.karaden.Config;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.model.Message;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.param.message.MessageCreateParams;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import java.time.OffsetDateTime;
import org.json.JSONObject;
import java.util.List;
public class TestSendSc {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxx-yyyy-zzzz-xxxx-123456789012";
OffsetDateTime datetime = OffsetDateTime.parse("2024-04-1T18:30:00+09:00:00");
MessageCreateParams params = MessageCreateParams.newBuilder()
.withServiceId(1)
.withTo("090********")
.withBody("テスト本文です。\nJava")
.withScheduledAt(datetime)
.build();
try {
Message message = Message.create(params);
System.out.println(ToStringBuilder.reflectionToString(message, MULTI_LINE_STYLE));
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}
SMS送信結果取得(一括)
import jp.karaden.Config;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.model.Collection;
import jp.karaden.model.Message;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.param.message.MessageListParams;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
public class TestList {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxx-yyyy-zzzz-xxxx-123456789012";
MessageListParams params = MessageListParams.newBuilder()
.withServiceId(1)
.withTo("090********")
.build();
try {
Collection messages = Message.list(params);
for (Message message : messages.getData()) {
System.out.println(ToStringBuilder.reflectionToString(message, MULTI_LINE_STYLE));
}
System.out.println(ToStringBuilder.reflectionToString(messages, MULTI_LINE_STYLE));
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}
SMS送信結果取得(レコード単位)
import jp.karaden.Config;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.model.Message;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.param.message.MessageDetailParams;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import java.util.List;
public class TestDetail {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxx-yyyy-zzzz-xxxx-123456789012";
MessageDetailParams params = MessageDetailParams.newBuilder()
.withId("12345678-aabb-1234-abcd-123456789123")
.build();
try {
Message message = Message.detail(params);
System.out.println(ToStringBuilder.reflectionToString(message, MULTI_LINE_STYLE));
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}
SMS送信キャンセル
import jp.karaden.Config;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.model.Message;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.param.message.MessageCancelParams;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import java.time.OffsetDateTime;
public class TestCancel {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxx-yyyy-zzzz-xxxx-123456789012";
MessageCancelParams params = MessageCancelParams.newBuilder()
.withId("12345678-aabb-1234-abcd-123456789123")
.build();
try {
Message message = Message.cancel(params);
System.out.println(ToStringBuilder.reflectionToString(message, MULTI_LINE_STYLE));
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}
SMS送信(BULK)
import java.nio.file.Paths;
import jp.karaden.Config;
import jp.karaden.RequestOptions;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.BulkMessageCreateFailedException;
import jp.karaden.exception.BulkMessageListMessageRetryLimitExceedException;
import jp.karaden.exception.BulkMessageShowRetryLimitExceedException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.FileDownloadFailedException;
import jp.karaden.exception.FileNotFoundException;
import jp.karaden.exception.FileUploadFailedException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.InvalidRequestOptionsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.model.BulkMessage;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.service.BulkMessageService;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import java.util.List;
public class TestBulkCreate {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxxx-zzzz-yyyy-zzzz-12345678901";
try {
RequestOptions requestOptions = Config.asRequestOptions();
String filename = Paths.get(System.getProperty("user.dir"), "<csvファイル>").toString();
BulkMessage bulkMessage = BulkMessageService.create(filename, requestOptions);
System.out.println(ToStringBuilder.reflectionToString(bulkMessage, MULTI_LINE_STYLE));
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (BulkMessageCreateFailedException e) {
System.out.println("---BulkMessageCreateFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (BulkMessageListMessageRetryLimitExceedException e) {
System.out.println("---BulkMessageListMessageRetryLimitExceedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (BulkMessageShowRetryLimitExceedException e) {
System.out.println("---BulkMessageShowRetryLimitExceedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (FileDownloadFailedException e) {
System.out.println("---FileDownloadFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (FileNotFoundException e) {
System.out.println("---FileNotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (FileUploadFailedException e) {
System.out.println("---FileUploadFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
KaradenObjectInterface errors = e.error.getErrors();
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (InvalidRequestOptionsException e) {
System.out.println("---InvalidRequestOptionsException---");
KaradenObjectInterface errors = e.error.getErrors();
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}
SMS送信結果ファイル取得(BULK)
import java.nio.file.Paths;
import jp.karaden.Config;
import jp.karaden.RequestOptions;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.BulkMessageCreateFailedException;
import jp.karaden.exception.BulkMessageListMessageRetryLimitExceedException;
import jp.karaden.exception.BulkMessageShowRetryLimitExceedException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.FileDownloadFailedException;
import jp.karaden.exception.FileNotFoundException;
import jp.karaden.exception.FileUploadFailedException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.InvalidRequestOptionsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.model.BulkMessage;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.param.message.bulk.BulkMessageDownloadParams;
import jp.karaden.service.BulkMessageService;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import java.util.List;
public class TestBulkList {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxxx-zzzz-yyyy-zzzz-12345678901";
BulkMessageDownloadParams params = BulkMessageDownloadParams.newBuilder()
.withId("<BulkID>")
.withDirectoryPath("<DirectoryPath>")
.withMaxRetries(3)
.withRetryInterval(30)
.build();
try {
RequestOptions requestOptions = Config.asRequestOptions();
BulkMessageService.download(params, requestOptions);
System.out.println("Done!");
System.out.println(Config.apiVersion);
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (BulkMessageCreateFailedException e) {
System.out.println("---BulkMessageCreateFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (BulkMessageListMessageRetryLimitExceedException e) {
System.out.println("---BulkMessageListMessageRetryLimitExceedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (BulkMessageShowRetryLimitExceedException e) {
System.out.println("---BulkMessageShowRetryLimitExceedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (FileDownloadFailedException e) {
System.out.println("---FileDownloadFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (FileNotFoundException e) {
System.out.println("---FileNotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (FileUploadFailedException e) {
System.out.println("---FileUploadFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
KaradenObjectInterface errors = e.error.getErrors();
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (InvalidRequestOptionsException e) {
System.out.println("---InvalidRequestOptionsException---");
KaradenObjectInterface errors = e.error.getErrors();
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}
SMS送信状態取得(BULK)
import java.nio.file.Paths;
import jp.karaden.Config;
import jp.karaden.RequestOptions;
import jp.karaden.exception.KaradenException;
import jp.karaden.exception.BadRequestException;
import jp.karaden.exception.BulkMessageCreateFailedException;
import jp.karaden.exception.BulkMessageListMessageRetryLimitExceedException;
import jp.karaden.exception.BulkMessageShowRetryLimitExceedException;
import jp.karaden.exception.ConnectionException;
import jp.karaden.exception.FileDownloadFailedException;
import jp.karaden.exception.FileNotFoundException;
import jp.karaden.exception.FileUploadFailedException;
import jp.karaden.exception.ForbiddenException;
import jp.karaden.exception.InvalidParamsException;
import jp.karaden.exception.InvalidRequestOptionsException;
import jp.karaden.exception.NotFoundException;
import jp.karaden.exception.TooManyRequestsException;
import jp.karaden.exception.UnauthorizedException;
import jp.karaden.exception.UnexpectedValueException;
import jp.karaden.exception.UnknownErrorException;
import jp.karaden.exception.UnprocessableEntityException;
import jp.karaden.model.BulkMessage;
import jp.karaden.model.KaradenObjectInterface;
import jp.karaden.param.message.bulk.BulkMessageShowParams;
import jp.karaden.service.BulkMessageService;
import org.apache.commons.lang3.builder.ToStringBuilder;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import java.util.List;
public class TestBulkShow {
public static void main(String[] args) {
Config.apiKey = "PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Config.apiVersion = "2024-03-01";
Config.tenantId = "xxxxxxxxx-zzzz-yyyy-zzzz-12345678901";
BulkMessageShowParams params = BulkMessageShowParams.newBuilder()
.withId("<BulkID>")
.build();
try {
RequestOptions requestOptions = Config.asRequestOptions();
BulkMessage bulkMessage = BulkMessage.show(params, requestOptions);
System.out.println(ToStringBuilder.reflectionToString(bulkMessage, MULTI_LINE_STYLE));
} catch (BadRequestException e) {
System.out.println("---BadRequestException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (BulkMessageCreateFailedException e) {
System.out.println("---BulkMessageCreateFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (BulkMessageListMessageRetryLimitExceedException e) {
System.out.println("---BulkMessageListMessageRetryLimitExceedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (BulkMessageShowRetryLimitExceedException e) {
System.out.println("---BulkMessageShowRetryLimitExceedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (ConnectionException e) {
System.out.println("---ConnectionException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (FileDownloadFailedException e) {
System.out.println("---FileDownloadFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (FileNotFoundException e) {
System.out.println("---FileNotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (FileUploadFailedException e) {
System.out.println("---FileUploadFailedException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (ForbiddenException e) {
System.out.println("---ForbiddenException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (InvalidParamsException e) {
System.out.println("---InvalidParamsException---");
KaradenObjectInterface errors = e.error.getErrors();
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (InvalidRequestOptionsException e) {
System.out.println("---InvalidRequestOptionsException---");
KaradenObjectInterface errors = e.error.getErrors();
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (NotFoundException e) {
System.out.println("---NotFoundException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (TooManyRequestsException e) {
System.out.println("---TooManyRequestsException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnauthorizedException e) {
System.out.println("---UnauthorizedException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnexpectedValueException e) {
System.out.println("---UnexpectedValueException---");
System.out.println(ToStringBuilder.reflectionToString(e, MULTI_LINE_STYLE));
} catch (UnknownErrorException e) {
System.out.println("---UnknownErrorException---");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
} catch (UnprocessableEntityException e) {
System.out.println("---UnprocessableEntityException---");
System.out.println("[e.error]");
System.out.println(ToStringBuilder.reflectionToString(e.error, MULTI_LINE_STYLE));
KaradenObjectInterface errors = e.error.getErrors();
System.out.println("[e.error.getErrors()]");
System.out.println(ToStringBuilder.reflectionToString(errors, MULTI_LINE_STYLE));
} catch (KaradenException e) {
System.out.println("[KaradenException]");
// 取りこぼした例外を表示
if(e.error == null){
System.out.println("Error: " + e.getMessage());
}else{
System.out.println("Error.: " + e.error.getMessage());
}
} catch (Exception e) {
System.out.println("[Error!]");
e.printStackTrace();
}
}
}