Skip to content

Commit 840ee4e

Browse files
committed
Added Attributes / Documents Request Builders
1 parent 2cc696c commit 840ee4e

2 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (c) 2018 - 2020 FormKiQ
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.formkiq.testutils.aws;
25+
26+
import com.formkiq.client.api.AttributesApi;
27+
import com.formkiq.client.invoker.ApiClient;
28+
import com.formkiq.client.invoker.ApiException;
29+
import com.formkiq.client.model.AddAttribute;
30+
import com.formkiq.client.model.AddAttributeRequest;
31+
import com.formkiq.client.model.AddResponse;
32+
import com.formkiq.client.model.AttributeDataType;
33+
import com.formkiq.client.model.AttributeType;
34+
import com.formkiq.client.model.Watermark;
35+
36+
/**
37+
* Attribute Request Builder.
38+
*/
39+
public class AttributesRequestBuilder {
40+
41+
/**
42+
* Add Entity Type, skip if already exists.
43+
*
44+
* @param client {@link ApiClient}
45+
* @param siteId {@link String}
46+
* @param attributeKey {@link String}
47+
* @param watermarkText {@link String}
48+
* @return {@link String}
49+
* @throws ApiException ApiException
50+
*/
51+
public static AddResponse addAttributeWatermark(final ApiClient client, final String siteId,
52+
final String attributeKey, final String watermarkText) throws ApiException {
53+
54+
AttributesApi api = new AttributesApi(client);
55+
Watermark watermark = new Watermark().text(watermarkText);
56+
AddAttributeRequest req = new AddAttributeRequest()
57+
.attribute(new AddAttribute().key(attributeKey).dataType(AttributeDataType.WATERMARK)
58+
.type(AttributeType.STANDARD).watermark(watermark));
59+
return api.addAttribute(req, siteId);
60+
}
61+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (c) 2018 - 2020 FormKiQ
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.formkiq.testutils.aws;
25+
26+
import com.formkiq.aws.dynamodb.ID;
27+
import com.formkiq.client.api.DocumentsApi;
28+
import com.formkiq.client.invoker.ApiClient;
29+
import com.formkiq.client.invoker.ApiException;
30+
import com.formkiq.client.model.AddDocumentAttribute;
31+
import com.formkiq.client.model.AddDocumentAttributeStandard;
32+
import com.formkiq.client.model.AddDocumentRequest;
33+
34+
/**
35+
* Documents Request Builder.
36+
*/
37+
public class DocumentsRequestBuilder {
38+
39+
/**
40+
* Add Document with Watermark.
41+
*
42+
* @param client {@link ApiClient}
43+
* @param siteId {@link String}
44+
* @param attributeKey {@link String}
45+
* @return {@link String}
46+
* @throws ApiException ApiException
47+
*/
48+
public static String addDocumentWithWatermark(final ApiClient client, final String siteId,
49+
final String attributeKey) throws ApiException {
50+
51+
DocumentsApi api = new DocumentsApi(client);
52+
AddDocumentRequest req = new AddDocumentRequest().content(ID.uuid()).addAttributesItem(
53+
new AddDocumentAttribute(new AddDocumentAttributeStandard().key(attributeKey)));
54+
return api.addDocument(req, siteId, null).getDocumentId();
55+
}
56+
}

0 commit comments

Comments
 (0)