Skip to content
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

DEVEXP- 469: SMS V1 design for batches #177

Merged
merged 19 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
569dcbd
feat (SMS): Define SMS v1
JPPortier Dec 7, 2024
fe713d4
feat (SMS/Batches): Support 'send' operation
JPPortier Dec 7, 2024
43b1f7d
feat (SMS/Batches): Support 'list' operation
JPPortier Dec 7, 2024
4a1da86
feat (SMS/Batches): Support 'dryRun' operation
JPPortier Dec 7, 2024
304b55e
feat (SMS/Batches): Support 'get' operation
JPPortier Dec 8, 2024
9cd60f4
feat (SMS/Batches): Support 'replace' operation
JPPortier Dec 9, 2024
d2d588a
feat (SMS/Batches): Support 'cancel' operation
JPPortier Dec 9, 2024
43a5214
feat (SMS/Batches): Support 'sendDeliveryFeedback' operation
JPPortier Dec 9, 2024
aa4223e
feat (SMS/Batches): Support 'update' operation
JPPortier Dec 9, 2024
7d3cce1
refactor (SMS/Batches): 'flash_message', 'truncat_concat' and 'max_nu…
JPPortier Dec 9, 2024
56ac119
refactor (SMS/Batche): Support new 'subject' field for MediaMessage
JPPortier Dec 14, 2024
858ea5e
test (SMS/Batches): Add IT and e2e tests for V1
JPPortier Dec 14, 2024
59753f2
feat (SMS/Batches): Generated files
JPPortier Dec 16, 2024
6ad8141
feat (SMS): Add guard against null SMS URL for service plan id usage
JPPortier Dec 17, 2024
21dddce
test (SMS): Use valid phone number format for unit tests
JPPortier Dec 17, 2024
b37e901
test (SMS): Refactor test filenames
JPPortier Dec 17, 2024
b7b1d79
test (SMS): Extend SMS service init unit tests coverage
JPPortier Dec 17, 2024
79fa747
refactor (SMS/Batches): Rename 'Batch' class with 'BatchResponse'
JPPortier Dec 17, 2024
0a20f75
refactor (SMS/Batches): Generated files update
JPPortier Dec 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import com.sinch.sdk.domains.sms.models.v1.batches.request.BatchRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.response.Batch;
import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse;

public interface BatchesService {

Batch send(BatchRequest batch) throws ApiException;

ListBatchesResponse list(ListBatchesRequest parameters) throws ApiException;

DryRunResponse dryRun(boolean perRecipient, int numberOfRecipient, BatchRequest batch);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.sinch.sdk.domains.sms.models.v1.batches.request.BatchRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.response.Batch;
import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.ApiBatchList;
import com.sinch.sdk.models.SmsContext;
Expand Down Expand Up @@ -58,4 +59,8 @@ public ListBatchesResponse list(ListBatchesRequest parameters) throws ApiExcepti
return new ListBatchesResponse(
this, new Page<>(guardParameters, response.getBatches(), navigator));
}

public DryRunResponse dryRun(boolean perRecipient, int numberOfRecipient, BatchRequest batch) {
return getApi().dryRun(perRecipient, numberOfRecipient, batch);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public class BatchesServiceTest extends BaseTest {
@GivenJsonResource("/domains/sms/v1/batches/response/BatchTextDto.json")
SendSMS201ResponseDto textResponseDto;

@GivenJsonResource("/domains/sms/v1/DryRunResponseDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json")
DryRun200ResponseDto dryRunResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/ListBatchesResponseDtoPage0.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@TestWithResources
public class DryRunDtoConverterTest extends BaseTest {

@GivenJsonResource("/domains/sms/v1/DryRunResponseDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json")
DryRun200ResponseDto loadedDto;

public static DryRun dryRunClient =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
@TestWithResources
class DryRunResponseDtoTest extends BaseTest {

@GivenJsonResource("/domains/sms/v1/DryRunResponseDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json")
DryRun200ResponseDto loadedDto;

@GivenTextResource("/domains/sms/v1/DryRunResponseDto.json")
@GivenTextResource("/domains/sms/v1/batches/response/DryRunResponseDto.json")
String jsonStringDto;

DryRun200ResponseDto dto =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sinch.sdk.domains.sms.models.v1.batches.response;

import com.adelean.inject.resources.junit.jupiter.GivenJsonResource;
import com.adelean.inject.resources.junit.jupiter.TestWithResources;
import com.sinch.sdk.BaseTest;
import com.sinch.sdk.core.TestHelpers;
import java.util.Collections;
import org.junit.jupiter.api.Test;

@TestWithResources
class DryRunResponseDtoTest extends BaseTest {

@GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json")
DryRunResponse loadedDto;

DryRunResponse dto =
DryRunResponse.builder()
.setNumberOfRecipients(123)
.setNumberOfMessages(456)
.setPerRecipient(
Collections.singletonList(
DryRunPerRecipientDetails.builder()
.setRecipient("recipient string")
.setNumberOfParts(1)
.setBody("body string")
.setEncoding("encoding string")
.build()))
.build();

@Test
void deserialize() {

TestHelpers.recursiveEquals(loadedDto, dto);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.sinch.sample.sms.v1.batches;

import com.sinch.sample.BaseApplication;
import com.sinch.sdk.domains.sms.api.v1.BatchesService;
import com.sinch.sdk.domains.sms.models.v1.batches.request.TextRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse;
import java.io.IOException;
import java.util.Collections;
import java.util.logging.Logger;

public class dryRun extends BaseApplication {

private static final Logger LOGGER = Logger.getLogger(dryRun.class.getName());

public dryRun() throws IOException {}

public static void main(String[] args) {
try {
new dryRun().run();
} catch (Exception e) {
LOGGER.severe(e.getMessage());
e.printStackTrace();
}
}

public void run() {

BatchesService service = client.sms().v1().batches();
LOGGER.info("DryRun Request");

DryRunResponse value =
service.dryRun(
JPPortier marked this conversation as resolved.
Show resolved Hide resolved
true,
3,
TextRequest.builder()
.setTo(Collections.singletonList(phoneNumber))
.setBody("the body")
.build());

LOGGER.info("Response: " + value);
}
}