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

SWI-5093 Adding CombinedSearchAndOrder #72

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.bandwidth.sdk</groupId>
<artifactId>bandwidth-java-iris-sdk</artifactId>
<version>4.0.0</version>
<version>4.1.1</version>
<packaging>jar</packaging>
<name>bandwidth-java-iris-sdk</name>
<description>Java SDK for use with the IRIS API.</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package com.bandwidth.iris.sdk.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "CombinedSearchAndOrderType")
@XmlAccessorType(XmlAccessType.FIELD)
public class CombinedSearchAndOrderType extends BaseOrderType {
@XmlElement(name = "AreaCode")
private String areaCode;

public String getAreaCode() {
return areaCode;
}

@XmlElement(name = "City")
private String city;

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

@XmlElement(name = "EnableLCA")
private boolean enableLCA;

public boolean isEnableLCA() {
return enableLCA;
}

public void setEnableLCA(boolean enableLCA) {
this.enableLCA = enableLCA;
}

@XmlElement(name = "EndsIn")
private boolean endsIn;

public boolean isEndsIn() {
return endsIn;
}

public void setEndsIn(boolean endsIn) {
this.endsIn = endsIn;
}

@XmlElement(name = "LATA")
private String lata;

public String getLata() {
return lata;
}

public void setLata(String lata) {
this.lata = lata;
}

@XmlElement(name = "LocalVanity")
private String localVanity;

public String getLocalVanity() {
return localVanity;
}

public void setLocalVanity(String localVanity) {
this.localVanity = localVanity;
}

@XmlElement(name = "NpaNxx")
private String npaNxx;

public String getNpaNxx() {
return npaNxx;
}

public void setNpaNxx(String npaNxx) {
this.npaNxx = npaNxx;
}

@XmlElement(name = "NpaNxxX")
private String npaNxxX;

public String getNpaNxxX() {
return npaNxxX;
}

public void setNpaNxxX(String npaNxxX) {
this.npaNxxX = npaNxxX;
}

@XmlElement(name = "Quantity")
private int quantity;

public int getQuantity() {
return quantity;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}

@XmlElement(name = "RateCenter")
private String rateCenter;

public String getRateCenter() {
return rateCenter;
}

public void setRateCenter(String rateCenter) {
this.rateCenter = rateCenter;
}

@XmlElement(name = "State")
private String state;

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

@XmlElement(name = "Zip")
private String zip;

public String getZip() {
return zip;
}

public void setZip(String zip) {
this.zip = zip;
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/bandwidth/iris/sdk/model/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class Order extends BaseModel {
private TollFreeWildCharSearchAndOrderType tollFreeWildCharSearchAndOrderType;
@XmlElement(name = "ZIPSearchAndOrderType")
private ZIPSearchAndOrderType zipSearchAndOrderType;
@XmlElement(name = "CombinedSearchAndOrderType")
private CombinedSearchAndOrderType combinedSearchAndOrderType;


public static OrderResponse create(IrisClient client, Order order) throws Exception {
OrderResponse orderResponse = client
Expand Down Expand Up @@ -208,6 +211,14 @@ public void setZipSearchAndOrderType(ZIPSearchAndOrderType zipSearchAndOrderType
this.zipSearchAndOrderType = zipSearchAndOrderType;
}

public CombinedSearchAndOrderType getCombinedSearchAndOrderType() {
return combinedSearchAndOrderType;
}

public void setCombinedSearchAndOrderType(CombinedSearchAndOrderType combinedSearchAndOrderType) {
this.combinedSearchAndOrderType = combinedSearchAndOrderType;
}

public void addNote(Note note) throws Exception {
client.put(client.buildAccountModelUri(new String[] { IrisPath.ORDERS_URI_PATH, id, "notes" }), note);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ public class IrisClientTestUtils {
* Order Xmls
*/
public static String validOrderResponseXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><OrderResponse><Order><Name>A New Order</Name><OrderCreateDate>2014-10-14T17:58:15.299Z</OrderCreateDate><BackOrderRequested>false</BackOrderRequested><id>someid</id><ExistingTelephoneNumberOrderType><TelephoneNumberList><TelephoneNumber>2052865046</TelephoneNumber></TelephoneNumberList></ExistingTelephoneNumberOrderType><PartialAllowed>false</PartialAllowed><SiteId>2858</SiteId></Order></OrderResponse>";
public static String validCombinedOrderResponseXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><OrderResponse><Order><Name>Test CombinedSearchAndOrderType Order</Name><OrderCreateDate>2014-10-14T17:58:15.299Z</OrderCreateDate><BackOrderRequested>false</BackOrderRequested><id>someid</id><CombinedSearchAndOrderType><EnableLCA>false</EnableLCA><Quantity>1</Quantity><RateCenter>DOVER</RateCenter><State>NH</State></CombinedSearchAndOrderType><PartialAllowed>false</PartialAllowed><SiteId>2858</SiteId></Order></OrderResponse>";
public static String validRateCenterOrderResponseXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><OrderResponse><Order><Name>Test RateCenterSearchAndOrderType Order</Name><OrderCreateDate>2014-10-14T17:58:15.299Z</OrderCreateDate><BackOrderRequested>false</BackOrderRequested><id>someid</id><RateCenterSearchAndOrderType><EnableLCA>false</EnableLCA><Quantity>1</Quantity><RateCenter>DOVER</RateCenter><State>NH</State></RateCenterSearchAndOrderType><PartialAllowed>false</PartialAllowed><SiteId>2858</SiteId></Order></OrderResponse>";
public static String validOrderResponseErrorXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><OrderResponse><CompletedQuantity>0</CompletedQuantity><CreatedByUser>testapi</CreatedByUser><ErrorList><Error><Code>5018</Code><Description>The entire quantity of telephone numbers ordered is unavailable</Description></Error></ErrorList><LastModifiedDate>2022-02-17T15:28:24.152Z</LastModifiedDate><OrderCompleteDate>2022-02-17T15:28:24.152Z</OrderCompleteDate><Order><id>errorid</id><CustomerOrderId>MyTestOrderId</CustomerOrderId><OrderCreateDate>2022-02-17T15:28:24.026Z</OrderCreateDate><PeerId>223787</PeerId><BackOrderRequested>false</BackOrderRequested><RateCenterSearchAndOrderType><EnableLCA>true</EnableLCA><Quantity>1</Quantity><RateCenter>DOVER</RateCenter><State>NH</State></RateCenterSearchAndOrderType><PartialAllowed>true</PartialAllowed><SiteId>56984</SiteId><TnAttributes/></Order><OrderStatus>FAILED</OrderStatus><CompletedNumbers/><Summary>1 number requested</Summary><FailedQuantity>1</FailedQuantity></OrderResponse>";
public static String validOrderNotesResponseXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Notes><Note><Id>178468</Id><UserId>user</UserId><Description>Adding a note</Description><LastDateModifier>2014-11-19T21:02:26.000Z</LastDateModifier></Note></Notes>";
Expand Down
26 changes: 26 additions & 0 deletions src/test/java/com/bandwidth/iris/sdk/OrderTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,30 @@ public void rateCenterSearchAndOrderTypeTestCreate() throws Exception {
assertEquals(createdOrder.getOrder().getRateCenterSearchAndOrderType().getRateCenter(), "DOVER");
}

@Test
public void CombinedSearchAndOrderTypeTestCreate() throws Exception {
String ordersUrl = "/v1.0/accounts/accountId/orders";
stubFor(post(urlMatching(ordersUrl))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/xml")
.withBody(IrisClientTestUtils.validCombinedOrderResponseXml)));

Order order = new Order();
order.setName("Test CombinedSearchAndOrderType Order");

CombinedSearchAndOrderType combinedSearchAndOrderType = new CombinedSearchAndOrderType();
combinedSearchAndOrderType.setEnableLCA(false);
combinedSearchAndOrderType.setQuantity(1);
combinedSearchAndOrderType.setRateCenter("DOVER"); // No inventory available here
combinedSearchAndOrderType.setState("NH");

order.setCombinedSearchAndOrderType(combinedSearchAndOrderType);

OrderResponse createdOrder = Order.create(getDefaultClient(), order);
assertEquals(createdOrder.getOrder().getName(), "Test CombinedSearchAndOrderType Order");
assertEquals(createdOrder.getOrder().getCombinedSearchAndOrderType().getRateCenter(), "DOVER");
}


}
Loading