SMS送信(即時送信)
from datetime import datetime
from karaden.config import Config
from karaden.param.message_create_params import MessageCreateParams
from karaden.model.message import Message
from karaden.exception.bad_request_exception import BadRequestException
from karaden.exception.forbidden_exception import ForbiddenException
from karaden.exception.invalid_params_exception import InvalidParamsException
from karaden.exception.not_found_exception import NotFoundException
from karaden.exception.too_many_reqests_exception import TooManyRequestsException
from karaden.exception.unauthorized_exception import UnauthorizedException
from karaden.exception.unexpected_value_exception import UnexpectedValueException
from karaden.exception.unknown_error_exception import UnknownErrorException
from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException
Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Config.api_version = '2024-03-01'
Config.tenant_id = 'xxxxxxxx-yyyy-zzzz-xxxx-123456789012'
body = """
テスト本文です。
Python
"""
params = (
MessageCreateParams
.new_builder()
.with_service_id(1)
.with_to('090********')
.with_body(body)
.with_tags(['testtag'])
.with_is_shorten(False)
.build()
)
request_options = Config.as_request_options()
try:
message = Message.create(params, request_options)
print(vars(message))
except BadRequestException as e:
print("BadRequestExceptionが返されました")
print(vars(e))
except ForbiddenException as e:
print("ForbiddenExceptionが返されました")
print(vars(e))
except InvalidParamsException as e:
print("InvalidParamsExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except NotFoundException as e:
print("NotFoundExceptionが返されました")
print(vars(e))
except TooManyRequestsException as e:
print("TooManyRequestsExceptionが返されました")
print(vars(e))
except UnauthorizedException as e:
print("UnauthorizedExceptionが返されました")
print(vars(e))
except UnexpectedValueException as e:
print("UnexpectedValueExceptionが返されました")
print(vars(e))
except UnknownErrorException as e:
print("UnknownErrorExceptionが返されました")
print(vars(e))
except UnprocessableEntityException as e:
print("UnprocessableEntityExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except Exception as e:
print("[Error!]")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
print(vars(e))
SMS送信(予約送信)
from datetime import datetime
from karaden.config import Config
from karaden.param.message_create_params import MessageCreateParams
from karaden.model.message import Message
from karaden.exception.bad_request_exception import BadRequestException
from karaden.exception.forbidden_exception import ForbiddenException
from karaden.exception.invalid_params_exception import InvalidParamsException
from karaden.exception.not_found_exception import NotFoundException
from karaden.exception.too_many_reqests_exception import TooManyRequestsException
from karaden.exception.unauthorized_exception import UnauthorizedException
from karaden.exception.unexpected_value_exception import UnexpectedValueException
from karaden.exception.unknown_error_exception import UnknownErrorException
from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException
Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Config.api_version = '2024-03-01'
Config.tenant_id = 'xxxxxxxx-yyyy-zzzz-xxxx-123456789012'
dt = datetime.fromisoformat('2024-04-06T18:15:00+09:00')
body = """
テスト本文です。
Python
"""
params = (
MessageCreateParams
.new_builder()
.with_service_id(1)
.with_to('090********')
.with_body(body)
.with_tags(['testtag'])
.with_is_shorten(False)
.with_scheduled_at(dt)
.build()
)
request_options = Config.as_request_options()
try:
message = Message.create(params, request_options)
print(vars(message))
except BadRequestException as e:
print("BadRequestExceptionが返されました")
print(vars(e))
except ForbiddenException as e:
print("ForbiddenExceptionが返されました")
print(vars(e))
except InvalidParamsException as e:
print("InvalidParamsExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except NotFoundException as e:
print("NotFoundExceptionが返されました")
print(vars(e))
except TooManyRequestsException as e:
print("TooManyRequestsExceptionが返されました")
print(vars(e))
except UnauthorizedException as e:
print("UnauthorizedExceptionが返されました")
print(vars(e))
except UnexpectedValueException as e:
print("UnexpectedValueExceptionが返されました")
print(vars(e))
except UnknownErrorException as e:
print("UnknownErrorExceptionが返されました")
print(vars(e))
except UnprocessableEntityException as e:
print("UnprocessableEntityExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except Exception as e:
print("[Error!]")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
print(vars(e))
SMS送信結果取得(一括)
from datetime import datetime
from karaden.config import Config
from karaden.param.message_list_params import MessageListParams
from karaden.model.message import Message
from karaden.exception.bad_request_exception import BadRequestException
from karaden.exception.forbidden_exception import ForbiddenException
from karaden.exception.invalid_params_exception import InvalidParamsException
from karaden.exception.not_found_exception import NotFoundException
from karaden.exception.too_many_reqests_exception import TooManyRequestsException
from karaden.exception.unauthorized_exception import UnauthorizedException
from karaden.exception.unexpected_value_exception import UnexpectedValueException
from karaden.exception.unknown_error_exception import UnknownErrorException
from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException
Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Config.api_version = '2024-03-01'
Config.tenant_id = 'xxxxxxxx-yyyy-zzzz-xxxx-123456789012'
params = (
MessageListParams
.new_builder()
.with_service_id(1)
.with_to('090********')
.with_status('done')
.build()
)
request_options = Config.as_request_options()
try:
collection = Message.list(params, request_options)
for item in collection._properties['data']:
print(item.__dict__)
print("------------------------------")
print(vars(collection))
except BadRequestException as e:
print("BadRequestExceptionが返されました")
print(vars(e))
except ForbiddenException as e:
print("ForbiddenExceptionが返されました")
print(vars(e))
except InvalidParamsException as e:
print("InvalidParamsExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except NotFoundException as e:
print("NotFoundExceptionが返されました")
print(vars(e))
except TooManyRequestsException as e:
print("TooManyRequestsExceptionが返されました")
print(vars(e))
except UnauthorizedException as e:
print("UnauthorizedExceptionが返されました")
print(vars(e))
except UnexpectedValueException as e:
print("UnexpectedValueExceptionが返されました")
print(vars(e))
except UnknownErrorException as e:
print("UnknownErrorExceptionが返されました")
print(vars(e))
except UnprocessableEntityException as e:
print("UnprocessableEntityExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except Exception as e:
print("[Error!]")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
print(vars(e))
SMS送信結果取得(レコード単位)
from datetime import datetime
from karaden.config import Config
from karaden.param.message_detail_params import MessageDetailParams
from karaden.model.message import Message
from karaden.exception.bad_request_exception import BadRequestException
from karaden.exception.forbidden_exception import ForbiddenException
from karaden.exception.invalid_params_exception import InvalidParamsException
from karaden.exception.not_found_exception import NotFoundException
from karaden.exception.too_many_reqests_exception import TooManyRequestsException
from karaden.exception.unauthorized_exception import UnauthorizedException
from karaden.exception.unexpected_value_exception import UnexpectedValueException
from karaden.exception.unknown_error_exception import UnknownErrorException
from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException
Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Config.api_version = '2024-03-01'
Config.tenant_id = 'xxxxxxxx-yyyy-zzzz-xxxx-123456789012'
params = (
MessageDetailParams
.new_builder()
.with_id('12345678-aabb-1234-abcd-123456789123')
.build()
)
request_options = Config.as_request_options()
try:
message = Message.detail(params, request_options)
print(vars(message))
except BadRequestException as e:
print("BadRequestExceptionが返されました")
print(vars(e))
except ForbiddenException as e:
print("ForbiddenExceptionが返されました")
print(vars(e))
except InvalidParamsException as e:
print("InvalidParamsExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except NotFoundException as e:
print("NotFoundExceptionが返されました")
print(vars(e))
except TooManyRequestsException as e:
print("TooManyRequestsExceptionが返されました")
print(vars(e))
except UnauthorizedException as e:
print("UnauthorizedExceptionが返されました")
print(vars(e))
except UnexpectedValueException as e:
print("UnexpectedValueExceptionが返されました")
print(vars(e))
except UnknownErrorException as e:
print("UnknownErrorExceptionが返されました")
print(vars(e))
except UnprocessableEntityException as e:
print("UnprocessableEntityExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except Exception as e:
print("[Error!]")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
print(vars(e))
SMS送信キャンセル
from datetime import datetime
from karaden.config import Config
from karaden.param.message_cancel_params import MessageCancelParams
from karaden.model.message import Message
from karaden.exception.bad_request_exception import BadRequestException
from karaden.exception.forbidden_exception import ForbiddenException
from karaden.exception.invalid_params_exception import InvalidParamsException
from karaden.exception.not_found_exception import NotFoundException
from karaden.exception.too_many_reqests_exception import TooManyRequestsException
from karaden.exception.unauthorized_exception import UnauthorizedException
from karaden.exception.unexpected_value_exception import UnexpectedValueException
from karaden.exception.unknown_error_exception import UnknownErrorException
from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException
Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Config.api_version = '2024-03-01'
Config.tenant_id = 'xxxxxxxx-yyyy-zzzz-xxxx-123456789012'
params = (
MessageCancelParams
.new_builder()
.with_id('12345678-aabb-1234-abcd-123456789123')
.build()
)
request_options = Config.as_request_options()
try:
message = Message.cancel(params, request_options)
print(vars(message))
except BadRequestException as e:
print("BadRequestExceptionが返されました")
print(vars(e))
except ForbiddenException as e:
print("ForbiddenExceptionが返されました")
print(vars(e))
except InvalidParamsException as e:
print("InvalidParamsExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except NotFoundException as e:
print("NotFoundExceptionが返されました")
print(vars(e))
except TooManyRequestsException as e:
print("TooManyRequestsExceptionが返されました")
print(vars(e))
except UnauthorizedException as e:
print("UnauthorizedExceptionが返されました")
print(vars(e))
except UnexpectedValueException as e:
print("UnexpectedValueExceptionが返されました")
print(vars(e))
except UnknownErrorException as e:
print("UnknownErrorExceptionが返されました")
print(vars(e))
except UnprocessableEntityException as e:
print("UnprocessableEntityExceptionが返されました")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
except Exception as e:
print("[Error!]")
error_obj = e.error
error_object = error_obj.errors
if(error_object):
print(vars(error_object))
print(vars(e))
SMS送信(BULK)
import os from karaden.config import Config from karaden.model.message import Message from karaden.service.bulk_message_service import BulkMessageService from karaden.exception.bad_request_exception import BadRequestException from karaden.exception.bulk_message_create_failed_exception import BulkMessageCreateFailedException from karaden.exception.bulk_message_list_message_retry_limit_exceed_exception import BulkMessageListMessageRetryLimitExceedException from karaden.exception.bulk_message_show_retry_limit_exceed_exception import BulkMessageShowRetryLimitExceedException from karaden.exception.file_download_failed_exception import FileDownloadFailedException from karaden.exception.file_not_found_exception import FileNotFoundException from karaden.exception.file_upload_failed_exception import FileUploadFailedException from karaden.exception.forbidden_exception import ForbiddenException from karaden.exception.invalid_params_exception import InvalidParamsException from karaden.exception.invalid_request_options_exception import InvalidRequestOptionsException from karaden.exception.karaden_exception import KaradenException from karaden.exception.not_found_exception import NotFoundException from karaden.exception.too_many_requests_exception import TooManyRequestsException from karaden.exception.unauthorized_exception import UnauthorizedException from karaden.exception.unexpected_value_exception import UnexpectedValueException from karaden.exception.unknown_error_exception import UnknownErrorException from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' Config.api_version = '2024-03-01' Config.tenant_id = 'xxxxxxxxx-zzzz-yyyy-zzzz-12345678901' request_options = Config.as_request_options() filename = os.path.join(os.getcwd(), '<csvファイル>') try: bulkMessage = BulkMessageService.create(filename, request_options) print(vars(bulkMessage)) print("Config.VERSION : " + Config.VERSION) except BadRequestException as e: print("BadRequestExceptionが返されました") print(vars(e)) except BulkMessageCreateFailedException as e: print("BulkMessageCreateFailedExceptionが返されました") print(vars(e)) except BulkMessageListMessageRetryLimitExceedException as e: print("BulkMessageListMessageRetryLimitExceedExceptionが返されました") print(vars(e)) except BulkMessageShowRetryLimitExceedException as e: print("BulkMessageShowRetryLimitExceedExceptionが返されました") print(vars(e)) except FileDownloadFailedException as e: print("FileDownloadFailedExceptionが返されました") print(vars(e)) except FileNotFoundException as e: print("FileNotFoundExceptionが返されました") print(vars(e)) except FileUploadFailedException as e: print("FileUploadFailedExceptionが返されました") print(vars(e)) except ForbiddenException as e: print("ForbiddenExceptionが返されました") print(vars(e)) except InvalidParamsException as e: print("InvalidParamsExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except InvalidRequestOptionsException as e: print("InvalidRequestOptionsExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except NotFoundException as e: print("NotFoundExceptionが返されました") print(vars(e)) except TooManyRequestsException as e: print("TooManyRequestsExceptionが返されました") print(vars(e)) except UnauthorizedException as e: print("UnauthorizedExceptionが返されました") print(vars(e)) except UnexpectedValueException as e: print("UnexpectedValueExceptionが返されました") print(vars(e)) except UnknownErrorException as e: print("UnknownErrorExceptionが返されました") print(vars(e)) except UnprocessableEntityException as e: print("UnprocessableEntityExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except KaradenException as e: print("KaradenExceptionが返されました") print(vars(e)) except Exception as e: print("[Error!]") print(vars(e))
SMS送信結果ファイル取得(BULK)
from karaden.config import Config from karaden.param.bulk.bulk_message_download_params import BulkMessageDownloadParams from karaden.service.bulk_message_service import BulkMessageService from karaden.exception.bad_request_exception import BadRequestException from karaden.exception.bulk_message_create_failed_exception import BulkMessageCreateFailedException from karaden.exception.bulk_message_list_message_retry_limit_exceed_exception import BulkMessageListMessageRetryLimitExceedException from karaden.exception.bulk_message_show_retry_limit_exceed_exception import BulkMessageShowRetryLimitExceedException from karaden.exception.file_download_failed_exception import FileDownloadFailedException from karaden.exception.file_not_found_exception import FileNotFoundException from karaden.exception.file_upload_failed_exception import FileUploadFailedException from karaden.exception.forbidden_exception import ForbiddenException from karaden.exception.invalid_params_exception import InvalidParamsException from karaden.exception.invalid_request_options_exception import InvalidRequestOptionsException from karaden.exception.karaden_exception import KaradenException from karaden.exception.not_found_exception import NotFoundException from karaden.exception.too_many_requests_exception import TooManyRequestsException from karaden.exception.unauthorized_exception import UnauthorizedException from karaden.exception.unexpected_value_exception import UnexpectedValueException from karaden.exception.unknown_error_exception import UnknownErrorException from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' Config.api_version = '2024-03-01' Config.tenant_id = 'xxxxxxxxx-zzzz-yyyy-zzzz-12345678901' params = ( BulkMessageDownloadParams .new_builder() .with_id('<BulkID>') .with_directory_path('<directory_path>') .with_max_retries(3) .with_retry_interval(30) .build() ) request_options = Config.as_request_options() BulkMessageService.download(params, request_options) try: print("done!") print("Config.VERSION : " + Config.VERSION) except BadRequestException as e: print("BadRequestExceptionが返されました") print(vars(e)) except BulkMessageCreateFailedException as e: print("BulkMessageCreateFailedExceptionが返されました") print(vars(e)) except BulkMessageListMessageRetryLimitExceedException as e: print("BulkMessageListMessageRetryLimitExceedExceptionが返されました") print(vars(e)) except BulkMessageShowRetryLimitExceedException as e: print("BulkMessageShowRetryLimitExceedExceptionが返されました") print(vars(e)) except FileDownloadFailedException as e: print("FileDownloadFailedExceptionが返されました") print(vars(e)) except FileNotFoundException as e: print("FileNotFoundExceptionが返されました") print(vars(e)) except FileUploadFailedException as e: print("FileUploadFailedExceptionが返されました") print(vars(e)) except ForbiddenException as e: print("ForbiddenExceptionが返されました") print(vars(e)) except InvalidParamsException as e: print("InvalidParamsExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except InvalidRequestOptionsException as e: print("InvalidRequestOptionsExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except NotFoundException as e: print("NotFoundExceptionが返されました") print(vars(e)) except TooManyRequestsException as e: print("TooManyRequestsExceptionが返されました") print(vars(e)) except UnauthorizedException as e: print("UnauthorizedExceptionが返されました") print(vars(e)) except UnexpectedValueException as e: print("UnexpectedValueExceptionが返されました") print(vars(e)) except UnknownErrorException as e: print("UnknownErrorExceptionが返されました") print(vars(e)) except UnprocessableEntityException as e: print("UnprocessableEntityExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except KaradenException as e: print("KaradenExceptionが返されました") print(vars(e)) except Exception as e: print("[Error!]") print(vars(e))
SMS送信状態取得(BULK)
from karaden.config import Config from karaden.param.bulk.bulk_message_show_params import BulkMessageShowParams from karaden.model.bulk_message import BulkMessage from karaden.exception.bad_request_exception import BadRequestException from karaden.exception.bulk_message_create_failed_exception import BulkMessageCreateFailedException from karaden.exception.bulk_message_list_message_retry_limit_exceed_exception import BulkMessageListMessageRetryLimitExceedException from karaden.exception.bulk_message_show_retry_limit_exceed_exception import BulkMessageShowRetryLimitExceedException from karaden.exception.file_download_failed_exception import FileDownloadFailedException from karaden.exception.file_not_found_exception import FileNotFoundException from karaden.exception.file_upload_failed_exception import FileUploadFailedException from karaden.exception.forbidden_exception import ForbiddenException from karaden.exception.invalid_params_exception import InvalidParamsException from karaden.exception.invalid_request_options_exception import InvalidRequestOptionsException from karaden.exception.karaden_exception import KaradenException from karaden.exception.not_found_exception import NotFoundException from karaden.exception.too_many_requests_exception import TooManyRequestsException from karaden.exception.unauthorized_exception import UnauthorizedException from karaden.exception.unexpected_value_exception import UnexpectedValueException from karaden.exception.unknown_error_exception import UnknownErrorException from karaden.exception.unprocessable_entity_exception import UnprocessableEntityException Config.api_key = 'PJ-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' Config.api_version = '2024-03-01' Config.tenant_id = 'xxxxxxxxx-zzzz-yyyy-zzzz-12345678901' params = ( BulkMessageShowParams .new_builder() .with_id('<BulkID>') .build() ) request_options = Config.as_request_options() try: bulk_message = BulkMessage.show(params, request_options) print(vars(bulk_message)) if bulk_message.error != None: print("----------------") print(vars(bulk_message.error)) if bulk_message.error.errors != None: print("----------------") print(vars(bulk_message.error.errors)) print("Config.VERSION : " + Config.VERSION) except BadRequestException as e: print("BadRequestExceptionが返されました") print(vars(e)) except BulkMessageCreateFailedException as e: print("BulkMessageCreateFailedExceptionが返されました") print(vars(e)) except BulkMessageListMessageRetryLimitExceedException as e: print("BulkMessageListMessageRetryLimitExceedExceptionが返されました") print(vars(e)) except BulkMessageShowRetryLimitExceedException as e: print("BulkMessageShowRetryLimitExceedExceptionが返されました") print(vars(e)) except FileDownloadFailedException as e: print("FileDownloadFailedExceptionが返されました") print(vars(e)) except FileNotFoundException as e: print("FileNotFoundExceptionが返されました") print(vars(e)) except FileUploadFailedException as e: print("FileUploadFailedExceptionが返されました") print(vars(e)) except ForbiddenException as e: print("ForbiddenExceptionが返されました") print(vars(e)) except InvalidParamsException as e: print("InvalidParamsExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except InvalidRequestOptionsException as e: print("InvalidRequestOptionsExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except NotFoundException as e: print("NotFoundExceptionが返されました") print(vars(e)) except TooManyRequestsException as e: print("TooManyRequestsExceptionが返されました") print(vars(e)) except UnauthorizedException as e: print("UnauthorizedExceptionが返されました") print(vars(e)) except UnexpectedValueException as e: print("UnexpectedValueExceptionが返されました") print(vars(e)) except UnknownErrorException as e: print("UnknownErrorExceptionが返されました") print(vars(e)) except UnprocessableEntityException as e: print("UnprocessableEntityExceptionが返されました") error_obj = e.error error_object = error_obj.errors if(error_object): print(vars(error_object)) except KaradenException as e: print("KaradenExceptionが返されました") print(vars(e)) except Exception as e: print("[Error!]") print(vars(e))