-
Notifications
You must be signed in to change notification settings - Fork 20
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
adaa85e
commit 9153c12
Showing
13 changed files
with
2,074 additions
and
2,095 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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
* or contact us @ [email protected]. | ||
*/ | ||
|
||
|
||
package com.infobip.api; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
|
@@ -16,7 +15,6 @@ | |
import com.infobip.model.FormsResponseContent; | ||
import com.infobip.model.FormsStatus; | ||
import com.infobip.model.FormsStatusResponse; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
|
@@ -38,8 +36,8 @@ public FormsApi(ApiClient apiClient) { | |
|
||
private RequestDefinition getFormDefinition(String id) { | ||
RequestDefinition.Builder builder = RequestDefinition.builder("GET", "/forms/1/forms/{id}") | ||
.requiresAuthentication(true) | ||
.accept("application/json"); | ||
.requiresAuthentication(true) | ||
.accept("application/json"); | ||
|
||
if (id != null) { | ||
builder.addPathParameter(new Parameter("id", id)); | ||
|
@@ -57,7 +55,6 @@ private GetFormRequest(String id) { | |
this.id = Objects.requireNonNull(id, "The required parameter 'id' is missing."); | ||
} | ||
|
||
|
||
/** | ||
* Executes the getForm request. | ||
* | ||
|
@@ -66,7 +63,7 @@ private GetFormRequest(String id) { | |
*/ | ||
public FormsResponseContent execute() throws ApiException { | ||
RequestDefinition getFormDefinition = getFormDefinition(id); | ||
return apiClient.execute(getFormDefinition, new TypeReference<FormsResponseContent>(){}.getType()); | ||
return apiClient.execute(getFormDefinition, new TypeReference<FormsResponseContent>() {}.getType()); | ||
} | ||
|
||
/** | ||
|
@@ -77,25 +74,28 @@ public FormsResponseContent execute() throws ApiException { | |
*/ | ||
public okhttp3.Call executeAsync(ApiCallback<FormsResponseContent> callback) { | ||
RequestDefinition getFormDefinition = getFormDefinition(id); | ||
return apiClient.executeAsync(getFormDefinition, new TypeReference<FormsResponseContent>(){}.getType(), callback); | ||
return apiClient.executeAsync( | ||
getFormDefinition, new TypeReference<FormsResponseContent>() {}.getType(), callback); | ||
} | ||
} | ||
|
||
/** | ||
* Get form. | ||
* <p> | ||
* Use this method to get a form by its ID. | ||
* | ||
* | ||
* @param id ID of a form (required) | ||
* @return GetFormRequest | ||
*/ | ||
public GetFormRequest getForm(String id) { | ||
return new GetFormRequest(id); | ||
} | ||
private RequestDefinition getFormsDefinition(Integer offset, Integer limit, String formType, FormsStatus formStatus) { | ||
|
||
private RequestDefinition getFormsDefinition( | ||
Integer offset, Integer limit, String formType, FormsStatus formStatus) { | ||
RequestDefinition.Builder builder = RequestDefinition.builder("GET", "/forms/1/forms") | ||
.requiresAuthentication(true) | ||
.accept("application/json"); | ||
.requiresAuthentication(true) | ||
.accept("application/json"); | ||
|
||
if (offset != null) { | ||
builder.addQueryParameter(new Parameter("offset", offset)); | ||
|
@@ -121,8 +121,7 @@ public class GetFormsRequest { | |
private String formType; | ||
private FormsStatus formStatus; | ||
|
||
private GetFormsRequest() { | ||
} | ||
private GetFormsRequest() {} | ||
|
||
/** | ||
* Sets offset. | ||
|
@@ -168,7 +167,6 @@ public GetFormsRequest formStatus(FormsStatus formStatus) { | |
return this; | ||
} | ||
|
||
|
||
/** | ||
* Executes the getForms request. | ||
* | ||
|
@@ -177,7 +175,7 @@ public GetFormsRequest formStatus(FormsStatus formStatus) { | |
*/ | ||
public FormsResponse execute() throws ApiException { | ||
RequestDefinition getFormsDefinition = getFormsDefinition(offset, limit, formType, formStatus); | ||
return apiClient.execute(getFormsDefinition, new TypeReference<FormsResponse>(){}.getType()); | ||
return apiClient.execute(getFormsDefinition, new TypeReference<FormsResponse>() {}.getType()); | ||
} | ||
|
||
/** | ||
|
@@ -188,24 +186,26 @@ public FormsResponse execute() throws ApiException { | |
*/ | ||
public okhttp3.Call executeAsync(ApiCallback<FormsResponse> callback) { | ||
RequestDefinition getFormsDefinition = getFormsDefinition(offset, limit, formType, formStatus); | ||
return apiClient.executeAsync(getFormsDefinition, new TypeReference<FormsResponse>(){}.getType(), callback); | ||
return apiClient.executeAsync( | ||
getFormsDefinition, new TypeReference<FormsResponse>() {}.getType(), callback); | ||
} | ||
} | ||
|
||
/** | ||
* Get forms. | ||
* <p> | ||
* Use this method to get a list of forms. | ||
* | ||
* | ||
* @return GetFormsRequest | ||
*/ | ||
public GetFormsRequest getForms() { | ||
return new GetFormsRequest(); | ||
} | ||
|
||
private RequestDefinition incrementViewCountDefinition(String id) { | ||
RequestDefinition.Builder builder = RequestDefinition.builder("POST", "/forms/1/forms/{id}/views") | ||
.requiresAuthentication(true) | ||
.accept("application/json"); | ||
.requiresAuthentication(true) | ||
.accept("application/json"); | ||
|
||
if (id != null) { | ||
builder.addPathParameter(new Parameter("id", id)); | ||
|
@@ -223,7 +223,6 @@ private IncrementViewCountRequest(String id) { | |
this.id = Objects.requireNonNull(id, "The required parameter 'id' is missing."); | ||
} | ||
|
||
|
||
/** | ||
* Executes the incrementViewCount request. | ||
* | ||
|
@@ -232,7 +231,8 @@ private IncrementViewCountRequest(String id) { | |
*/ | ||
public FormsStatusResponse execute() throws ApiException { | ||
RequestDefinition incrementViewCountDefinition = incrementViewCountDefinition(id); | ||
return apiClient.execute(incrementViewCountDefinition, new TypeReference<FormsStatusResponse>(){}.getType()); | ||
return apiClient.execute( | ||
incrementViewCountDefinition, new TypeReference<FormsStatusResponse>() {}.getType()); | ||
} | ||
|
||
/** | ||
|
@@ -243,27 +243,30 @@ public FormsStatusResponse execute() throws ApiException { | |
*/ | ||
public okhttp3.Call executeAsync(ApiCallback<FormsStatusResponse> callback) { | ||
RequestDefinition incrementViewCountDefinition = incrementViewCountDefinition(id); | ||
return apiClient.executeAsync(incrementViewCountDefinition, new TypeReference<FormsStatusResponse>(){}.getType(), callback); | ||
return apiClient.executeAsync( | ||
incrementViewCountDefinition, new TypeReference<FormsStatusResponse>() {}.getType(), callback); | ||
} | ||
} | ||
|
||
/** | ||
* Increment form view count. | ||
* <p> | ||
* Use this method to increase the view counter of a specific form. It's used for proper statistics calculation. Statistics are available on the form performance page on the Portal. | ||
* | ||
* | ||
* @param id ID of a form (required) | ||
* @return IncrementViewCountRequest | ||
*/ | ||
public IncrementViewCountRequest incrementViewCount(String id) { | ||
return new IncrementViewCountRequest(id); | ||
} | ||
private RequestDefinition submitFormDataDefinition(String id, Map<String, Object> requestBody, String ibSubmissionSource, String ibSubmissionFormCampaign) { | ||
|
||
private RequestDefinition submitFormDataDefinition( | ||
String id, Map<String, Object> requestBody, String ibSubmissionSource, String ibSubmissionFormCampaign) { | ||
RequestDefinition.Builder builder = RequestDefinition.builder("POST", "/forms/1/forms/{id}/data") | ||
.body(requestBody) | ||
.requiresAuthentication(true) | ||
.accept("application/json") | ||
.contentType("application/json"); | ||
.body(requestBody) | ||
.requiresAuthentication(true) | ||
.accept("application/json") | ||
.contentType("application/json"); | ||
|
||
if (id != null) { | ||
builder.addPathParameter(new Parameter("id", id)); | ||
|
@@ -313,16 +316,16 @@ public SubmitFormDataRequest ibSubmissionFormCampaign(String ibSubmissionFormCam | |
return this; | ||
} | ||
|
||
|
||
/** | ||
* Executes the submitFormData request. | ||
* | ||
* @return FormsStatusResponse The deserialized response. | ||
* @throws ApiException If the API call fails or an error occurs during the request or response processing. | ||
*/ | ||
public FormsStatusResponse execute() throws ApiException { | ||
RequestDefinition submitFormDataDefinition = submitFormDataDefinition(id, requestBody, ibSubmissionSource, ibSubmissionFormCampaign); | ||
return apiClient.execute(submitFormDataDefinition, new TypeReference<FormsStatusResponse>(){}.getType()); | ||
RequestDefinition submitFormDataDefinition = | ||
submitFormDataDefinition(id, requestBody, ibSubmissionSource, ibSubmissionFormCampaign); | ||
return apiClient.execute(submitFormDataDefinition, new TypeReference<FormsStatusResponse>() {}.getType()); | ||
} | ||
|
||
/** | ||
|
@@ -332,16 +335,18 @@ public FormsStatusResponse execute() throws ApiException { | |
* @return The {@link okhttp3.Call} associated with the API request. | ||
*/ | ||
public okhttp3.Call executeAsync(ApiCallback<FormsStatusResponse> callback) { | ||
RequestDefinition submitFormDataDefinition = submitFormDataDefinition(id, requestBody, ibSubmissionSource, ibSubmissionFormCampaign); | ||
return apiClient.executeAsync(submitFormDataDefinition, new TypeReference<FormsStatusResponse>(){}.getType(), callback); | ||
RequestDefinition submitFormDataDefinition = | ||
submitFormDataDefinition(id, requestBody, ibSubmissionSource, ibSubmissionFormCampaign); | ||
return apiClient.executeAsync( | ||
submitFormDataDefinition, new TypeReference<FormsStatusResponse>() {}.getType(), callback); | ||
} | ||
} | ||
|
||
/** | ||
* Submit form data. | ||
* <p> | ||
* Use this method to submit form data. | ||
* | ||
* | ||
* @param id ID of a form (required) | ||
* @param requestBody Form Data (required) | ||
* @return SubmitFormDataRequest | ||
|
Oops, something went wrong.