sky-api-client 3.3.7__tar.gz → 3.3.9__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.
Files changed (68) hide show
  1. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/PKG-INFO +3 -3
  2. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/setup.py +3 -3
  3. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/base.py +2 -2
  4. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/education.py +57 -2
  5. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client.egg-info/PKG-INFO +3 -3
  6. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/README.md +0 -0
  7. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/pyproject.toml +0 -0
  8. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/setup.cfg +0 -0
  9. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/__init__.py +0 -0
  10. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/client.py +0 -0
  11. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/common/__init__.py +0 -0
  12. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/common/tasks/__init__.py +0 -0
  13. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/common/tasks/asyncio.py +0 -0
  14. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/__init__.py +0 -0
  15. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/action.py +0 -0
  16. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/action_custom_field.py +0 -0
  17. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/action_status.py +0 -0
  18. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/address.py +0 -0
  19. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/code_table.py +0 -0
  20. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent.py +0 -0
  21. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_address.py +0 -0
  22. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_code.py +0 -0
  23. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_custom_field.py +0 -0
  24. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_education.py +0 -0
  25. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_email_address.py +0 -0
  26. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_online_presence.py +0 -0
  27. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_phone.py +0 -0
  28. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_relationship.py +0 -0
  29. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/constituent_solicit_code.py +0 -0
  30. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/custom_field.py +0 -0
  31. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/custom_field_categories.py +0 -0
  32. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/email_addresses.py +0 -0
  33. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event.py +0 -0
  34. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event_fee.py +0 -0
  35. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event_participant.py +0 -0
  36. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event_participant_donation.py +0 -0
  37. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event_participant_fee.py +0 -0
  38. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event_participant_fee_payment.py +0 -0
  39. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event_participant_levels.py +0 -0
  40. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/event_participation_levels.py +0 -0
  41. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/fundraising_appeal.py +0 -0
  42. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/fundraising_campaign.py +0 -0
  43. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/fundraising_fund.py +0 -0
  44. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/fundraising_package.py +0 -0
  45. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gender.py +0 -0
  46. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift.py +0 -0
  47. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift_aid.py +0 -0
  48. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift_batch.py +0 -0
  49. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift_batch_gift.py +0 -0
  50. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift_batch_gift_v2.py +0 -0
  51. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift_custom_field_values.py +0 -0
  52. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift_custom_fields.py +0 -0
  53. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/gift_subtype.py +0 -0
  54. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/list.py +0 -0
  55. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/online_presence.py +0 -0
  56. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/phone.py +0 -0
  57. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/registry.py +0 -0
  58. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/relationship.py +0 -0
  59. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/solicit_code.py +0 -0
  60. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/suffix.py +0 -0
  61. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/table_entry.py +0 -0
  62. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/title.py +0 -0
  63. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/entity/webhook_subscription.py +0 -0
  64. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/exceptions/__init__.py +0 -0
  65. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client/exceptions/exception.py +0 -0
  66. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client.egg-info/SOURCES.txt +0 -0
  67. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client.egg-info/dependency_links.txt +0 -0
  68. {sky_api_client-3.3.7 → sky_api_client-3.3.9}/sky_api_client.egg-info/top_level.txt +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sky_api_client
3
- Version: 3.3.7
3
+ Version: 3.3.9
4
4
  Summary: Python client for RENXT APIs
5
5
  Home-page: https://bitbucket.org/kalyanvarma/skyapi
6
- Author: Rajeev K L
7
- Author-email: rajeev@almabase.com
6
+ Author: Almabase Engineering
7
+ Author-email: engineering@almabase.com
8
8
  License: UNKNOWN
9
9
  Description: # Sky Api Client
10
10
 
@@ -5,9 +5,9 @@ with open('README.md', 'r', encoding='utf-8') as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name='sky_api_client',
8
- version='3.3.7',
9
- author='Rajeev K L',
10
- author_email='rajeev@almabase.com',
8
+ version='3.3.9',
9
+ author='Almabase Engineering',
10
+ author_email='engineering@almabase.com',
11
11
  description='Python client for RENXT APIs',
12
12
  long_description=long_description,
13
13
  long_description_content_type='text/markdown',
@@ -36,9 +36,9 @@ class Entity(object):
36
36
  return self._api.request(method='GET', path=self.GET_URL.format(id=id, parent_id=parent_id))
37
37
  raise MethodNotDefined('Get')
38
38
 
39
- def create(self, data: Dict[str, str], id=''):
39
+ def create(self, data: Dict[str, str], id='', params=None):
40
40
  if self.CREATE_URL:
41
- return self._api.request(method='POST', path=self.CREATE_URL.format(id=id), data=data)
41
+ return self._api.request(method='POST', path=self.CREATE_URL.format(id=id), data=data, params=params)
42
42
  raise MethodNotDefined('Create')
43
43
 
44
44
  def update(self, id: str, data: Dict[str, str], parent_id=''):
@@ -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/{custom_field_id}'
33
- UPDATE_URL = 'constituent/v1/educations/customfields/{custom_field_id}'
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
 
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sky-api-client
3
- Version: 3.3.7
3
+ Version: 3.3.9
4
4
  Summary: Python client for RENXT APIs
5
5
  Home-page: https://bitbucket.org/kalyanvarma/skyapi
6
- Author: Rajeev K L
7
- Author-email: rajeev@almabase.com
6
+ Author: Almabase Engineering
7
+ Author-email: engineering@almabase.com
8
8
  License: UNKNOWN
9
9
  Description: # Sky Api Client
10
10
 
File without changes
File without changes