sky-api-client 3.3.7__tar.gz → 3.3.8__tar.gz
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.
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/PKG-INFO +1 -1
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/setup.py +1 -1
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/education.py +57 -2
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client.egg-info/PKG-INFO +1 -1
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/README.md +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/pyproject.toml +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/setup.cfg +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/__init__.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/client.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/common/__init__.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/common/tasks/__init__.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/common/tasks/asyncio.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/__init__.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/action.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/action_custom_field.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/action_status.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/address.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/base.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/code_table.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_address.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_code.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_custom_field.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_education.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_email_address.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_online_presence.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_phone.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_relationship.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_solicit_code.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/custom_field.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/custom_field_categories.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/email_addresses.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_fee.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_donation.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_fee.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_fee_payment.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_levels.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participation_levels.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/fundraising_appeal.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/fundraising_campaign.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/fundraising_fund.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/fundraising_package.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gender.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_aid.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_batch.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_batch_gift.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_batch_gift_v2.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_custom_field_values.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_custom_fields.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_subtype.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/list.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/online_presence.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/phone.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/registry.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/relationship.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/solicit_code.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/suffix.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/table_entry.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/title.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/webhook_subscription.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/exceptions/__init__.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/exceptions/exception.py +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client.egg-info/SOURCES.txt +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client.egg-info/dependency_links.txt +0 -0
- {sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client.egg-info/top_level.txt +0 -0
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
|
|
3
|
+
import six
|
|
4
|
+
import re
|
|
1
5
|
from sky_api_client.entity.base import Entity
|
|
2
6
|
from sky_api_client.entity.registry import EntityRegistry
|
|
3
7
|
from sky_api_client.exceptions.exception import MethodNotDefined
|
|
4
8
|
from urllib.parse import quote_plus
|
|
5
9
|
|
|
6
10
|
|
|
11
|
+
def slugify_underscore(name):
|
|
12
|
+
"""Return slug for the given name i.e. replace any non alphanumeric character with underscore."""
|
|
13
|
+
if name is None or not isinstance(name, six.text_type):
|
|
14
|
+
return None
|
|
15
|
+
|
|
16
|
+
name = name.strip().lower()
|
|
17
|
+
# Any non word characters (letters, digits, and underscores) are replaced by '-'
|
|
18
|
+
name = re.sub(r'\W+', '_', name)
|
|
19
|
+
# Removing any trailing or leading dash
|
|
20
|
+
name = re.sub(r'^[-_]|[-_]$', '', name)
|
|
21
|
+
# Replace multiple continuous hipens with one
|
|
22
|
+
name = re.sub('[-_]+', '_', name)
|
|
23
|
+
return name
|
|
24
|
+
|
|
25
|
+
|
|
7
26
|
@EntityRegistry.register('education')
|
|
8
27
|
class Education(Entity):
|
|
9
28
|
LIST_URL = '/constituent/v1/educations/'
|
|
@@ -14,6 +33,31 @@ class Education(Entity):
|
|
|
14
33
|
SUBJECTS_URL = '/constituent/v1/educations/subjects'
|
|
15
34
|
DEGREES_URL = '/constituent/v1/educations/degrees'
|
|
16
35
|
|
|
36
|
+
def add_custom_field_entries(self, education_id, data):
|
|
37
|
+
sky_api_ed_client = EducationCustomField(self._api)
|
|
38
|
+
already_present = {}
|
|
39
|
+
for entry in sky_api_ed_client.custom_fields(education_id):
|
|
40
|
+
ed_custom_field_slug = slugify_underscore(entry['category'])
|
|
41
|
+
if ed_custom_field_slug in data:
|
|
42
|
+
if entry['value'] in (data.get(ed_custom_field_slug) or []):
|
|
43
|
+
already_present.setdefault(ed_custom_field_slug, [])
|
|
44
|
+
already_present[ed_custom_field_slug].append(entry['value'])
|
|
45
|
+
else:
|
|
46
|
+
sky_api_ed_client.delete(entry['id'], parent_id=education_id)
|
|
47
|
+
|
|
48
|
+
ed_custom_fields_names = [field['name'] for field in sky_api_ed_client.list(id=education_id)['value']]
|
|
49
|
+
for ed_custom_field in ed_custom_fields_names:
|
|
50
|
+
ed_custom_field_slug = slugify_underscore(ed_custom_field)
|
|
51
|
+
for value in data.get(ed_custom_field_slug) or []:
|
|
52
|
+
if value not in already_present.get(ed_custom_field_slug, []):
|
|
53
|
+
sky_api_ed_client.create(
|
|
54
|
+
{
|
|
55
|
+
'value': value,
|
|
56
|
+
'category': ed_custom_field,
|
|
57
|
+
'parent_id': education_id,
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
|
|
17
61
|
def subjects(self):
|
|
18
62
|
if self.SUBJECTS_URL:
|
|
19
63
|
return self._api.request(method='GET', path=self.SUBJECTS_URL).get('value', [])
|
|
@@ -24,13 +68,24 @@ class Education(Entity):
|
|
|
24
68
|
return self._api.request(method='GET', path=self.DEGREES_URL).get('value', [])
|
|
25
69
|
raise MethodNotDefined('degrees')
|
|
26
70
|
|
|
71
|
+
def create(self, data: Dict[str, str], id=''):
|
|
72
|
+
response = super().create(data=data, id=id)
|
|
73
|
+
if isinstance(response, dict) and response.get('id'):
|
|
74
|
+
self.add_custom_field_entries(response['id'], data)
|
|
75
|
+
return response
|
|
76
|
+
|
|
77
|
+
def update(self, id: str, data: Dict[str, str], parent_id=''):
|
|
78
|
+
response = super().update(id=id, data=data, parent_id=parent_id)
|
|
79
|
+
self.add_custom_field_entries(id, data)
|
|
80
|
+
return response
|
|
81
|
+
|
|
27
82
|
|
|
28
83
|
@EntityRegistry.register('education_custom_field')
|
|
29
84
|
class EducationCustomField(Entity):
|
|
30
85
|
LIST_URL = 'constituent/v1/educations/customfields/categories/details?limit=5000'
|
|
31
86
|
CREATE_URL = 'constituent/v1/educations/customfields'
|
|
32
|
-
DELETE_URL = 'constituent/v1/educations/customfields/{
|
|
33
|
-
UPDATE_URL = 'constituent/v1/educations/customfields/{
|
|
87
|
+
DELETE_URL = 'constituent/v1/educations/customfields/{id}'
|
|
88
|
+
UPDATE_URL = 'constituent/v1/educations/customfields/{id}'
|
|
34
89
|
CUSTOM_FIELDS_URL = 'constituent/v1/educations/{education_id}/customfields'
|
|
35
90
|
CUSTOM_FIELD_CATEGORIES_CODE_TABLE_URL = 'constituent/v1/educations/customfields/categories/values?category_name={}'
|
|
36
91
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_custom_field.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_education.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_email_address.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_online_presence.py
RENAMED
|
File without changes
|
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_relationship.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/constituent_solicit_code.py
RENAMED
|
File without changes
|
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/custom_field_categories.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_donation.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_fee.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_fee_payment.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participant_levels.py
RENAMED
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/event_participation_levels.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sky_api_client-3.3.7 → sky_api_client-3.3.8}/sky_api_client/entity/gift_custom_field_values.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|