Skip to content

Commit 158965f

Browse files
committed
Revert "Upgrade api version to v2 (#132)"
This reverts commit 5e51412.
1 parent 00918bb commit 158965f

8 files changed

Lines changed: 13 additions & 36 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# Changelog
22

3-
## 4.4.1
4-
* Replace /users with /branches endpoint [#133](https://github.com/singer-io/tap-mambu/pull/133)
5-
6-
## 4.4.0
7-
* Update the access_check to use the v2 `/users` endpoint instead of the v1 `/settings/organization` endpoint. [#132](https://github.com/singer-io/tap-mambu/pull/132)
8-
* Replace the v1 `/settings/organization` endpoint with `/setup/organization` to retrieve timezone information.
9-
* Add support for the `timezone` new config property
10-
* The `/setup/organization` endpoint requires admin permissions. If admin credentials are not provided, the timezone config value will be used as a fallback.
113
## 4.3.1
124
* Bump dependency versions for twistlock compliance [#124](https://github.com/singer-io/tap-mambu/pull/123)
135

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,12 @@ This tap:
255255
"user_agent": "tap-mambu <api_user_email@your_company.com>",
256256
"page_size": "500",
257257
"apikey_audit": "AUDIT_TRAIL_APIKEY",
258-
"window_size": 7,
259-
"timezone": "US/Pacific"
258+
"window_size": 7
260259
}
261260
```
262261
263262
Note: The `window_size` parameter defaults to 1 day, which may cause slowdowns in historical sync for streams utilizing multi-threaded implementation. Conversely, using a larger `window_size` could lead to potential `out-of-memory` issues. It is advisable to select an optimal `window_size` based on the `start_date` and volume of data to mitigate these concerns.
264263
265-
The `timezone` represents your organization's local timezone. To find the [timezone](https://support.mambu.com/docs/organization-contact-currency-and-timezone) information, go to the main menu and go to Administration > General Setup > Organization Details > Time Zone
266-
267264
Optionally, also create a `state.json` file. `currently_syncing` is an optional attribute used for identifying the last object to be synced in case the job is interrupted mid-stream. The next run would begin where the last job left off.
268265
269266
```json

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55
setup(name='tap-mambu',
6-
version='4.4.1',
6+
version='4.3.1',
77
description='Singer.io tap for extracting data from the Mambu 2.0 API',
88
author='jeff.huth@bytecode.io',
99
classifiers=['Programming Language :: Python :: 3 :: Only'],

tap_mambu/helpers/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ def check_access(self):
168168
headers = {}
169169
# Endpoint: simple API call to return a single record (org settings) to test access
170170
# https://support.mambu.com/docs/organisational-settings-api#get-organisational-settings
171-
endpoint = 'branches'
171+
endpoint = 'settings/organization'
172172
url = '{}/{}'.format(self.base_url, endpoint)
173173
headers['User-Agent'] = self.__user_agent
174-
headers['Accept'] = 'application/vnd.mambu.v2+json'
174+
headers['Accept'] = 'application/vnd.mambu.v1+json'
175175
if use_apikey:
176176
# Api Key API Consumer Authentication: https://support.mambu.com/docs/api-consumers
177177
self.__session.headers['apikey'] = self.__apikey

tap_mambu/helpers/datetime_utils.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import singer
21
from pytz import timezone
32
from datetime import datetime
43
from tap_mambu import MambuClient
5-
from tap_mambu.helpers.client import MambuForbiddenError
64
import dateutil.parser
75

8-
LOGGER = singer.get_logger()
9-
106

117
_timezone = None
128
_datetime_formats = [
@@ -26,18 +22,11 @@
2622
]
2723

2824

29-
def get_timezone_info(client: MambuClient, config_timezone: str = None):
25+
def get_timezone_info(client: MambuClient):
3026
global _timezone
31-
try:
32-
response = client.request(method="GET", path="setup/organization", version="v2")
33-
_timezone = timezone(response.get("timeZoneID"))
34-
except MambuForbiddenError:
35-
if config_timezone:
36-
LOGGER.warning("Could not get timezone information from Mambu endpoint, using config timezone")
37-
_timezone = timezone(config_timezone)
38-
else:
39-
raise RuntimeError("Unable to retrieve timezone information from the Mambu endpoint. Please provide administrator credentials or configure valid timezone in the UI(e.g., US/Pacific)." \
40-
" Refer this for more details: https://support.mambu.com/docs/organization-contact-currency-and-timezone")
27+
response = client.request(method="GET", path="settings/organization", version="v1")
28+
_timezone = timezone(response.get("timeZoneID"))
29+
4130

4231
def localize(dttm: datetime) -> datetime:
4332
if _timezone is None:

tap_mambu/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def sync_all_streams(client, config, catalog, state):
3535
from .tap_generators.child_generator import ChildGenerator
3636
from .tap_processors.child_processor import ChildProcessor
3737

38-
get_timezone_info(client, config_timezone=config.get("timezone"))
38+
get_timezone_info(client)
3939

4040
selected_streams = get_selected_streams(catalog)
4141
LOGGER.info('selected_streams: {}'.format(selected_streams))

tests/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ def get_properties(self, original_properties=True):
250250
'username': os.environ['TAP_MAMBU_USERNAME'],
251251
'subdomain': os.environ['TAP_MAMBU_SUBDOMAIN'],
252252
'page_size': '90',
253-
'timezone': 'US/Pacific',
254253
'window_size': 30
255254
}
256255

tests/unittests/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def test_client_check_access_api_key(mock_requests_session_get):
5353
assert client.base_url == base_url
5454
assert client.page_size == DEFAULT_PAGE_SIZE
5555

56-
mock_requests_session_get.assert_called_once_with(url=f'{base_url}/branches',
57-
headers={'Accept': 'application/vnd.mambu.v2+json',
56+
mock_requests_session_get.assert_called_once_with(url=f'{base_url}/settings/organization',
57+
headers={'Accept': 'application/vnd.mambu.v1+json',
5858
'User-Agent': 'MambuTap-User_Agent_Test'})
5959

6060

@@ -77,8 +77,8 @@ def test_client_check_access_user_pass(mock_requests_session_get):
7777
assert client.base_url == base_url
7878
assert client.page_size == 100
7979

80-
mock_requests_session_get.assert_called_once_with(url=f'{base_url}/branches',
81-
headers={'Accept': 'application/vnd.mambu.v2+json',
80+
mock_requests_session_get.assert_called_once_with(url=f'{base_url}/settings/organization',
81+
headers={'Accept': 'application/vnd.mambu.v1+json',
8282
'User-Agent': 'MambuTap'})
8383

8484

0 commit comments

Comments
 (0)