-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the ability to get and create opt out resources. Includes some changes and improvements to the existing tests to increase coverage for regression protection. Usage: * Create an instance of the optout service ```java UserPassword userPassword = new UserPassword("YourUsername","YourPassword"); BasicServiceFactory serviceFactory = ServiceFactory.createBasicAuthenticatingFactory(userPassword); OptOutService optOutService = serviceFactory.getOptOutService(); ``` * Get single opt out ```java OptOutResponse optout = optOutService.getOptOut("b6a39581-9cfc-40ea-9b40-9320444cf49d"); ``` * Get paged opt outs ```java OptOutCollectionResponse optouts = optOutService.getOptOuts(1, 15); ``` * Create an opt out ```java FromAddress fromAddress = new FromAddress(); fromAddress.setPhoneNumber("99887744556322"); OptOutRequest request = new OptOutRequestImpl(); request.setAccountReference("EX006789"); request.setFromAddress(fromAddress); OptOutResponse optout = optOutService.createOptOut(request); ```
- Loading branch information
1 parent
88e5187
commit f21b739
Showing
51 changed files
with
1,989 additions
and
464 deletions.
There are no files selected for viewing
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,10 @@ | ||
Esendex Java SDK | ||
================ | ||
|
||
[![Build Status](https://travis-ci.org/esendex/esendex-java-sdk.svg?branch=master)](https://travis-ci.org/esendex/esendex-java-sdk) | ||
|
||
The Esendex Java SDK is an easy to use client for the Esendex REST API which you can use to integrate SMS and Voice messaging into any application built with the JVM. | ||
|
||
It contains a set of services for sending SMS and Voice messages, receiving SMS, tracking the status of your sent messages and more. | ||
|
||
Full details at http://developers.esendex.com/SDKs/Java-SDK |
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
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
10 changes: 10 additions & 0 deletions
10
src/main/java/esendex/sdk/java/model/domain/impl/FromAddress.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,10 @@ | ||
package esendex.sdk.java.model.domain.impl; | ||
|
||
public class FromAddress { | ||
|
||
private String phoneNumber; | ||
|
||
public String getPhoneNumber() { return phoneNumber; } | ||
|
||
public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/esendex/sdk/java/model/domain/impl/OptOutCollectionResponseImpl.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,30 @@ | ||
package esendex.sdk.java.model.domain.impl; | ||
|
||
import esendex.sdk.java.model.domain.response.OptOutCollectionResponse; | ||
import esendex.sdk.java.model.domain.response.OptOutResponse; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class OptOutCollectionResponseImpl extends PageableImpl implements OptOutCollectionResponse { | ||
|
||
private List<OptOutResponse> optouts; | ||
|
||
public OptOutCollectionResponseImpl(List<OptOutResponse> optouts) { | ||
this.optouts = optouts; | ||
} | ||
|
||
public List<OptOutResponse> getOptOuts() { | ||
return optouts; | ||
} | ||
|
||
public void setOptouts(List<OptOutResponse> optouts) { | ||
this.optouts = optouts; | ||
} | ||
|
||
@Override | ||
public Iterator<OptOutResponse> iterator() { | ||
return null; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/esendex/sdk/java/model/domain/impl/OptOutRequestAssembler.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,21 @@ | ||
package esendex.sdk.java.model.domain.impl; | ||
|
||
import esendex.sdk.java.model.domain.request.OptOutRequest; | ||
import esendex.sdk.java.model.transfer.optout.FromAddressDto; | ||
import esendex.sdk.java.model.transfer.optout.OptOutRequestDto; | ||
|
||
public class OptOutRequestAssembler { | ||
|
||
public OptOutRequestDto createOptOutDto(OptOutRequest optOutRequest) { | ||
|
||
OptOutRequestDto dto = new OptOutRequestDto(); | ||
|
||
FromAddressDto fromAddress = new FromAddressDto(); | ||
fromAddress.setPhoneNumber(optOutRequest.getFromAddress().getPhoneNumber()); | ||
|
||
dto.setFromAddress(fromAddress); | ||
dto.setAccountReference(optOutRequest.getAccountReference()); | ||
|
||
return dto; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/esendex/sdk/java/model/domain/impl/OptOutRequestImpl.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,28 @@ | ||
package esendex.sdk.java.model.domain.impl; | ||
|
||
import esendex.sdk.java.model.domain.request.OptOutRequest; | ||
|
||
public class OptOutRequestImpl implements OptOutRequest { | ||
private String accountReference; | ||
private FromAddress fromAddress; | ||
|
||
@Override | ||
public String getAccountReference() { | ||
return accountReference; | ||
} | ||
|
||
@Override | ||
public void setAccountReference(String accountReference) { | ||
this.accountReference = accountReference; | ||
} | ||
|
||
@Override | ||
public FromAddress getFromAddress() { | ||
return fromAddress; | ||
} | ||
|
||
@Override | ||
public void setFromAddress(FromAddress fromAddress) { | ||
this.fromAddress = fromAddress; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/esendex/sdk/java/model/domain/impl/OptOutResponseAssembler.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,44 @@ | ||
package esendex.sdk.java.model.domain.impl; | ||
|
||
import esendex.sdk.java.model.domain.response.OptOutCollectionResponse; | ||
import esendex.sdk.java.model.domain.response.OptOutResponse; | ||
import esendex.sdk.java.model.transfer.optout.OptOutCollectionResponseDto; | ||
import esendex.sdk.java.model.transfer.optout.OptOutResponseDto; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class OptOutResponseAssembler { | ||
|
||
public OptOutResponse createResponse(OptOutResponseDto dto) { | ||
|
||
OptOutResponseImpl response = new OptOutResponseImpl(); | ||
|
||
response.setId(dto.getId()); | ||
response.setAccountReference(dto.getAccountReference()); | ||
response.setReceivedAt(dto.getReceivedAt()); | ||
|
||
FromAddress from = new FromAddress(); | ||
from.setPhoneNumber(dto.getFrom().getPhoneNumber()); | ||
response.setFrom(from); | ||
|
||
return response; | ||
} | ||
|
||
public OptOutCollectionResponse createCollectionResponse(OptOutCollectionResponseDto col) { | ||
|
||
List<OptOutResponse> optouts = new ArrayList<>(); | ||
if (col.getOptouts() != null) { | ||
for (OptOutResponseDto dto : col.getOptouts()) { | ||
optouts.add(this.createResponse(dto)); | ||
} | ||
} | ||
|
||
OptOutCollectionResponseImpl response = new OptOutCollectionResponseImpl(optouts); | ||
response.setCount(col.getCount()); | ||
response.setStartIndex(col.getStartindex()); | ||
response.setTotalCount(col.getTotalcount()); | ||
|
||
return response; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/esendex/sdk/java/model/domain/impl/OptOutResponseImpl.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,37 @@ | ||
package esendex.sdk.java.model.domain.impl; | ||
|
||
import esendex.sdk.java.model.domain.response.OptOutResponse; | ||
|
||
import java.util.Date; | ||
|
||
public class OptOutResponseImpl implements OptOutResponse { | ||
|
||
private String id; | ||
private Date receivedAt; | ||
private String accountReference; | ||
private FromAddress from; | ||
|
||
public OptOutResponseImpl() { } | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Date getReceivedAt() { return receivedAt; } | ||
|
||
public String getAccountReference() { return accountReference; } | ||
|
||
public FromAddress getFrom() { return from; } | ||
|
||
void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
void setReceivedAt(Date receivedAt) { | ||
this.receivedAt = receivedAt; | ||
} | ||
|
||
void setAccountReference(String accountReference) { this.accountReference = accountReference; } | ||
|
||
void setFrom(FromAddress from) { this.from = from; } | ||
} |
Oops, something went wrong.