-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SMS Inbounds & Groups
- Loading branch information
Showing
73 changed files
with
3,675 additions
and
751 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
client/src/main/com/sinch/sdk/domains/sms/GroupsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package com.sinch.sdk.domains.sms; | ||
|
||
import com.sinch.sdk.core.exceptions.ApiException; | ||
import com.sinch.sdk.domains.sms.models.Group; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupCreateRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupReplaceRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupUpdateRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupsListRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.responses.GroupsListResponse; | ||
import java.util.Collection; | ||
|
||
/** | ||
* Groups Service | ||
* | ||
* <p>A group is a set of phone numbers (or MSISDNs) that can be used as a target when sending an | ||
* SMS. An phone number (MSISDN) can only occur once in a group and any attempts to add a duplicate | ||
* are ignored but not rejected. | ||
* | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups</a> | ||
* @since 1.0 | ||
*/ | ||
public interface GroupsService { | ||
|
||
/** | ||
* Retrieve a group | ||
* | ||
* <p>This operation retrieves a specific group with the provided group ID. | ||
* | ||
* @param groupId The inbound ID found when listing inbound messages | ||
* @return Group associated to groupId | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/RetrieveGroup">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/RetrieveGroup</a> | ||
* @since 1.0 | ||
*/ | ||
Group get(String groupId) throws ApiException; | ||
|
||
/** | ||
* Create a group | ||
* | ||
* <p>A group is a set of phone numbers (MSISDNs) that can be used as a target in the <code> | ||
* send_batch_msg</code> operation. An MSISDN can only occur once in a group and any attempts to | ||
* add a duplicate would be ignored but not rejected. | ||
* | ||
* @param parameters Parameters to be used to define group onto creation | ||
* @return Created group | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/CreateGroup">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/CreateGroup</a> | ||
* @since 1.0 | ||
*/ | ||
Group create(GroupCreateRequestParameters parameters) throws ApiException; | ||
|
||
Group create() throws ApiException; | ||
|
||
/** | ||
* List Groups | ||
* | ||
* <p>With the list operation you can list all groups that you have created. This operation | ||
* supports pagination. | ||
* | ||
* <p>Groups are returned in reverse chronological order. | ||
* | ||
* @param parameters Filtering parameters | ||
* @return group list | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ListGroups">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ListGroups</a> | ||
* @since 1.0 | ||
*/ | ||
GroupsListResponse list(GroupsListRequestParameters parameters) throws ApiException; | ||
|
||
GroupsListResponse list() throws ApiException; | ||
|
||
/** | ||
* Replace a group | ||
* | ||
* <p>The replace operation will replace all parameters, including members, of an existing group | ||
* with new values. | ||
* | ||
* <p>Replacing a group targeted by a batch message scheduled in the future is allowed and changes | ||
* will be reflected when the batch is sent. | ||
* | ||
* @param groupId ID of a group that you are interested in getting. | ||
* @param parameters Parameters to be replaced for group | ||
* @return Group associated to groupId | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ReplaceGroup">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ReplaceGroup</a> | ||
* @since 1.0 | ||
*/ | ||
Group replace(String groupId, GroupReplaceRequestParameters parameters) throws ApiException; | ||
|
||
/** | ||
* Update a group | ||
* | ||
* @param groupId ID of a group that you are interested in getting. | ||
* @param parameters Parameters to be used to update group | ||
* @return Modified group associated to groupId | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/UpdateGroup">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/UpdateGroup</a> | ||
* @since 1.0 | ||
*/ | ||
Group update(String groupId, GroupUpdateRequestParameters parameters) throws ApiException; | ||
|
||
/** | ||
* Delete a group | ||
* | ||
* @param groupId ID of a group that you are interested in getting. | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/deleteGroup">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/deleteGroup</a> | ||
* @since 1.0 | ||
*/ | ||
void delete(String groupId) throws ApiException; | ||
|
||
/** | ||
* Get phone numbers for a group | ||
* | ||
* @param groupId ID of a group that you are interested in getting. | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/deleteGroup">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/deleteGroup</a> | ||
* @since 1.0 | ||
*/ | ||
Collection<String> listMembers(String groupId) throws ApiException; | ||
} |
47 changes: 47 additions & 0 deletions
47
client/src/main/com/sinch/sdk/domains/sms/InboundsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.sinch.sdk.domains.sms; | ||
|
||
import com.sinch.sdk.core.exceptions.ApiException; | ||
import com.sinch.sdk.domains.sms.models.Inbound; | ||
import com.sinch.sdk.domains.sms.models.requests.InboundsListRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.responses.InboundsListResponse; | ||
|
||
/** | ||
* Inbounds Service | ||
* | ||
* <p>Inbounds, or Mobile Originated (MO) messages, are incoming messages. Inbound messages can be | ||
* listed and retrieved like batch messages and they can also be delivered by callback requests like | ||
* delivery reports. | ||
* | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Inbounds/">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Inbounds/</a> | ||
* @since 1.0 | ||
*/ | ||
public interface InboundsService { | ||
|
||
/** | ||
* List incoming messages | ||
* | ||
* <p>With the list operation, you can list all inbound messages that you have received. This | ||
* operation supports pagination. Inbounds are returned in reverse chronological order. | ||
* | ||
* @param parameters Filtering parameters | ||
* @return Incoming messages | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports</a> | ||
* @since 1.0 | ||
*/ | ||
InboundsListResponse list(InboundsListRequestParameters parameters) throws ApiException; | ||
|
||
/** | ||
* Retrieve inbound message | ||
* | ||
* <p>This operation retrieves a specific inbound message with the provided inbound ID | ||
* | ||
* @param inboundId The inbound ID found when listing inbound messages | ||
* @return Inbound messages- | ||
* @see <a | ||
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Inbounds/#tag/Inbounds/operation/RetrieveInboundMessage">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Inbounds/#tag/Inbounds/operation/RetrieveInboundMessage</a> | ||
* @since 1.0 | ||
*/ | ||
Inbound<?> get(String inboundId) throws ApiException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
client/src/main/com/sinch/sdk/domains/sms/adapters/GroupsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.sinch.sdk.domains.sms.adapters; | ||
|
||
import com.sinch.sdk.core.exceptions.ApiException; | ||
import com.sinch.sdk.core.http.HttpClient; | ||
import com.sinch.sdk.core.http.HttpMapper; | ||
import com.sinch.sdk.core.models.pagination.Page; | ||
import com.sinch.sdk.core.models.pagination.PageToken; | ||
import com.sinch.sdk.core.utils.Pair; | ||
import com.sinch.sdk.domains.sms.adapters.api.v1.GroupsApi; | ||
import com.sinch.sdk.domains.sms.adapters.converters.GroupsDtoConverter; | ||
import com.sinch.sdk.domains.sms.models.Group; | ||
import com.sinch.sdk.domains.sms.models.dto.v1.ApiGroupListDto; | ||
import com.sinch.sdk.domains.sms.models.dto.v1.CreateGroupResponseDto; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupCreateRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupReplaceRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupUpdateRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.requests.GroupsListRequestParameters; | ||
import com.sinch.sdk.domains.sms.models.responses.GroupsListResponse; | ||
import com.sinch.sdk.models.Configuration; | ||
import java.util.Collection; | ||
|
||
public class GroupsService implements com.sinch.sdk.domains.sms.GroupsService { | ||
|
||
private Configuration configuration; | ||
private GroupsApi api; | ||
|
||
public GroupsService() {} | ||
|
||
private GroupsApi getApi() { | ||
return this.api; | ||
} | ||
|
||
public GroupsService(Configuration configuration, HttpClient httpClient) { | ||
this.configuration = configuration; | ||
this.api = new GroupsApi(httpClient, configuration.getSmsServer(), new HttpMapper()); | ||
} | ||
|
||
public Group get(String groupId) throws ApiException { | ||
|
||
CreateGroupResponseDto response = getApi().retrieveGroup(configuration.getProjectId(), groupId); | ||
return GroupsDtoConverter.convert(response); | ||
} | ||
|
||
public Group create() throws ApiException { | ||
return this.create(null); | ||
} | ||
|
||
public Group create(GroupCreateRequestParameters parameters) throws ApiException { | ||
GroupCreateRequestParameters guardParameters = | ||
null != parameters ? parameters : GroupCreateRequestParameters.builder().build(); | ||
|
||
CreateGroupResponseDto response = | ||
getApi() | ||
.createGroup(configuration.getProjectId(), GroupsDtoConverter.convert(guardParameters)); | ||
return GroupsDtoConverter.convert(response); | ||
} | ||
|
||
public GroupsListResponse list() throws ApiException { | ||
return this.list(null); | ||
} | ||
|
||
public GroupsListResponse list(GroupsListRequestParameters parameters) throws ApiException { | ||
GroupsListRequestParameters guardParameters = | ||
null != parameters ? parameters : GroupsListRequestParameters.builder().build(); | ||
|
||
ApiGroupListDto response = | ||
getApi() | ||
.listGroups( | ||
configuration.getProjectId(), | ||
guardParameters.getPage().orElse(null), | ||
guardParameters.getPageSize().orElse(null)); | ||
|
||
Pair<Collection<Group>, PageToken<Integer>> content = GroupsDtoConverter.convert(response); | ||
|
||
return new GroupsListResponse( | ||
this, new Page<>(guardParameters, content.getLeft(), content.getRight())); | ||
} | ||
|
||
public Group replace(String groupId, GroupReplaceRequestParameters parameters) | ||
throws ApiException { | ||
GroupReplaceRequestParameters guardParameters = | ||
null != parameters ? parameters : GroupReplaceRequestParameters.builder().build(); | ||
|
||
CreateGroupResponseDto response = | ||
getApi() | ||
.replaceGroup( | ||
configuration.getProjectId(), groupId, GroupsDtoConverter.convert(guardParameters)); | ||
return GroupsDtoConverter.convert(response); | ||
} | ||
|
||
public Group update(String groupId, GroupUpdateRequestParameters parameters) throws ApiException { | ||
GroupUpdateRequestParameters guardParameters = | ||
null != parameters ? parameters : GroupUpdateRequestParameters.builder().build(); | ||
|
||
CreateGroupResponseDto response = | ||
getApi() | ||
.updateGroup( | ||
configuration.getProjectId(), groupId, GroupsDtoConverter.convert(guardParameters)); | ||
return GroupsDtoConverter.convert(response); | ||
} | ||
|
||
public void delete(String groupId) throws ApiException { | ||
getApi().deleteGroup(configuration.getProjectId(), groupId); | ||
} | ||
|
||
public Collection<String> listMembers(String groupId) throws ApiException { | ||
return getApi().getMembers(configuration.getProjectId(), groupId); | ||
} | ||
} |
Oops, something went wrong.