Skip to content

Commit a421deb

Browse files
author
Brian Melton
committed
adding PUT/PATCH to Requests
1 parent da4657b commit a421deb

File tree

2 files changed

+125
-22
lines changed

2 files changed

+125
-22
lines changed

Templates/Android/generated/BaseMethodRequest.java.tt

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,49 @@ if (c.AsOdcmMethod().IsAction()) {
123123
}
124124
<#
125125
}
126-
} else {
126+
} else { // FUNCTIONS
127127
if (c.AsOdcmMethod().ReturnType != null) {
128+
if (c.AsOdcmMethod().IsComposable) {
129+
#>
130+
/**
131+
* Patches the <#=ReturnType(c)#>
132+
*
133+
* @param callback The callback to be called after success or failure
134+
*/
135+
public void patch(final ICallback<<#=ReturnType(c)#>> callback) {
136+
send(HttpMethod.PATCH, callback, null);
137+
}
138+
139+
/**
140+
* Patches the <#=ReturnType(c)#>
141+
*
142+
* @return The <#=ReturnType(c)#>
143+
* @throws ClientException An exception occurs if there was an error while the request was sent
144+
*/
145+
public void patch() throws ClientException {
146+
this.send(HttpMethod.PATCH, null);
147+
}
148+
149+
/**
150+
* Puts the <#=ReturnType(c)#>
151+
*
152+
* @param callback The callback to be called after success or failure
153+
*/
154+
public void put(final ICallback<<#=ReturnType(c)#>> callback) {
155+
send(HttpMethod.PUT, callback, null);
156+
}
157+
158+
/**
159+
* Puts the <#=ReturnType(c)#>
160+
*
161+
* @return The <#=ReturnType(c)#>
162+
* @throws ClientException An exception occurs if there was an error while the request was sent
163+
*/
164+
public void put() throws ClientException {
165+
this.send(HttpMethod.PUT, null);
166+
}
167+
<#
168+
}
128169
#>
129170
/**
130171
* Gets the <#=ReturnType(c)#>

Templates/Android/generated/IBaseMethodRequest.java.tt

Lines changed: 83 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import com.google.gson.annotations.*;
1111

1212
<#=CreateInterfaceDef(IBaseTypeRequest(c))#>
1313

14-
<# if (c.AsOdcmMethod().IsAction()) { #>
15-
<# if (c.AsOdcmMethod().ReturnType != null) { #>
14+
<#
15+
if (c.AsOdcmMethod().IsAction()) {
16+
if (c.AsOdcmMethod().ReturnType != null) {
17+
#>
1618
/**
1719
* Creates the <#=ReturnType(c)#>
1820
*
@@ -28,7 +30,9 @@ import com.google.gson.annotations.*;
2830
*/
2931
<#=ReturnType(c)#> post() throws ClientException;
3032

31-
<# if (c.GetFeatures().CanSelect) { #>
33+
<#
34+
if (c.GetFeatures().CanSelect) {
35+
#>
3236
/**
3337
* Sets the select clause for the request
3438
*
@@ -37,8 +41,11 @@ import com.google.gson.annotations.*;
3741
*/
3842
<#=ITypeRequest(c)#> select(final String value);
3943

40-
<# } #>
41-
<# if (c.GetFeatures().CanExpand) { #>
44+
<#
45+
}
46+
47+
if (c.GetFeatures().CanExpand) {
48+
#>
4249
/**
4350
* Sets the expand clause for the request
4451
*
@@ -47,17 +54,24 @@ import com.google.gson.annotations.*;
4754
*/
4855
<#=ITypeRequest(c)#> expand(final String value);
4956

50-
<# } #>
51-
<# if (c.AsOdcmProperty() != null && c.AsOdcmProperty().IsCollection && c.GetFeatures().CanUseTop) { #>
57+
<#
58+
}
59+
60+
if (c.AsOdcmProperty() != null
61+
&& c.AsOdcmProperty().IsCollection
62+
&& c.GetFeatures().CanUseTop) {
63+
#>
5264
/**
5365
* Sets the top value for the request
5466
*
5567
* @param value The max number of items to return
5668
* @return The updated request
5769
*/
5870
<#=ITypeRequest(c)#> top(final int value);
59-
<# } #>
60-
<# } else { #>
71+
<#
72+
}
73+
} else {
74+
#>
6175
/**
6276
* Creates the <#=ReturnType(c)#>
6377
*
@@ -73,9 +87,44 @@ import com.google.gson.annotations.*;
7387
*/
7488
void post() throws ClientException;
7589

76-
<# } #>
77-
<# } else { #>
78-
<# if (c.AsOdcmMethod().ReturnType != null) { #>
90+
<#
91+
}
92+
} else {
93+
if (c.AsOdcmMethod().ReturnType != null) {
94+
if (c.AsOdcmMethod().IsComposable) {
95+
#>
96+
/**
97+
* Patches the <#=ReturnType(c)#>
98+
*
99+
* @param callback The callback to be called after success or failure
100+
*/
101+
public void patch(final ICallback<<#=ReturnType(c)#>> callback);
102+
103+
/**
104+
* Patches the <#=ReturnType(c)#>
105+
*
106+
* @return The <#=ReturnType(c)#>
107+
* @throws ClientException An exception occurs if there was an error while the request was sent
108+
*/
109+
public void patch() throws ClientException;
110+
111+
/**
112+
* Puts the <#=ReturnType(c)#>
113+
*
114+
* @param callback The callback to be called after success or failure
115+
*/
116+
public void put(final ICallback<<#=ReturnType(c)#>> callback);
117+
118+
/**
119+
* Puts the <#=ReturnType(c)#>
120+
*
121+
* @return The <#=ReturnType(c)#>
122+
* @throws ClientException An exception occurs if there was an error while the request was sent
123+
*/
124+
public void put() throws ClientException;
125+
<#
126+
}
127+
#>
79128
/**
80129
* Gets the <#=ReturnType(c)#>
81130
* @param callback The callback to be called after success or failure.
@@ -90,7 +139,9 @@ import com.google.gson.annotations.*;
90139
*/
91140
<#=ReturnType(c)#> get() throws ClientException;
92141

93-
<# if (c.GetFeatures().CanSelect) { #>
142+
<#
143+
if (c.GetFeatures().CanSelect) {
144+
#>
94145
/**
95146
* Sets the select clause for the request
96147
*
@@ -99,8 +150,10 @@ import com.google.gson.annotations.*;
99150
*/
100151
<#=ITypeRequest(c)#> select(final String value);
101152

102-
<# } #>
103-
<# if (c.GetFeatures().CanExpand) { #>
153+
<#
154+
}
155+
156+
if (c.GetFeatures().CanExpand) { #>
104157
/**
105158
* Sets the expand clause for the request
106159
*
@@ -109,21 +162,30 @@ import com.google.gson.annotations.*;
109162
*/
110163
<#=ITypeRequest(c)#> expand(final String value);
111164

112-
<# } #>
113-
<# if (c.AsOdcmProperty() != null && c.AsOdcmProperty().IsCollection && c.GetFeatures().CanUseTop) { #>
165+
<#
166+
}
167+
168+
if (c.AsOdcmProperty() != null
169+
&& c.AsOdcmProperty().IsCollection
170+
&& c.GetFeatures().CanUseTop) {
171+
#>
114172
/**
115173
* Sets the top value for the request
116174
*
117175
* @param value The max number of items to return
118176
* @return The updated request
119177
*/
120178
<#=ITypeRequest(c)#> top(final int value);
121-
<# } #>
122-
<# } else { #>
179+
<#
180+
}
181+
} else {
182+
#>
123183
void get(final ICallback<Void> callback);
124184

125185
void get() throws ClientException;
126186

127-
<# } #>
128-
<# } #>
187+
<#
188+
}
189+
}
190+
#>
129191
}

0 commit comments

Comments
 (0)