Skip to content

Commit

Permalink
refactor: Align SDK function name from 'voice.updateNumbers()' to 'vo…
Browse files Browse the repository at this point in the history
…ice.assignNumbers()' (for 'updateNumbers' OAS operation)
  • Loading branch information
JPPortier committed Feb 16, 2024
1 parent 567e06f commit cd5263d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.sinch.sdk.domains.voice.models.CallbackUrls;
import com.sinch.sdk.domains.voice.models.NumberInformation;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsUpdateNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.response.AssignedNumbers;
import com.sinch.sdk.models.E164PhoneNumber;

Expand Down Expand Up @@ -42,7 +42,7 @@ public interface ApplicationsService {
* @param parameters Request parameters
* @since 1.0
*/
void updateNumbers(ApplicationsUpdateNumbersRequestParameters parameters);
void assignNumbers(ApplicationsAssignNumbersRequestParameters parameters);

/**
* Un-assign a number from an application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.sinch.sdk.domains.voice.adapters.converters.ApplicationsDtoConverter;
import com.sinch.sdk.domains.voice.models.CallbackUrls;
import com.sinch.sdk.domains.voice.models.NumberInformation;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsUpdateNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.response.AssignedNumbers;
import com.sinch.sdk.models.Configuration;
import com.sinch.sdk.models.E164PhoneNumber;
Expand Down Expand Up @@ -51,7 +51,7 @@ public NumberInformation queryNumber(E164PhoneNumber number) {
return ApplicationsDtoConverter.convert(getApi().callingQueryNumber(number.stringValue()));
}

public void updateNumbers(ApplicationsUpdateNumbersRequestParameters parameters) {
public void assignNumbers(ApplicationsAssignNumbersRequestParameters parameters) {
getApi().configurationUpdateNumbers(ApplicationsDtoConverter.convert(parameters));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.sinch.sdk.domains.voice.models.dto.v1.GetQueryNumberNumberDto;
import com.sinch.sdk.domains.voice.models.dto.v1.UnassignNumbersDto;
import com.sinch.sdk.domains.voice.models.dto.v1.UpdateNumbersDto;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsUpdateNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.response.AssignedNumbers;
import com.sinch.sdk.models.E164PhoneNumber;
import java.util.List;
Expand Down Expand Up @@ -69,7 +69,7 @@ public static NumberInformation convert(GetQueryNumberDto dto) {
.build();
}

public static UpdateNumbersDto convert(ApplicationsUpdateNumbersRequestParameters client) {
public static UpdateNumbersDto convert(ApplicationsAssignNumbersRequestParameters client) {
if (null == client) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
*
* @since 1.0
*/
public class ApplicationsUpdateNumbersRequestParameters {
public class ApplicationsAssignNumbersRequestParameters {

private final OptionalValue<Collection<E164PhoneNumber>> numbers;
private final OptionalValue<String> applicationKey;
private final OptionalValue<CapabilityType> capability;

private ApplicationsUpdateNumbersRequestParameters(
private ApplicationsAssignNumbersRequestParameters(
OptionalValue<Collection<E164PhoneNumber>> numbers,
OptionalValue<String> applicationKey,
OptionalValue<CapabilityType> capability) {
Expand Down Expand Up @@ -60,7 +60,7 @@ public OptionalValue<CapabilityType> getCapability() {

@Override
public String toString() {
return "ApplicationsUpdateNumbersRequestParameters{"
return "ApplicationsAssignNumbersRequestParameters{"
+ "numbers="
+ numbers
+ ", applicationKey='"
Expand Down Expand Up @@ -126,8 +126,8 @@ public Builder setCapability(CapabilityType capability) {
return this;
}

public ApplicationsUpdateNumbersRequestParameters build() {
return new ApplicationsUpdateNumbersRequestParameters(numbers, applicationKey, capability);
public ApplicationsAssignNumbersRequestParameters build() {
return new ApplicationsAssignNumbersRequestParameters(numbers, applicationKey, capability);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ void updateCallbackUrls() {

@Test
void updateNumbers() {
service.updateNumbers(
ApplicationsDtoConverterTest.expectedApplicationsUpdateNumbersRequestParameters);
service.assignNumbers(
ApplicationsDtoConverterTest.expectedApplicationsAssignNumbersRequestParameters);

verify(api).configurationUpdateNumbers(updateNumbersDtoCaptor.capture());

UpdateNumbersDto body = updateNumbersDtoCaptor.getValue();
Assertions.assertThat(body)
.isEqualTo(
ApplicationsDtoConverter.convert(
ApplicationsDtoConverterTest.expectedApplicationsUpdateNumbersRequestParameters));
ApplicationsDtoConverterTest.expectedApplicationsAssignNumbersRequestParameters));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.sinch.sdk.domains.voice.models.dto.v1.ApplicationsQueryNumberResponseDtoTest;
import com.sinch.sdk.domains.voice.models.dto.v1.ApplicationsUnassignNumberRequestDtoTest;
import com.sinch.sdk.domains.voice.models.dto.v1.ApplicationsUpdateNumberRequestDtoTest;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsUpdateNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.response.AssignedNumbers;
import com.sinch.sdk.models.E164PhoneNumber;
import java.util.Arrays;
Expand Down Expand Up @@ -58,9 +58,9 @@ public class ApplicationsDtoConverterTest extends BaseTest {
.setRate(Price.builder().setCurrencyId("USD").setAmount(0.1850F).build())
.build();

public static ApplicationsUpdateNumbersRequestParameters
expectedApplicationsUpdateNumbersRequestParameters =
ApplicationsUpdateNumbersRequestParameters.builder()
public static ApplicationsAssignNumbersRequestParameters
expectedApplicationsAssignNumbersRequestParameters =
ApplicationsAssignNumbersRequestParameters.builder()
.setNumbers(Collections.singletonList(E164PhoneNumber.valueOf("+12073091712")))
.setApplicationKey("an app key")
.setCapability(CapabilityType.VOICE)
Expand Down Expand Up @@ -100,7 +100,7 @@ void convertGetQueryNumberDto() {
@Test
void convertApplicationsUpdateNumberRequestParameters() {
Assertions.assertThat(
ApplicationsDtoConverter.convert(expectedApplicationsUpdateNumbersRequestParameters))
ApplicationsDtoConverter.convert(expectedApplicationsAssignNumbersRequestParameters))
.usingRecursiveComparison()
.isEqualTo(ApplicationsUpdateNumberRequestDtoTest.updateNumbersDto);
}
Expand Down
2 changes: 1 addition & 1 deletion sample-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ See https://developers.sinch.com for details about these parameters
| | QueryNumber | [com.sinch.sample.voice.applications.QueryNumber](src/main/java/com/sinch/sample/voice/applications/QueryNumber.java) | Require `PHONE_NUMBER` parameter |
| | UnassignNumber | [com.sinch.sample.voice.applications.UnassignNumber](src/main/java/com/sinch/sample/voice/applications/UnassignNumber.java) | Require `APPLICATION_API_KEY` & `PHONE_NUMBER` parameters |
| | UpdateCallbackUrls | [com.sinch.sample.voice.applications.UpdateCallbackUrls](src/main/java/com/sinch/sample/voice/applications/UpdateCallbackUrls.java) | Require `APPLICATION_API_KEY` parameter |
| | UpdateNumbers | [com.sinch.sample.voice.applications.UpdateNumbers](src/main/java/com/sinch/sample/voice/applications/UpdateNumbers.java) | Require `APPLICATION_API_KEY` & `PHONE_NUMBER` parameters |
| | AssignNumbers | [com.sinch.sample.voice.applications.AssignNumbers](src/main/java/com/sinch/sample/voice/applications/AssignNumbers.java) | Require `APPLICATION_API_KEY` & `PHONE_NUMBER` parameters |
### Dedicated webhooks feature samples
#### How to run webhooks sample application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

import com.sinch.sample.BaseApplication;
import com.sinch.sdk.domains.voice.models.CapabilityType;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsUpdateNumbersRequestParameters;
import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters;
import com.sinch.sdk.models.E164PhoneNumber;
import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;

public class UpdateNumbers extends BaseApplication {
public class AssignNumbers extends BaseApplication {

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

public UpdateNumbers() throws IOException {}
public AssignNumbers() throws IOException {}

public static void main(String[] args) {
try {
new UpdateNumbers().run();
new AssignNumbers().run();
} catch (Exception e) {
LOGGER.severe(e.getMessage());
e.printStackTrace();
Expand All @@ -30,8 +30,8 @@ public void run() {
client
.voice()
.applications()
.updateNumbers(
ApplicationsUpdateNumbersRequestParameters.builder()
.assignNumbers(
ApplicationsAssignNumbersRequestParameters.builder()
.setNumbers(List.of(E164PhoneNumber.valueOf(phoneNumber)))
.setApplicationKey(applicationKey)
.setCapability(CapabilityType.VOICE)
Expand Down

0 comments on commit cd5263d

Please sign in to comment.