genio 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +54 -0
- data/README.md +55 -0
- data/bin/genio +21 -0
- data/lib/genio.rb +35 -0
- data/lib/genio/helper/base.rb +101 -0
- data/lib/genio/helper/dot_net.rb +410 -0
- data/lib/genio/helper/java.rb +415 -0
- data/lib/genio/helper/php.rb +342 -0
- data/lib/genio/logging.rb +30 -0
- data/lib/genio/tasks.rb +246 -0
- data/lib/genio/template.rb +65 -0
- data/lib/genio/util/namespace_helper.rb +93 -0
- data/lib/genio/util/schema_helper.rb +65 -0
- data/lib/genio/version.rb +19 -0
- data/templates/sdk.rest_dotnet.erb +174 -0
- data/templates/sdk.rest_java.erb +231 -0
- data/templates/sdk.rest_php.erb +120 -0
- data/templates/sdk.rest_version_dotnet.erb +49 -0
- data/templates/sdk.rest_version_java.erb +46 -0
- data/templates/sdk.wsdl_dotnet.erb +90 -0
- data/templates/sdk.wsdl_java.erb +115 -0
- data/templates/sdk.wsdl_php.erb +79 -0
- data/templates/sdk.wsdlenum_dotnet.erb +32 -0
- data/templates/sdk.wsdlenum_java.erb +47 -0
- data/templates/sdk.wsdlservice_dotnet.erb +154 -0
- data/templates/sdk.wsdlservice_java.erb +145 -0
- data/templates/sdk.wsdlservice_php.erb +92 -0
- data/templates/sdk.wsdlsoapdeserialize_dotnet.erb +139 -0
- data/templates/sdk.wsdlsoapdeserialize_java.erb +128 -0
- data/templates/sdk.wsdlsoapserialize_dotnet.erb +184 -0
- data/templates/sdk.wsdlsoapserialize_java.erb +170 -0
- data/templates/sdk.wsdlsoapserialize_php.erb +67 -0
- metadata +191 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 PayPal Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
#
|
17
|
+
module Genio
|
18
|
+
VERSION = "1.0.0"
|
19
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
<%
|
2
|
+
#
|
3
|
+
# Copyright 2013 PayPal Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
#
|
18
|
+
%>
|
19
|
+
<% imports(data_type, schema, package, classname, "rest").each do |import| %>
|
20
|
+
using <%= import %>;
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
namespace <%= package %>
|
24
|
+
{
|
25
|
+
public class <%= validate_class_name(classname) %><%= " : #{validate_class_name(data_type.extends)}" if data_type.extends %>
|
26
|
+
{
|
27
|
+
<% const_args = {} %>
|
28
|
+
<% data_type.properties.each do |name, property| %>
|
29
|
+
<% vname = validate_property_name(name) %>
|
30
|
+
<% const_args[vname] = get_property_class(property, classname) if property.required %>
|
31
|
+
private <%= get_property_class(property, classname) %><%= '?' if (is_nullable_type(property) and !property.array) %> <%= vname %>Property;
|
32
|
+
|
33
|
+
/// <summary>
|
34
|
+
/// <%= property.description %>
|
35
|
+
/// </summary>
|
36
|
+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
37
|
+
public <%= get_property_class(property, classname) %><%= '?' if (is_nullable_type(property) and !property.array) %> <%= vname %>
|
38
|
+
{
|
39
|
+
get
|
40
|
+
{
|
41
|
+
return this.<%= vname %>Property;
|
42
|
+
}
|
43
|
+
set
|
44
|
+
{
|
45
|
+
this.<%= vname %>Property = value;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
<% end %>
|
50
|
+
/// <summary>
|
51
|
+
/// Default Constructor
|
52
|
+
/// </summary>
|
53
|
+
public <%= validate_class_name(classname) %>()
|
54
|
+
{
|
55
|
+
}
|
56
|
+
|
57
|
+
<% if const_args.size > 0 %>
|
58
|
+
/// <summary>
|
59
|
+
/// Parameterized Constructor
|
60
|
+
/// </summary>
|
61
|
+
public <%= validate_class_name(classname) %>(<%= const_args.map{|name, type| "#{type} #{name}"}.join(", ") %>)
|
62
|
+
{
|
63
|
+
<% const_args.each do |name, type| %>
|
64
|
+
this.<%= name %> = <%= name %>;
|
65
|
+
<% end %>
|
66
|
+
}
|
67
|
+
<% end %>
|
68
|
+
|
69
|
+
<% service = schema.services[classname] %>
|
70
|
+
<% if service %>
|
71
|
+
<% service.operations.each do |name, property| %>
|
72
|
+
<% static = is_static_method(property) %>
|
73
|
+
<% hostIdCheck = check_host_id(classname, property) %>
|
74
|
+
<% methodName = validate_method_name(name) %>
|
75
|
+
<% argumentHash = form_rest_api_args(classname, property, name) %>
|
76
|
+
<% resourcePath = validate_path(property.path) %>
|
77
|
+
<% pathParameters = generate_format_hash(classname, property, resourcePath) %>
|
78
|
+
<% payLoad = get_payload(classname, property) %>
|
79
|
+
<% if options[:gen_deprecated_methods] %>
|
80
|
+
|
81
|
+
/// <summary>
|
82
|
+
/// <%= property.description %>
|
83
|
+
/// </summary>
|
84
|
+
/// <param name="accessToken">Access Token used for the API call.</param><% if argumentHash.size > 0 %><% argumentHash.each do |name, type| %>
|
85
|
+
/// <param name="<%= name %>"><%= type %></param><% end %><% end %>
|
86
|
+
/// <returns><% if property.response %><%= property.response %><% end %></returns>
|
87
|
+
public<%= " static" if static %><% if property.response %> <%= validate_class_name(property.response) %><% else %> void<% end %> <%= methodName %>(string accessToken<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{type} #{name}"}.join(", ") %><% end %>)
|
88
|
+
{
|
89
|
+
APIContext apiContext = new APIContext(accessToken);
|
90
|
+
<% if property.response %>
|
91
|
+
return <%= methodName %>(apiContext<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{name}"}.join(", ") %><% end %>);
|
92
|
+
<% else %>
|
93
|
+
<%= name.camelcase %>(apiContext<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{name}"}.join(", ") %><% end %>);
|
94
|
+
return;
|
95
|
+
<% end %>
|
96
|
+
}
|
97
|
+
<% end %>
|
98
|
+
|
99
|
+
/// <summary>
|
100
|
+
/// <%= property.description %>
|
101
|
+
/// </summary>
|
102
|
+
/// <param name="apiContext">APIContext used for the API call.</param><% if argumentHash.size > 0 %><% argumentHash.each do |name, type| %>
|
103
|
+
/// <param name="<%= name %>"><%= type %></param><% end %><% end %>
|
104
|
+
/// <returns><% if property.response %><%= property.response %><% end %></returns>
|
105
|
+
public<%= " static" if static %><% if property.response %> <%= validate_class_name(property.response) %><% else %> void<% end %> <%= methodName %>(APIContext apiContext<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{type} #{name}"}.join(", ") %><% end %>)
|
106
|
+
{
|
107
|
+
if (apiContext == null)
|
108
|
+
{
|
109
|
+
throw new ArgumentNullException("APIContext cannot be null");
|
110
|
+
}
|
111
|
+
<% if options[:mandate_oauth] %>
|
112
|
+
if (string.IsNullOrEmpty(apiContext.AccessToken))
|
113
|
+
{
|
114
|
+
throw new ArgumentNullException("AccessToken cannot be null or empty");
|
115
|
+
}
|
116
|
+
<% end %>
|
117
|
+
if (apiContext.HTTPHeaders == null)
|
118
|
+
{
|
119
|
+
apiContext.HTTPHeaders = new Dictionary<string, string>();
|
120
|
+
}
|
121
|
+
apiContext.HTTPHeaders.Add(BaseConstants.CONTENT_TYPE_HEADER, BaseConstants.CONTENT_TYPE_JSON);
|
122
|
+
apiContext.SdkVersion = new SDKVersionImpl();
|
123
|
+
<% if hostIdCheck %>
|
124
|
+
if (this.id == null)
|
125
|
+
{
|
126
|
+
throw new ArgumentNullException("Id cannot be null");
|
127
|
+
}
|
128
|
+
<% end %>
|
129
|
+
<% if argumentHash.size > 0 %>
|
130
|
+
<% argumentHash.each do |name, type| %>
|
131
|
+
<% if name != 'queryParameters' %>
|
132
|
+
if (<%= name %> == null)
|
133
|
+
{
|
134
|
+
throw new ArgumentNullException("<%= name%> cannot be null");
|
135
|
+
}
|
136
|
+
<% end %>
|
137
|
+
<% end %>
|
138
|
+
<% end %>
|
139
|
+
Dictionary<string, string> pathParameters = new Dictionary<string, string>();
|
140
|
+
<% pathParameters.each do |name, value| %>
|
141
|
+
pathParameters.Add("<%= name %>", <%= value %>);
|
142
|
+
<% end %>
|
143
|
+
string pattern = "<%= resourcePath %>";
|
144
|
+
<% if property.type != 'POST' and property.type != 'PATCH' and property.type != 'PUT' %>
|
145
|
+
string resourcePath = SDKUtil.FormatURIPath(pattern, pathParameters, queryParameters);
|
146
|
+
<% else %>
|
147
|
+
string resourcePath = SDKUtil.FormatURIPath(pattern, pathParameters);
|
148
|
+
<% end %>
|
149
|
+
string payLoad = <%= payLoad %>;
|
150
|
+
<% if property.response %>
|
151
|
+
return PayPalResource.ConfigureAndExecute<<%= validate_class_name(property.response) %>>(apiContext, <%= "HttpMethod." + property.type %>, resourcePath, payLoad);
|
152
|
+
<% else %>
|
153
|
+
PayPalResource.ConfigureAndExecute<object>(apiContext, <%= "HttpMethod." + property.type %>, resourcePath, payLoad);
|
154
|
+
return;
|
155
|
+
<% end %>
|
156
|
+
}
|
157
|
+
|
158
|
+
<% end %>
|
159
|
+
<% end %>
|
160
|
+
/// <summary>
|
161
|
+
/// Converts the object to JSON string
|
162
|
+
/// </summary>
|
163
|
+
public string ConvertToJson()
|
164
|
+
{
|
165
|
+
return JsonFormatter.ConvertToJson(this);
|
166
|
+
}
|
167
|
+
|
168
|
+
public override string ToString()
|
169
|
+
{
|
170
|
+
return ConvertToJson();
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
}
|
@@ -0,0 +1,231 @@
|
|
1
|
+
<%
|
2
|
+
#
|
3
|
+
# Copyright 2013 PayPal Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
#
|
18
|
+
%>
|
19
|
+
package <%= package %>;
|
20
|
+
|
21
|
+
<% imports(data_type, schema, package, classname, "rest").each do |import| %>
|
22
|
+
import <%= import %>;
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
public class <%= validate_class_name(classname) %> <%= "extends #{validate_class_name(data_type.extends)}" if data_type.extends %> {
|
26
|
+
|
27
|
+
<% const_args = {} %>
|
28
|
+
<% data_type.properties.each do |name, property| %>
|
29
|
+
<% vname = validate_property_name(name) %>
|
30
|
+
<% const_args[vname] = get_property_class(property, classname) if property.required %>
|
31
|
+
/**
|
32
|
+
* <%= property.description %>
|
33
|
+
*/
|
34
|
+
private <%= get_property_class(property, classname) %> <%= vname %>;
|
35
|
+
|
36
|
+
<% end %>
|
37
|
+
<% if schema.services[classname] and !options[:skip_stub_operations] %>
|
38
|
+
/**
|
39
|
+
* Returns the last request sent to the Service
|
40
|
+
*
|
41
|
+
* @return Last request sent to the server
|
42
|
+
*/
|
43
|
+
public static String getLastRequest() {
|
44
|
+
return PayPalResource.getLastRequest();
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Returns the last response returned by the Service
|
49
|
+
*
|
50
|
+
* @return Last response got from the Service
|
51
|
+
*/
|
52
|
+
public static String getLastResponse() {
|
53
|
+
return PayPalResource.getLastResponse();
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Initialize using InputStream(of a Properties file)
|
58
|
+
*
|
59
|
+
* @param is
|
60
|
+
* InputStream
|
61
|
+
* @throws PayPalRESTException
|
62
|
+
*/
|
63
|
+
public static void initConfig(InputStream is) throws PayPalRESTException {
|
64
|
+
PayPalResource.initConfig(is);
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Initialize using a File(Properties file)
|
69
|
+
*
|
70
|
+
* @param file
|
71
|
+
* File object of a properties entity
|
72
|
+
* @throws PayPalRESTException
|
73
|
+
*/
|
74
|
+
public static void initConfig(File file) throws PayPalRESTException {
|
75
|
+
PayPalResource.initConfig(file);
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Initialize using Properties
|
80
|
+
*
|
81
|
+
* @param properties
|
82
|
+
* Properties object
|
83
|
+
*/
|
84
|
+
public static void initConfig(Properties properties) {
|
85
|
+
PayPalResource.initConfig(properties);
|
86
|
+
}
|
87
|
+
<% end %>
|
88
|
+
/**
|
89
|
+
* Default Constructor
|
90
|
+
*/
|
91
|
+
public <%= validate_class_name(classname) %>() {
|
92
|
+
}
|
93
|
+
|
94
|
+
<% if const_args.size > 0 %>
|
95
|
+
/**
|
96
|
+
* Parameterized Constructor
|
97
|
+
*/
|
98
|
+
public <%= validate_class_name(classname) %>(<%= const_args.map{|name, type| "#{type} #{name}"}.join(", ") %>) {
|
99
|
+
<% const_args.each do |name, type| %>
|
100
|
+
this.<%= name %> = <%= name %>;
|
101
|
+
<% end %>
|
102
|
+
}
|
103
|
+
|
104
|
+
<% end %>
|
105
|
+
<% data_type.properties.each do |name, property| %>
|
106
|
+
<% vname = validate_property_name(name) %>
|
107
|
+
<% methodname = validate_class_name(name) %>
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Setter for <%= vname %>
|
111
|
+
*/
|
112
|
+
public <%= classname %> set<%= methodname %>(<%= get_property_class(property, classname) %> <%= vname %>) {
|
113
|
+
this.<%= vname%> = <%= vname %>;
|
114
|
+
return this;
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Getter for <%= vname %>
|
119
|
+
*/
|
120
|
+
public <%= get_property_class(property, classname) %> get<%= methodname %>() {
|
121
|
+
return this.<%= vname%>;
|
122
|
+
}
|
123
|
+
|
124
|
+
<% end %>
|
125
|
+
<% service = schema.services[classname] %>
|
126
|
+
<% if service and !options[:skip_stub_operations] %>
|
127
|
+
<% service.operations.each do |name, property| %>
|
128
|
+
<% static = is_static_method(property) %>
|
129
|
+
<% methodName = validate_method_name(name) %>
|
130
|
+
<% hostIdCheck = check_host_id(classname, property) %>
|
131
|
+
<% argumentHash = form_rest_api_args(classname, property, name) %>
|
132
|
+
<% resourcePath = validate_path(property.path) %>
|
133
|
+
<% pathParameters = generate_format_hash(classname, property, resourcePath) %>
|
134
|
+
<% payLoad = get_payload(classname, property) %>
|
135
|
+
<% if options[:gen_deprecated_methods] %>
|
136
|
+
|
137
|
+
/**
|
138
|
+
* <%= property.description %>
|
139
|
+
* @deprecated
|
140
|
+
* @param accessToken
|
141
|
+
* Access Token used for the API call.<% if argumentHash.size > 0 %><% argumentHash.each do |name, type| %>
|
142
|
+
* @param <%= name %>
|
143
|
+
* <%= type %><% end %><% end %>
|
144
|
+
* @return <% if property.response %><%= property.response %><% end %>
|
145
|
+
* @throws PayPalRESTException
|
146
|
+
*/
|
147
|
+
public<%= " static" if static %><% if property.response %> <%= validate_class_name(property.response) %><% else %> void<% end %> <%= methodName %>(String accessToken<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{type.camelcase} #{name}"}.join(", ") %><% end %>) throws PayPalRESTException {
|
148
|
+
APIContext apiContext = new APIContext(accessToken);
|
149
|
+
<% if property.response %>
|
150
|
+
return <%= methodName %>(apiContext<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{name}"}.join(", ") %><% end %>);
|
151
|
+
<% else %>
|
152
|
+
<%= methodName %>(apiContext<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{name}"}.join(", ") %><% end %>);
|
153
|
+
return;
|
154
|
+
<% end %>
|
155
|
+
}
|
156
|
+
<% end %>
|
157
|
+
|
158
|
+
/**
|
159
|
+
* <%= property.description %>
|
160
|
+
* @param apiContext
|
161
|
+
* {@link APIContext} used for the API call.<% if argumentHash.size > 0 %><% argumentHash.each do |name, type| %>
|
162
|
+
* @param <%= name %>
|
163
|
+
* <%= type %><% end %><% end %>
|
164
|
+
* @return <% if property.response %><%= property.response %><% end %>
|
165
|
+
* @throws PayPalRESTException
|
166
|
+
*/
|
167
|
+
public<%= " static" if static %><% if property.response %> <%= validate_class_name(property.response) %><% else %> void<% end %> <%= methodName %>(APIContext apiContext<% if argumentHash.size > 0 %>, <%= argumentHash.map{|name, type| "#{type.camelcase} #{name}"}.join(", ") %><% end %>) throws PayPalRESTException {
|
168
|
+
if (apiContext == null) {
|
169
|
+
throw new IllegalArgumentException("APIContext cannot be null");
|
170
|
+
}
|
171
|
+
<% if options[:mandate_oauth] %>
|
172
|
+
if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
|
173
|
+
throw new IllegalArgumentException("AccessToken cannot be null or empty");
|
174
|
+
}
|
175
|
+
<% end %>
|
176
|
+
if (apiContext.getHTTPHeaders() == null) {
|
177
|
+
apiContext.setHTTPHeaders(new HashMap<String, String>());
|
178
|
+
}
|
179
|
+
apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
|
180
|
+
apiContext.setSdkVersion(new SDKVersionImpl());
|
181
|
+
<% if hostIdCheck %>
|
182
|
+
if (this.getId() == null) {
|
183
|
+
throw new IllegalArgumentException("Id cannot be null");
|
184
|
+
}
|
185
|
+
<% end %>
|
186
|
+
<% if argumentHash.size > 0 %>
|
187
|
+
<% argumentHash.each do |name, type| %>
|
188
|
+
<% if name != 'queryParameters' %>
|
189
|
+
if (<%= name%> == null) {
|
190
|
+
throw new IllegalArgumentException("<%= name%> cannot be null");
|
191
|
+
}
|
192
|
+
<% end %>
|
193
|
+
<% end %>
|
194
|
+
<% end %>
|
195
|
+
Map<String, String> pathParameters = new HashMap<String, String>();
|
196
|
+
<% pathParameters.each do |name, value| %>
|
197
|
+
pathParameters.put("<%= name %>", <%= value%>);
|
198
|
+
<% end %>
|
199
|
+
String pattern = "<%= resourcePath %>";
|
200
|
+
<% if property.type != 'POST' and property.type != 'PATCH' and property.type != 'PUT' %>
|
201
|
+
String resourcePath = RESTUtil.formatURIPath(pattern, pathParameters, queryParameters);
|
202
|
+
<% else %>
|
203
|
+
String resourcePath = RESTUtil.formatURIPath(pattern, pathParameters);
|
204
|
+
<% end %>
|
205
|
+
String payLoad = <%= payLoad %>;
|
206
|
+
<% if property.response %>
|
207
|
+
return PayPalResource.configureAndExecute(apiContext, <%= "HttpMethod." + property.type %>, resourcePath, payLoad, <%= validate_class_name(property.response) %>.class);
|
208
|
+
<% else %>
|
209
|
+
PayPalResource.configureAndExecute(apiContext, <%= "HttpMethod." + property.type %>, resourcePath, payLoad, null);
|
210
|
+
return;
|
211
|
+
<% end %>
|
212
|
+
}
|
213
|
+
|
214
|
+
<% end %>
|
215
|
+
<% end %>
|
216
|
+
<% if !options[:skip_stub_operations] %>
|
217
|
+
/**
|
218
|
+
* Returns a JSON string corresponding to object state
|
219
|
+
*
|
220
|
+
* @return JSON representation
|
221
|
+
*/
|
222
|
+
public String toJSON() {
|
223
|
+
return JSONFormatter.toJSON(this);
|
224
|
+
}
|
225
|
+
|
226
|
+
@Override
|
227
|
+
public String toString() {
|
228
|
+
return toJSON();
|
229
|
+
}
|
230
|
+
<% end %>
|
231
|
+
}
|
@@ -0,0 +1,120 @@
|
|
1
|
+
<%
|
2
|
+
#
|
3
|
+
# Copyright 2013 PayPal Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
#
|
18
|
+
%>
|
19
|
+
<?php
|
20
|
+
<% service = schema.services[classname] %>
|
21
|
+
namespace <%= package %>;
|
22
|
+
|
23
|
+
<% imports(data_type, schema, package, classname, "rest").each do |import| %>
|
24
|
+
use <%= import %>;
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
class <%= classname %> <%= data_type.extends ? "extends #{valid_class_name(data_type.extends)} " : "extends PPModel " %><%= "implements IResource " if service %>{
|
28
|
+
<% if service %>
|
29
|
+
|
30
|
+
<% end %>
|
31
|
+
<% data_type.properties.each do |name, property| %>
|
32
|
+
<% vname = to_underscore(name) %>
|
33
|
+
<% vtype = get_php_type(property, schema, classname) %>
|
34
|
+
/**
|
35
|
+
* <%= property.description %>
|
36
|
+
*
|
37
|
+
<% if property.array %>
|
38
|
+
* @array
|
39
|
+
<% end %>
|
40
|
+
* @param <%= "#{get_namespace(schema.data_types[vtype].package || schema.endpoint )}\\" if schema.data_types[vtype] %><%= vtype %> $<%= name %>
|
41
|
+
*/
|
42
|
+
public function set<%= valid_class_name(name) %>(<%if property.array %>array <%end%>$<%= vname %>) {
|
43
|
+
<% if vname != name%>
|
44
|
+
$this->{"<%= name %>"} = $<%= vname %>;
|
45
|
+
<% else %>
|
46
|
+
$this-><%= vname %> = $<%= vname %>;
|
47
|
+
<% end %>
|
48
|
+
return $this;
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* <%= property.description %>
|
53
|
+
*
|
54
|
+
* @return <%= "#{get_namespace(schema.data_types[vtype].package || schema.endpoint )}\\" if schema.data_types[vtype] %><%= vtype %>
|
55
|
+
*/
|
56
|
+
public function get<%= valid_class_name(name) %>() {
|
57
|
+
<% if vname != name%>
|
58
|
+
return $this->{"<%= name %>"};
|
59
|
+
<% else %>
|
60
|
+
return $this-><%= vname %>;
|
61
|
+
<% end %>
|
62
|
+
}
|
63
|
+
|
64
|
+
<% end %>
|
65
|
+
<% if service %>
|
66
|
+
<% service.operations.each do |name, property| %>
|
67
|
+
<% static = is_static_method(property) %>
|
68
|
+
<% hostId_check = check_host_id(classname, property) %>
|
69
|
+
<% argument_hash = form_arguments(classname, property, name) %>
|
70
|
+
<% object_array = get_object_array(classname, name, property, argument_hash) %>
|
71
|
+
<% payload = get_payload(classname, property) %>
|
72
|
+
/*
|
73
|
+
* <%= property.description %>
|
74
|
+
*
|
75
|
+
<% argument_hash.each do |name, type| %>
|
76
|
+
* @param <%= type %> $<%= name %>
|
77
|
+
<% end %>
|
78
|
+
<% if( property.parameters && allowed_params(property.parameters).size > 0 )%>
|
79
|
+
* allowed queryparameters <%= allowed_params(property.parameters).map{|k,v| "'#{k}'" }.join(", ") %>
|
80
|
+
<% end %>
|
81
|
+
* @param PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration, credentials, and additional headers.
|
82
|
+
* @return <%= "#{get_namespace(schema.data_types[property.response].package || schema.endpoint )}\\" if schema.data_types[property.response] %><%= property.response || 'string' %>
|
83
|
+
*/
|
84
|
+
public<%= " static" if static %> function <%= validate_function_name(name) %>(<% if argument_hash.size > 0 %><%= argument_hash.map{|name, type| type == "array" ? "array $#{name}" : "$#{name}"}.join(", ") %>, <% end %>$apiContext) {
|
85
|
+
<% if hostId_check %>
|
86
|
+
if ($this->getId() == null) {
|
87
|
+
throw new \InvalidArgumentException("Id cannot be null");
|
88
|
+
}
|
89
|
+
<% end %>
|
90
|
+
<% if argument_hash.size > 0 %>
|
91
|
+
<% argument_hash.each do |name, type| %>
|
92
|
+
<% if name != 'queryParameters'%>
|
93
|
+
|
94
|
+
if ($<%= name %> == null<%= " || strlen($#{name}) == 0" if type == "string" %>) {
|
95
|
+
throw new \InvalidArgumentException("<%= name%> cannot be null or empty");
|
96
|
+
}
|
97
|
+
<% end %>
|
98
|
+
<% end %>
|
99
|
+
<% end %>
|
100
|
+
$payload = <%= payload %>;
|
101
|
+
$call = new PPRestCall($apiContext);
|
102
|
+
$json = $call->execute(array('PayPal\Rest\RestHandler'), <%= process_path_with_placeholders(classname, name, property.path, hostId_check, argument_hash, property.parameters) %>, "<%= property.type %>", $payload);
|
103
|
+
<% if property.request == classname %>
|
104
|
+
$this->fromJson($json);
|
105
|
+
return $this;
|
106
|
+
<% elsif property.response %>
|
107
|
+
<% if property.response == "string" %>
|
108
|
+
return $json;
|
109
|
+
<% else %>
|
110
|
+
$ret = new <%= property.response %>();
|
111
|
+
$ret->fromJson($json);
|
112
|
+
return $ret;
|
113
|
+
<% end %>
|
114
|
+
<% else %>
|
115
|
+
return $json;
|
116
|
+
<% end %>
|
117
|
+
}
|
118
|
+
<% end %>
|
119
|
+
<% end %>
|
120
|
+
}
|