Skip to content

Commit 00adea2

Browse files
authored
GROW-965: Adding method for contact finance update (#63)
* GROW-965: Adding method for contact finance update * GROW-965: Fixing changelog and version * GROW-965: Log order
1 parent 310f570 commit 00adea2

File tree

6 files changed

+212
-5
lines changed

6 files changed

+212
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [2.1.0] - 2019-08-19
7+
### Added
8+
- update_contact_finances()
9+
10+
611
## [2.0.0] - 2019-08-10
712
### Added
813
- New CHANGELOG.md added.
914

1015
### Changes
1116
- The `get_quote()` method now utilizes
1217
[v2 of the quotes endpoint](https://connect.vacasait.com/#operation/get-quote-v2).
18+
19+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='VacasaConnect',
5-
version='2.0.0',
5+
version='2.1.0',
66
description='A Python 3.6+ SDK for the connect.vacasa.com API.',
77
packages=['vacasa.connect'],
88
url='https://github.com/Vacasa/python-vacasa-connect-sdk',

tests/test_connect.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,44 @@ def test_create_cancelled_reservation_ignores_missing_display_currency_code(mock
153153
mock_post.assert_called_once_with('https://fake_url/v1/reservations',
154154
headers=ANY,
155155
json=deepcopy(TEST_EXPECTED['reservation_without_display_currency_code']))
156+
157+
158+
# ----- Contracts (DOCUMENTS) ----- #
159+
@patch.object(VacasaConnect, '_post')
160+
def test_create_contract(mock_post):
161+
connect = mock_connect()
162+
163+
connect.create_contract(**deepcopy(TEST_DATA['normal_contract']))
164+
mock_post.assert_called_once_with('https://fake_url/v1/contracts',
165+
headers=ANY,
166+
json=deepcopy(TEST_EXPECTED['normal_contract']))
167+
168+
169+
# ----- Contacts (PEOPLE) ----- #
170+
@patch.object(VacasaConnect, '_post')
171+
def test_create_contact(mock_post):
172+
connect = mock_connect()
173+
174+
connect.create_contact(**deepcopy(TEST_DATA['normal_contact']))
175+
mock_post.assert_called_once_with('https://fake_url/v1/contacts',
176+
headers=ANY,
177+
json=deepcopy(TEST_EXPECTED['normal_contact']))
178+
179+
180+
@patch.object(VacasaConnect, '_patch')
181+
def test_update_finance_payload(mock_patch):
182+
connect = mock_connect()
183+
184+
connect.update_contact_finances_payload(12345, deepcopy(TEST_DATA['normal_contact_finances']))
185+
mock_patch.assert_called_once_with('https://fake_url/v1/contacts/12345/finances',
186+
headers=ANY,
187+
json=deepcopy(TEST_EXPECTED['normal_contact_finances']))
188+
189+
@patch.object(VacasaConnect, '_patch')
190+
def test_update_finance(mock_patch):
191+
connect = mock_connect()
192+
193+
connect.update_contact_finances(12340, **deepcopy(TEST_DATA['normal_contact_finances']))
194+
mock_patch.assert_called_once_with('https://fake_url/v1/contacts/12340/finances',
195+
headers=ANY,
196+
json=deepcopy(TEST_EXPECTED['normal_contact_finances']))

tests/test_data.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,51 @@
1313
last_name='Doe',
1414
account_number='bar',
1515
exp_mmyy='0130'
16+
),
17+
normal_contact=dict(
18+
address_1= "123 Main st",
19+
address_2= "",
20+
city= "Springfield",
21+
country_code= "US",
22+
created_by= 0,
23+
email= "user@example.com",
24+
first_name= "User",
25+
language_id= 0,
26+
last_name= "Namesson",
27+
phone= "208-555-6677",
28+
phone_notes= "Don't ever call after midnight",
29+
state= "MO",
30+
tax_entity_name= "Arbys",
31+
zip= "string"
32+
),
33+
normal_contract=dict(
34+
amendment_by_notice_id= 4,
35+
channel_fee_cost_sharing_id= 5,
36+
created_by= 0,
37+
end_date= "2019-08-15",
38+
form_id= 1,
39+
management_fee= 0,
40+
monthly_rent= 0,
41+
owners= [
42+
dict(
43+
percentage_ownership= 100,
44+
tax_ownership= 100,
45+
contact_id= 12345
46+
)
47+
],
48+
referral_discount= 0,
49+
referral_eligible= False,
50+
start_date= "2019-08-15",
51+
template_version_id= 1,
52+
unit_id= 0
53+
),
54+
normal_contact_finances=dict(
55+
account_name= "Chemical Bank",
56+
account_number= "987654321",
57+
routing_number= "123456789",
58+
tax_id= "00-0000-0",
59+
tax_entity_name= "Arbys",
60+
tax_form_code_id= 12
1661
)
1762
)
1863

tests/test_expected.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,66 @@
2222
source=None
2323
)
2424
)
25+
),
26+
normal_contact=dict(
27+
data=dict(
28+
attributes=dict(
29+
address_1= "123 Main st",
30+
address_2= "",
31+
city= "Springfield",
32+
country_code= "US",
33+
created_by= 0,
34+
email= "user@example.com",
35+
first_name= "User",
36+
language_id= 0,
37+
last_name= "Namesson",
38+
phone= "208-555-6677",
39+
phone_notes= "Don't ever call after midnight",
40+
state= "MO",
41+
tax_entity_name= "Arbys",
42+
zip= "string",
43+
send_email=False
44+
)
45+
)
46+
),
47+
normal_contract=dict(
48+
data=dict(
49+
attributes=dict(
50+
amendment_by_notice_id= 4,
51+
channel_fee_cost_sharing_id= 5,
52+
created_by= 0,
53+
end_date= "2019-08-15",
54+
form_id= 1,
55+
management_fee= 0,
56+
monthly_rent= 0,
57+
owners= [
58+
dict(
59+
percentage_ownership= 100,
60+
tax_ownership= 100,
61+
contact_id= 12345
62+
)
63+
],
64+
referral_discount= 0,
65+
referral_eligible= False,
66+
start_date= "2019-08-15",
67+
template_version_id= 1,
68+
unit_id= 0
69+
)
70+
)
71+
),
72+
normal_contact_finances=dict(
73+
data=dict(
74+
attributes=dict(
75+
account_name= "Chemical Bank",
76+
account_number= "987654321",
77+
routing_number= "123456789",
78+
tax_id= "00-0000-0",
79+
tax_entity_name= "Arbys",
80+
tax_form_code_id= 12
81+
)
82+
)
2583
)
84+
2685
)
2786

2887
# terms

vacasa/connect/connect.py

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ def create_contact(self,
11571157
send_email: bool = False
11581158
):
11591159
"""
1160-
https://vacasa.docs.stoplight.io/contacts/postv1contacts
1160+
https://connect.vacasa.com/#tag/Contacts/paths/~1v1~1contacts/post
11611161
11621162
Args:
11631163
first_name: First name of the contact
@@ -1210,22 +1210,77 @@ def create_contact(self,
12101210
def update_contact(self, contact_id, params: dict):
12111211

12121212
"""
1213-
Update a unit via connect.
1214-
https://vacasa.docs.stoplight.io/contacts/patchv1contactsid
1213+
Update a contact via connect.
1214+
https://connect.vacasa.com/#tag/Contacts/paths/~1v1~1contacts/patch
12151215
12161216
Args:
12171217
contact_id: ID of the contact to update
12181218
params: A dict of key value pairs to update.
12191219
12201220
Returns: dict
1221-
updated unit
1221+
updated contact
12221222
12231223
"""
12241224

12251225
url = f"{self.endpoint}/v1/contacts/{contact_id}"
12261226
return self._patch(url, json={'data': {'attributes': params}}, headers=self._headers()).json()
12271227

12281228

1229+
def update_contact_finances(self,
1230+
contact_id,
1231+
account_name: str = None,
1232+
account_number: str = None,
1233+
routing_number: str = None,
1234+
tax_id: str = None,
1235+
tax_entity_name: str = None,
1236+
tax_form_code_id: int = 0):
1237+
1238+
"""
1239+
Update a contacts finances via connect.
1240+
https://connect.vacasa.com/#tag/Contacts/paths/~1v1~1contacts~1{id}~1finances/patch
1241+
1242+
Args:
1243+
contact_id: ID of the contact to update
1244+
account_name: Bank Account Name (<= 100 Chars)
1245+
account_number: Bank Account Number (<= 25 Chars)
1246+
routing_number: Bank Routing Number (<= 20 Chars)
1247+
tax_id: Tax Identification (<= 11 Chars)
1248+
tax_entity_name: Tax Name (<= 100 Chars)
1249+
tax_form_code_id:
1250+
1251+
1252+
Returns: None
1253+
Sensitve data.. no result (HTTP-204)
1254+
1255+
"""
1256+
return self.update_contact_finances_payload(contact_id, dict(
1257+
account_name=account_name,
1258+
account_number=account_number,
1259+
routing_number=routing_number,
1260+
tax_id=tax_id,
1261+
tax_entity_name=tax_entity_name,
1262+
tax_form_code_id=tax_form_code_id))
1263+
1264+
def update_contact_finances_payload(self, contact_id, params: dict):
1265+
1266+
"""
1267+
Update a contacts finances via connect.
1268+
https://connect.vacasa.com/#tag/Contacts/paths/~1v1~1contacts~1{id}~1finances/patch
1269+
1270+
Args:
1271+
contact_id: ID of the contact to update
1272+
params: A dict of key value pairs to update.
1273+
1274+
Returns: None
1275+
Sensitve data.. no result (HTTP-204)
1276+
1277+
"""
1278+
1279+
url = f"{self.endpoint}/v1/contacts/{contact_id}/finances"
1280+
return self._patch(url, json={'data': {'attributes': params}}, headers=self._headers()).json()
1281+
1282+
1283+
12291284
def _trip_protection_to_integer(trip_protection: bool) -> int:
12301285
"""Convert from True/False/None to 1/0/-1"""
12311286
if trip_protection is None:

0 commit comments

Comments
 (0)