Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit ae1ff6e

Browse files
Merge 00d45c4 into 278b49e
2 parents 278b49e + 00d45c4 commit ae1ff6e

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

smartsheet/models/profile_image.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# pylint: disable=C0111,R0902,R0904,R0912,R0913,R0915,E1101
2+
# Smartsheet Python SDK.
3+
#
4+
# Copyright 2020 Smartsheet.com, Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"): you may
7+
# not use this file except in compliance with the License. You may obtain
8+
# a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
18+
from __future__ import absolute_import
19+
20+
from ..types import *
21+
from ..util import serialize
22+
from ..util import deserialize
23+
24+
25+
class ProfileImage(object):
26+
27+
"""Smartsheet Profile Image data model."""
28+
29+
def __init__(self, props=None, base_obj=None):
30+
"""Initialize the ProfileImage model."""
31+
self._base = None
32+
if base_obj is not None:
33+
self._base = base_obj
34+
35+
self._height = Number()
36+
self._image_id_ = String()
37+
self._width = Number()
38+
39+
if props:
40+
deserialize(self, props)
41+
42+
@property
43+
def height(self):
44+
return self._height.value
45+
46+
@height.setter
47+
def height(self, value):
48+
self._height.value = value
49+
50+
@property
51+
def image_id(self):
52+
return self._image_id_.value
53+
54+
@image_id.setter
55+
def image_id(self, value):
56+
self._image_id_.value = value
57+
58+
@property
59+
def width(self):
60+
return self._width.value
61+
62+
@width.setter
63+
def width(self, value):
64+
self._width.value = value
65+
66+
def to_dict(self):
67+
return serialize(self)
68+
69+
def to_json(self):
70+
return json.dumps(self.to_dict())
71+
72+
def __str__(self):
73+
return self.to_json()

smartsheet/models/user_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from .alternate_email import AlternateEmail
2121
from .enums import UserStatus
22-
from .image import Image
22+
from .profile_image import ProfileImage
2323
from ..types import *
2424
from ..util import serialize
2525
from ..util import deserialize
@@ -48,7 +48,7 @@ def __init__(self, props=None, base_obj=None):
4848
self._last_name = String()
4949
self._licensed_sheet_creator = Boolean()
5050
self._mobile_phone = String()
51-
self._profile_image = TypedObject(Image)
51+
self._profile_image = TypedObject(ProfileImage)
5252
self._resource_viewer = Boolean()
5353
self._role = String()
5454
self._sheet_count = Number()

tests/integration/test_users.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,16 @@ def test_delete_alternate_email(self, smart_setup):
119119
)
120120
assert action.message == 'SUCCESS'
121121

122+
122123
def test_add_profile_image(self, smart_setup):
123124
smart = smart_setup['smart']
124125
me = smart.Users.get_current_user()
125126
assert isinstance(me.id, six.integer_types)
126127

127128
action = smart.Users.add_profile_image(me.id, _dir + '/fixtures/curly.jpg', 'image/jpeg')
128129
assert action.message == 'SUCCESS'
130+
me = smart.Users.get_current_user()
131+
assert me.profile_image.image_id is not None
132+
square_profile_image_size = 1050
133+
assert me.profile_image.width == square_profile_image_size
134+
assert me.profile_image.height == square_profile_image_size

0 commit comments

Comments
 (0)