Skip to content

Commit b51178a

Browse files
authored
Merge pull request #5 from PandaDoc/PD-18164-18165-fix-list-responses
Fix contacts and members list response formats, fix fields for template details
2 parents f72b59d + bb8b97f commit b51178a

File tree

8 files changed

+126
-168
lines changed

8 files changed

+126
-168
lines changed

docs/ContactListResponse.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
## Properties
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**value** | [**[ContactDetailsResponse]**](ContactDetailsResponse.md) | |
7+
**results** | [**[ContactDetailsResponse]**](ContactDetailsResponse.md) | | [optional]
8+
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
89

910
[[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1011

docs/MemberListResponse.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
## Properties
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**value** | [**[MemberDetailsResponse]**](MemberDetailsResponse.md) | |
7+
**results** | [**[MemberDetailsResponse]**](MemberDetailsResponse.md) | | [optional]
8+
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
89

910
[[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1011

pandadoc_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111

12-
__version__ = "2.0.0"
12+
__version__ = "3.0.0"
1313

1414
# import ApiClient
1515
from pandadoc_client.api_client import ApiClient

pandadoc_client/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7575
self.default_headers[header_name] = header_value
7676
self.cookie = cookie
7777
# Set default User-Agent.
78-
self.user_agent = 'pandadoc_python_client/2.0.0'
78+
self.user_agent = 'pandadoc_python_client/3.0.0'
7979

8080
def __enter__(self):
8181
return self

pandadoc_client/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def to_debug_report(self):
412412
"OS: {env}\n"\
413413
"Python Version: {pyversion}\n"\
414414
"Version of the API: 2.0.0\n"\
415-
"SDK Package Version: 2.0.0".\
415+
"SDK Package Version: 3.0.0".\
416416
format(env=sys.platform, pyversion=sys.version)
417417

418418
def get_host_settings(self):

pandadoc_client/model/contact_list_response.py

Lines changed: 59 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def lazy_import():
3333
globals()['ContactDetailsResponse'] = ContactDetailsResponse
3434

3535

36-
class ContactListResponse(ModelSimple):
36+
class ContactListResponse(ModelNormal):
3737
"""NOTE: This class is auto generated by OpenAPI Generator.
3838
Ref: https://openapi-generator.tech
3939
@@ -44,6 +44,10 @@ class ContactListResponse(ModelSimple):
4444
and the for var_name this is (var_name,). The value is a dict
4545
with a capitalized key describing the allowed value and an allowed
4646
value. These dicts store the allowed enum values.
47+
attribute_map (dict): The key is attribute name
48+
and the value is json key in definition.
49+
discriminator_value_class_map (dict): A dict to go from the discriminator
50+
variable value to the discriminator class name.
4751
validations (dict): The key is the tuple path to the attribute
4852
and the for var_name this is (var_name,). The value is a dict
4953
that stores validations for max_length, min_length, max_items,
@@ -59,7 +63,14 @@ class ContactListResponse(ModelSimple):
5963
validations = {
6064
}
6165

62-
additional_properties_type = None
66+
@cached_property
67+
def additional_properties_type():
68+
"""
69+
This must be a method because a model may have properties that are
70+
of type self, this must run after the class is loaded
71+
"""
72+
lazy_import()
73+
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501
6374

6475
_nullable = False
6576

@@ -75,40 +86,29 @@ def openapi_types():
7586
"""
7687
lazy_import()
7788
return {
78-
'value': ([ContactDetailsResponse],),
89+
'results': ([ContactDetailsResponse],), # noqa: E501
7990
}
8091

8192
@cached_property
8293
def discriminator():
8394
return None
8495

8596

86-
attribute_map = {}
87-
88-
read_only_vars = set()
97+
attribute_map = {
98+
'results': 'results', # noqa: E501
99+
}
89100

90-
_composed_schemas = None
101+
read_only_vars = {
102+
}
91103

92-
required_properties = set([
93-
'_data_store',
94-
'_check_type',
95-
'_spec_property_naming',
96-
'_path_to_item',
97-
'_configuration',
98-
'_visited_composed_classes',
99-
])
104+
_composed_schemas = {}
100105

106+
@classmethod
101107
@convert_js_args_to_python_args
102-
def __init__(self, *args, **kwargs):
108+
def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
103109
"""ContactListResponse - a model defined in OpenAPI
104110
105-
Note that value can be passed either in args or in kwargs, but not in both.
106-
107-
Args:
108-
args[0] ([ContactDetailsResponse]): # noqa: E501
109-
110111
Keyword Args:
111-
value ([ContactDetailsResponse]): # noqa: E501
112112
_check_type (bool): if True, values for parameters in openapi_types
113113
will be type checked and a TypeError will be
114114
raised if the wrong type is input.
@@ -139,27 +139,17 @@ def __init__(self, *args, **kwargs):
139139
Animal class but this time we won't travel
140140
through its discriminator because we passed in
141141
_visited_composed_classes = (Animal,)
142+
results ([ContactDetailsResponse]): [optional] # noqa: E501
142143
"""
143-
# required up here when default value is not given
144-
_path_to_item = kwargs.pop('_path_to_item', ())
145-
146-
if 'value' in kwargs:
147-
value = kwargs.pop('value')
148-
elif args:
149-
args = list(args)
150-
value = args.pop(0)
151-
else:
152-
raise ApiTypeError(
153-
"value is required, but not passed in args or kwargs and doesn't have default",
154-
path_to_item=_path_to_item,
155-
valid_classes=(self.__class__,),
156-
)
157144

158145
_check_type = kwargs.pop('_check_type', True)
159146
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
147+
_path_to_item = kwargs.pop('_path_to_item', ())
160148
_configuration = kwargs.pop('_configuration', None)
161149
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
162150

151+
self = super(OpenApiModel, cls).__new__(cls)
152+
163153
if args:
164154
raise ApiTypeError(
165155
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
@@ -176,29 +166,31 @@ def __init__(self, *args, **kwargs):
176166
self._path_to_item = _path_to_item
177167
self._configuration = _configuration
178168
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
179-
self.value = value
180-
if kwargs:
181-
raise ApiTypeError(
182-
"Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % (
183-
kwargs,
184-
self.__class__.__name__,
185-
),
186-
path_to_item=_path_to_item,
187-
valid_classes=(self.__class__,),
188-
)
189169

190-
@classmethod
191-
@convert_js_args_to_python_args
192-
def _from_openapi_data(cls, *args, **kwargs):
193-
"""ContactListResponse - a model defined in OpenAPI
170+
for var_name, var_value in kwargs.items():
171+
if var_name not in self.attribute_map and \
172+
self._configuration is not None and \
173+
self._configuration.discard_unknown_keys and \
174+
self.additional_properties_type is None:
175+
# discard variable.
176+
continue
177+
setattr(self, var_name, var_value)
178+
return self
194179

195-
Note that value can be passed either in args or in kwargs, but not in both.
180+
required_properties = set([
181+
'_data_store',
182+
'_check_type',
183+
'_spec_property_naming',
184+
'_path_to_item',
185+
'_configuration',
186+
'_visited_composed_classes',
187+
])
196188

197-
Args:
198-
args[0] ([ContactDetailsResponse]): # noqa: E501
189+
@convert_js_args_to_python_args
190+
def __init__(self, *args, **kwargs): # noqa: E501
191+
"""ContactListResponse - a model defined in OpenAPI
199192
200193
Keyword Args:
201-
value ([ContactDetailsResponse]): # noqa: E501
202194
_check_type (bool): if True, values for parameters in openapi_types
203195
will be type checked and a TypeError will be
204196
raised if the wrong type is input.
@@ -229,26 +221,12 @@ def _from_openapi_data(cls, *args, **kwargs):
229221
Animal class but this time we won't travel
230222
through its discriminator because we passed in
231223
_visited_composed_classes = (Animal,)
224+
results ([ContactDetailsResponse]): [optional] # noqa: E501
232225
"""
233-
# required up here when default value is not given
234-
_path_to_item = kwargs.pop('_path_to_item', ())
235-
236-
self = super(OpenApiModel, cls).__new__(cls)
237-
238-
if 'value' in kwargs:
239-
value = kwargs.pop('value')
240-
elif args:
241-
args = list(args)
242-
value = args.pop(0)
243-
else:
244-
raise ApiTypeError(
245-
"value is required, but not passed in args or kwargs and doesn't have default",
246-
path_to_item=_path_to_item,
247-
valid_classes=(self.__class__,),
248-
)
249226

250227
_check_type = kwargs.pop('_check_type', True)
251228
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
229+
_path_to_item = kwargs.pop('_path_to_item', ())
252230
_configuration = kwargs.pop('_configuration', None)
253231
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
254232

@@ -268,15 +246,15 @@ def _from_openapi_data(cls, *args, **kwargs):
268246
self._path_to_item = _path_to_item
269247
self._configuration = _configuration
270248
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
271-
self.value = value
272-
if kwargs:
273-
raise ApiTypeError(
274-
"Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % (
275-
kwargs,
276-
self.__class__.__name__,
277-
),
278-
path_to_item=_path_to_item,
279-
valid_classes=(self.__class__,),
280-
)
281249

282-
return self
250+
for var_name, var_value in kwargs.items():
251+
if var_name not in self.attribute_map and \
252+
self._configuration is not None and \
253+
self._configuration.discard_unknown_keys and \
254+
self.additional_properties_type is None:
255+
# discard variable.
256+
continue
257+
setattr(self, var_name, var_value)
258+
if var_name in self.read_only_vars:
259+
raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
260+
f"class with read only attributes.")

0 commit comments

Comments
 (0)