-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a080c4d
commit 85e97ae
Showing
1 changed file
with
51 additions
and
43 deletions.
There are no files selected for viewing
94 changes: 51 additions & 43 deletions
94
...parent/core/src/main/java/com/atg/openssp/core/exchange/channel/rtb/OpenRtbConnector.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 |
---|---|---|
@@ -1,43 +1,51 @@ | ||
package com.atg.openssp.core.exchange.channel.rtb; | ||
|
||
import org.apache.http.Header; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.entity.ContentType; | ||
import org.apache.http.entity.StringEntity; | ||
|
||
import com.atg.openssp.common.core.connector.JsonPostConnector; | ||
import com.atg.openssp.common.exception.BidProcessingException; | ||
|
||
/** | ||
* A wrapper to a concrete connector using JSON notation and post method. | ||
* | ||
* @author André Schmer | ||
* | ||
*/ | ||
public class OpenRtbConnector { | ||
|
||
private final JsonPostConnector jsonPostConnector; | ||
|
||
private final String endpoint; | ||
|
||
public OpenRtbConnector(final String endpoint) { | ||
this.endpoint = endpoint; | ||
jsonPostConnector = new JsonPostConnector(); | ||
} | ||
|
||
/** | ||
* Prepares the post transport. | ||
* | ||
* @param bidrequest | ||
* the request to send | ||
* @param header | ||
* to fill in connection header | ||
* @return the body result from the response | ||
* @throws BidProcessingException | ||
*/ | ||
String connect(final String bidrequest, final Header[] header) throws BidProcessingException { | ||
final HttpPost httpPost = new HttpPost(endpoint); | ||
httpPost.setHeaders(header); | ||
return jsonPostConnector.connect(new StringEntity(bidrequest, ContentType.APPLICATION_JSON), httpPost); | ||
} | ||
} | ||
package com.atg.openssp.core.exchange.channel.rtb; | ||
|
||
import org.apache.http.Header; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.entity.ContentType; | ||
import org.apache.http.entity.StringEntity; | ||
|
||
import com.atg.openssp.common.core.connector.JsonPostConnector; | ||
import com.atg.openssp.common.demand.Supplier; | ||
import com.atg.openssp.common.exception.BidProcessingException; | ||
|
||
/** | ||
* A wrapper to a concrete connector using JSON notation and post method. | ||
* | ||
* @author André Schmer | ||
* | ||
*/ | ||
public class OpenRtbConnector { | ||
|
||
private final JsonPostConnector jsonPostConnector; | ||
|
||
private final String endpoint; | ||
|
||
private final Supplier supplier; | ||
|
||
public OpenRtbConnector(final Supplier supplier) { | ||
this.supplier = supplier; | ||
endpoint = supplier.getEndPoint(); | ||
jsonPostConnector = new JsonPostConnector(); | ||
} | ||
|
||
/** | ||
* Prepares the post transport. | ||
* | ||
* @param bidrequest | ||
* the request to send | ||
* @param header | ||
* to fill in connection header | ||
* @return the body result from the response | ||
* @throws BidProcessingException | ||
*/ | ||
String connect(final String bidrequest, final Header[] header) throws BidProcessingException { | ||
final HttpPost httpPost = new HttpPost(endpoint); | ||
httpPost.setHeaders(header); | ||
return jsonPostConnector.connect(new StringEntity(bidrequest, ContentType.APPLICATION_JSON), httpPost); | ||
} | ||
|
||
public Supplier getSupplier() { | ||
return supplier; | ||
} | ||
} |