-
Notifications
You must be signed in to change notification settings - Fork 9
Add missing features and new endpoints #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ca0bf7a
6daf595
383f43a
0b7a467
c445577
51a3bee
53f9aaf
53719fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,13 +31,54 @@ class _Schema(Schema): | |
| retracted_event_id = fields.String(allow_none=True) | ||
| external_id = fields.String(allow_none=True) | ||
| event_order = fields.Int(allow_none=True) | ||
| disabled = fields.Bool(allow_none=True) | ||
|
|
||
| @post_load | ||
| def make(self, data, **kwargs): | ||
| return SubscriptionEvent(**data) | ||
|
|
||
| _schema = _Schema(unknown=EXCLUDE) | ||
|
|
||
| @classmethod | ||
| def destroy(cls, config, **kwargs): | ||
| """Accept flat params and wrap in subscription_event envelope for the API.""" | ||
| data = dict(kwargs.get("data", {})) | ||
| if "subscription_event" not in data: | ||
| data = {"subscription_event": data} | ||
| return cls.destroy_with_params(config, data=data) | ||
|
|
||
| @classmethod | ||
| def modify(cls, config, **kwargs): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [question] Why do you have to implement modify here, if it's already defined in resource? Can't you do something like |
||
| """Accept flat params and wrap in subscription_event envelope for the API.""" | ||
| data = dict(kwargs.get("data", {})) | ||
| if "subscription_event" not in data: | ||
| data = {"subscription_event": data} | ||
| return cls.modify_with_params(config, data=data) | ||
|
|
||
| @classmethod | ||
| def disable(cls, config, **kwargs): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [question] Shouldn't this be defined in |
||
| """Disable a subscription event by setting disabled to true.""" | ||
| data = dict(kwargs.get("data", {})) | ||
| if "subscription_event" in data: | ||
| data = {"subscription_event": dict(data["subscription_event"])} | ||
| data["subscription_event"]["disabled"] = True | ||
| else: | ||
| data["disabled"] = True | ||
| data = {"subscription_event": data} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [question] Same here. |
||
| return cls.modify_with_params(config, data=data) | ||
|
|
||
| @classmethod | ||
| def enable(cls, config, **kwargs): | ||
| """Enable a subscription event by setting disabled to false.""" | ||
| data = dict(kwargs.get("data", {})) | ||
| if "subscription_event" in data: | ||
| data = {"subscription_event": dict(data["subscription_event"])} | ||
| data["subscription_event"]["disabled"] = False | ||
| else: | ||
| data["disabled"] = False | ||
| data = {"subscription_event": data} | ||
| return cls.modify_with_params(config, data=data) | ||
|
|
||
|
|
||
| SubscriptionEvent.all = SubscriptionEvent._method("all", "get", "/subscription_events") | ||
| SubscriptionEvent.destroy_with_params = SubscriptionEvent._method( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,7 +174,7 @@ def _expandPath(cls, path, kwargs): | |
| def _validate_arguments(cls, method, kwargs): | ||
| # This enforces user to pass argument, otherwise we could call | ||
| # wrong URL. | ||
| if method in ["destroy", "cancel", "retrieve", "modify", "update"] and "uuid" not in kwargs: | ||
| if method in ["destroy", "cancel", "retrieve", "modify", "update", "disable"] and "uuid" not in kwargs: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [question] Shouldn't it also include |
||
| raise ArgumentMissingError("Please pass 'uuid' parameter") | ||
| if method in ["create", "modify"] and "data" not in kwargs: | ||
| raise ArgumentMissingError("Please pass 'data' parameter") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] This seems a bit complicated. Is this pattern used anywhere else in the code?