diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 864c4e9..26d58e5 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -10,6 +10,7 @@ tremendous/exceptions.py tremendous/models/__init__.py tremendous/models/balance_transaction.py tremendous/models/campaign.py +tremendous/models/campaign_base.py tremendous/models/create_api_key200_response.py tremendous/models/create_campaign201_response.py tremendous/models/create_campaign_request.py @@ -65,6 +66,7 @@ tremendous/models/list_campaigns200_response_campaigns_inner_email_style.py tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.py tremendous/models/list_fields200_response.py tremendous/models/list_fields200_response_fields_inner.py +tremendous/models/list_forex_response.py tremendous/models/list_funding_sources200_response.py tremendous/models/list_funding_sources200_response_funding_sources_inner.py tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.py @@ -129,6 +131,8 @@ tremendous/models/reward_with_link_delivery.py tremendous/models/reward_without_link.py tremendous/models/reward_without_link_delivery.py tremendous/models/simulate_webhook_request.py +tremendous/models/update_campaign.py +tremendous/models/update_campaign_request.py tremendous/models/webhook.py tremendous/models/webhook_post.py tremendous/py.typed diff --git a/pyproject.toml b/pyproject.toml index 490d1f0..1a01a1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tremendous" -version = "3.0.0" +version = "3.1.0" long_description="Python API client for Tremendous" description = "Python API client for Tremendous" authors = ["API Support "] diff --git a/test-requirements.txt b/test-requirements.txt index 65f73d6..8e6d8cb 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,4 @@ -pytest~=7.4.4 +pytest~=7.1.3 pytest-cov>=2.8.1 pytest-randomly>=3.12.0 mypy>=1.4.1 diff --git a/tremendous/__init__.py b/tremendous/__init__.py index b86583e..c1bf979 100644 --- a/tremendous/__init__.py +++ b/tremendous/__init__.py @@ -34,6 +34,7 @@ # import models into sdk package from tremendous.models.balance_transaction import BalanceTransaction from tremendous.models.campaign import Campaign +from tremendous.models.campaign_base import CampaignBase from tremendous.models.create_api_key200_response import CreateApiKey200Response from tremendous.models.create_campaign201_response import CreateCampaign201Response from tremendous.models.create_campaign_request import CreateCampaignRequest @@ -89,6 +90,7 @@ from tremendous.models.list_campaigns200_response_campaigns_inner_webpage_style import ListCampaigns200ResponseCampaignsInnerWebpageStyle from tremendous.models.list_fields200_response import ListFields200Response from tremendous.models.list_fields200_response_fields_inner import ListFields200ResponseFieldsInner +from tremendous.models.list_forex_response import ListForexResponse from tremendous.models.list_funding_sources200_response import ListFundingSources200Response from tremendous.models.list_funding_sources200_response_funding_sources_inner import ListFundingSources200ResponseFundingSourcesInner from tremendous.models.list_funding_sources200_response_funding_sources_inner_meta import ListFundingSources200ResponseFundingSourcesInnerMeta @@ -153,5 +155,7 @@ from tremendous.models.reward_without_link import RewardWithoutLink from tremendous.models.reward_without_link_delivery import RewardWithoutLinkDelivery from tremendous.models.simulate_webhook_request import SimulateWebhookRequest +from tremendous.models.update_campaign import UpdateCampaign +from tremendous.models.update_campaign_request import UpdateCampaignRequest from tremendous.models.webhook import Webhook from tremendous.models.webhook_post import WebhookPost diff --git a/tremendous/api/tremendous_api.py b/tremendous/api/tremendous_api.py index 8718be5..976d511 100644 --- a/tremendous/api/tremendous_api.py +++ b/tremendous/api/tremendous_api.py @@ -44,6 +44,7 @@ from tremendous.models.list_balance_transactions200_response import ListBalanceTransactions200Response from tremendous.models.list_campaigns200_response import ListCampaigns200Response from tremendous.models.list_fields200_response import ListFields200Response +from tremendous.models.list_forex_response import ListForexResponse from tremendous.models.list_funding_sources200_response import ListFundingSources200Response from tremendous.models.list_invoices200_response import ListInvoices200Response from tremendous.models.list_members200_response import ListMembers200Response @@ -54,6 +55,7 @@ from tremendous.models.list_webhook_events200_response import ListWebhookEvents200Response from tremendous.models.list_webhooks200_response import ListWebhooks200Response from tremendous.models.simulate_webhook_request import SimulateWebhookRequest +from tremendous.models.update_campaign_request import UpdateCampaignRequest from tremendous.api_client import ApiClient, RequestSerialized from tremendous.api_response import ApiResponse @@ -6923,6 +6925,275 @@ def _list_fields_serialize( + @validate_call + def list_forex( + self, + base: Annotated[Optional[StrictStr], Field(description="Base currency code, default is USD.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ListForexResponse: + """List exchange rates + + Retrieve a list of exchange rates + + :param base: Base currency code, default is USD. + :type base: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_forex_serialize( + base=base, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListForexResponse", + '401': "ListRewards401Response", + '429': "ListRewards429Response", + '500': "ListRewards401Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def list_forex_with_http_info( + self, + base: Annotated[Optional[StrictStr], Field(description="Base currency code, default is USD.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ListForexResponse]: + """List exchange rates + + Retrieve a list of exchange rates + + :param base: Base currency code, default is USD. + :type base: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_forex_serialize( + base=base, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListForexResponse", + '401': "ListRewards401Response", + '429': "ListRewards429Response", + '500': "ListRewards401Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def list_forex_without_preload_content( + self, + base: Annotated[Optional[StrictStr], Field(description="Base currency code, default is USD.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List exchange rates + + Retrieve a list of exchange rates + + :param base: Base currency code, default is USD. + :type base: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_forex_serialize( + base=base, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListForexResponse", + '401': "ListRewards401Response", + '429': "ListRewards429Response", + '500': "ListRewards401Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _list_forex_serialize( + self, + base, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if base is not None: + + _query_params.append(('base', base)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'BearerApiKey' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/forex', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def list_funding_sources( self, @@ -10251,7 +10522,7 @@ def _simulate_webhook_serialize( def update_campaign( self, id: Annotated[str, Field(strict=True, description="ID of the campaign that should be updated")], - create_campaign_request: Annotated[CreateCampaignRequest, Field(description="Campaign details")], + update_campaign_request: Annotated[UpdateCampaignRequest, Field(description="Campaign details")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -10270,8 +10541,8 @@ def update_campaign( :param id: ID of the campaign that should be updated (required) :type id: str - :param create_campaign_request: Campaign details (required) - :type create_campaign_request: CreateCampaignRequest + :param update_campaign_request: Campaign details (required) + :type update_campaign_request: UpdateCampaignRequest :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -10296,7 +10567,7 @@ def update_campaign( _param = self._update_campaign_serialize( id=id, - create_campaign_request=create_campaign_request, + update_campaign_request=update_campaign_request, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -10325,7 +10596,7 @@ def update_campaign( def update_campaign_with_http_info( self, id: Annotated[str, Field(strict=True, description="ID of the campaign that should be updated")], - create_campaign_request: Annotated[CreateCampaignRequest, Field(description="Campaign details")], + update_campaign_request: Annotated[UpdateCampaignRequest, Field(description="Campaign details")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -10344,8 +10615,8 @@ def update_campaign_with_http_info( :param id: ID of the campaign that should be updated (required) :type id: str - :param create_campaign_request: Campaign details (required) - :type create_campaign_request: CreateCampaignRequest + :param update_campaign_request: Campaign details (required) + :type update_campaign_request: UpdateCampaignRequest :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -10370,7 +10641,7 @@ def update_campaign_with_http_info( _param = self._update_campaign_serialize( id=id, - create_campaign_request=create_campaign_request, + update_campaign_request=update_campaign_request, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -10399,7 +10670,7 @@ def update_campaign_with_http_info( def update_campaign_without_preload_content( self, id: Annotated[str, Field(strict=True, description="ID of the campaign that should be updated")], - create_campaign_request: Annotated[CreateCampaignRequest, Field(description="Campaign details")], + update_campaign_request: Annotated[UpdateCampaignRequest, Field(description="Campaign details")], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -10418,8 +10689,8 @@ def update_campaign_without_preload_content( :param id: ID of the campaign that should be updated (required) :type id: str - :param create_campaign_request: Campaign details (required) - :type create_campaign_request: CreateCampaignRequest + :param update_campaign_request: Campaign details (required) + :type update_campaign_request: UpdateCampaignRequest :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -10444,7 +10715,7 @@ def update_campaign_without_preload_content( _param = self._update_campaign_serialize( id=id, - create_campaign_request=create_campaign_request, + update_campaign_request=update_campaign_request, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -10468,7 +10739,7 @@ def update_campaign_without_preload_content( def _update_campaign_serialize( self, id, - create_campaign_request, + update_campaign_request, _request_auth, _content_type, _headers, @@ -10494,8 +10765,8 @@ def _update_campaign_serialize( # process the header parameters # process the form parameters # process the body parameter - if create_campaign_request is not None: - _body_params = create_campaign_request + if update_campaign_request is not None: + _body_params = update_campaign_request # set the HTTP header `Accept` diff --git a/tremendous/models/__init__.py b/tremendous/models/__init__.py index 3386bf1..ea0b1b3 100644 --- a/tremendous/models/__init__.py +++ b/tremendous/models/__init__.py @@ -17,6 +17,7 @@ # import models into model package from tremendous.models.balance_transaction import BalanceTransaction from tremendous.models.campaign import Campaign +from tremendous.models.campaign_base import CampaignBase from tremendous.models.create_api_key200_response import CreateApiKey200Response from tremendous.models.create_campaign201_response import CreateCampaign201Response from tremendous.models.create_campaign_request import CreateCampaignRequest @@ -72,6 +73,7 @@ from tremendous.models.list_campaigns200_response_campaigns_inner_webpage_style import ListCampaigns200ResponseCampaignsInnerWebpageStyle from tremendous.models.list_fields200_response import ListFields200Response from tremendous.models.list_fields200_response_fields_inner import ListFields200ResponseFieldsInner +from tremendous.models.list_forex_response import ListForexResponse from tremendous.models.list_funding_sources200_response import ListFundingSources200Response from tremendous.models.list_funding_sources200_response_funding_sources_inner import ListFundingSources200ResponseFundingSourcesInner from tremendous.models.list_funding_sources200_response_funding_sources_inner_meta import ListFundingSources200ResponseFundingSourcesInnerMeta @@ -136,5 +138,7 @@ from tremendous.models.reward_without_link import RewardWithoutLink from tremendous.models.reward_without_link_delivery import RewardWithoutLinkDelivery from tremendous.models.simulate_webhook_request import SimulateWebhookRequest +from tremendous.models.update_campaign import UpdateCampaign +from tremendous.models.update_campaign_request import UpdateCampaignRequest from tremendous.models.webhook import Webhook from tremendous.models.webhook_post import WebhookPost diff --git a/tremendous/models/campaign_base.py b/tremendous/models/campaign_base.py new file mode 100644 index 0000000..50dfa09 --- /dev/null +++ b/tremendous/models/campaign_base.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + API Endpoints + + Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + + The version of the OpenAPI document: 2 + Contact: developers@tremendous.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from tremendous.models.list_campaigns200_response_campaigns_inner_email_style import ListCampaigns200ResponseCampaignsInnerEmailStyle +from tremendous.models.list_campaigns200_response_campaigns_inner_webpage_style import ListCampaigns200ResponseCampaignsInnerWebpageStyle +from typing import Optional, Set +from typing_extensions import Self + +class CampaignBase(BaseModel): + """ + With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. + """ # noqa: E501 + id: Optional[Annotated[str, Field(strict=True)]] = None + name: Optional[StrictStr] = Field(default=None, description="Name of the campaign") + description: Optional[StrictStr] = Field(default=None, description="Description of the campaign") + products: Optional[List[Annotated[str, Field(strict=True)]]] = Field(default=None, description="List of IDs of products (different gift cards, charity, etc.) that are available in this campaign. ") + webpage_style: Optional[ListCampaigns200ResponseCampaignsInnerWebpageStyle] = None + email_style: Optional[ListCampaigns200ResponseCampaignsInnerEmailStyle] = None + __properties: ClassVar[List[str]] = ["id", "name", "description", "products", "webpage_style", "email_style"] + + @field_validator('id') + def id_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"[A-Z0-9]{4,20}", value): + raise ValueError(r"must validate the regular expression /[A-Z0-9]{4,20}/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CampaignBase from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * OpenAPI `readOnly` fields are excluded. + """ + excluded_fields: Set[str] = set([ + "id", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of webpage_style + if self.webpage_style: + _dict['webpage_style'] = self.webpage_style.to_dict() + # override the default output from pydantic by calling `to_dict()` of email_style + if self.email_style: + _dict['email_style'] = self.email_style.to_dict() + # set to None if description (nullable) is None + # and model_fields_set contains the field + if self.description is None and "description" in self.model_fields_set: + _dict['description'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CampaignBase from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "name": obj.get("name"), + "description": obj.get("description"), + "products": obj.get("products"), + "webpage_style": ListCampaigns200ResponseCampaignsInnerWebpageStyle.from_dict(obj["webpage_style"]) if obj.get("webpage_style") is not None else None, + "email_style": ListCampaigns200ResponseCampaignsInnerEmailStyle.from_dict(obj["email_style"]) if obj.get("email_style") is not None else None + }) + return _obj + + diff --git a/tremendous/models/list_forex_response.py b/tremendous/models/list_forex_response.py new file mode 100644 index 0000000..c2d0bef --- /dev/null +++ b/tremendous/models/list_forex_response.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + API Endpoints + + Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + + The version of the OpenAPI document: 2 + Contact: developers@tremendous.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class ListForexResponse(BaseModel): + """ + ListForexResponse + """ # noqa: E501 + forex: Dict[str, Union[StrictFloat, StrictInt]] + __properties: ClassVar[List[str]] = ["forex"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ListForexResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ListForexResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "forex": obj.get("forex") + }) + return _obj + + diff --git a/tremendous/models/update_campaign.py b/tremendous/models/update_campaign.py new file mode 100644 index 0000000..09ecd04 --- /dev/null +++ b/tremendous/models/update_campaign.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + API Endpoints + + Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + + The version of the OpenAPI document: 2 + Contact: developers@tremendous.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from tremendous.models.list_campaigns200_response_campaigns_inner_email_style import ListCampaigns200ResponseCampaignsInnerEmailStyle +from tremendous.models.list_campaigns200_response_campaigns_inner_webpage_style import ListCampaigns200ResponseCampaignsInnerWebpageStyle +from typing import Optional, Set +from typing_extensions import Self + +class UpdateCampaign(BaseModel): + """ + With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. + """ # noqa: E501 + id: Optional[Annotated[str, Field(strict=True)]] = None + name: Optional[StrictStr] = Field(default=None, description="Name of the campaign") + description: Optional[StrictStr] = Field(default=None, description="Description of the campaign") + products: Optional[List[Annotated[str, Field(strict=True)]]] = Field(default=None, description="List of IDs of products (different gift cards, charity, etc.) that are available in this campaign. ") + webpage_style: Optional[ListCampaigns200ResponseCampaignsInnerWebpageStyle] = None + email_style: Optional[ListCampaigns200ResponseCampaignsInnerEmailStyle] = None + __properties: ClassVar[List[str]] = ["id", "name", "description", "products", "webpage_style", "email_style"] + + @field_validator('id') + def id_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"[A-Z0-9]{4,20}", value): + raise ValueError(r"must validate the regular expression /[A-Z0-9]{4,20}/") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UpdateCampaign from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * OpenAPI `readOnly` fields are excluded. + """ + excluded_fields: Set[str] = set([ + "id", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of webpage_style + if self.webpage_style: + _dict['webpage_style'] = self.webpage_style.to_dict() + # override the default output from pydantic by calling `to_dict()` of email_style + if self.email_style: + _dict['email_style'] = self.email_style.to_dict() + # set to None if description (nullable) is None + # and model_fields_set contains the field + if self.description is None and "description" in self.model_fields_set: + _dict['description'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UpdateCampaign from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "name": obj.get("name"), + "description": obj.get("description"), + "products": obj.get("products"), + "webpage_style": ListCampaigns200ResponseCampaignsInnerWebpageStyle.from_dict(obj["webpage_style"]) if obj.get("webpage_style") is not None else None, + "email_style": ListCampaigns200ResponseCampaignsInnerEmailStyle.from_dict(obj["email_style"]) if obj.get("email_style") is not None else None + }) + return _obj + + diff --git a/tremendous/models/update_campaign_request.py b/tremendous/models/update_campaign_request.py new file mode 100644 index 0000000..978bd32 --- /dev/null +++ b/tremendous/models/update_campaign_request.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + API Endpoints + + Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API. + + The version of the OpenAPI document: 2 + Contact: developers@tremendous.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from tremendous.models.list_campaigns200_response_campaigns_inner_email_style import ListCampaigns200ResponseCampaignsInnerEmailStyle +from tremendous.models.list_campaigns200_response_campaigns_inner_webpage_style import ListCampaigns200ResponseCampaignsInnerWebpageStyle +from typing import Optional, Set +from typing_extensions import Self + +class UpdateCampaignRequest(BaseModel): + """ + With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. + """ # noqa: E501 + name: Optional[StrictStr] = Field(default=None, description="Name of the campaign") + description: Optional[StrictStr] = Field(default=None, description="Description of the campaign") + products: Optional[List[Annotated[str, Field(strict=True)]]] = Field(default=None, description="List of IDs of products (different gift cards, charity, etc.) that are available in this campaign. ") + webpage_style: Optional[ListCampaigns200ResponseCampaignsInnerWebpageStyle] = None + email_style: Optional[ListCampaigns200ResponseCampaignsInnerEmailStyle] = None + __properties: ClassVar[List[str]] = ["name", "description", "products", "webpage_style", "email_style"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UpdateCampaignRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of webpage_style + if self.webpage_style: + _dict['webpage_style'] = self.webpage_style.to_dict() + # override the default output from pydantic by calling `to_dict()` of email_style + if self.email_style: + _dict['email_style'] = self.email_style.to_dict() + # set to None if description (nullable) is None + # and model_fields_set contains the field + if self.description is None and "description" in self.model_fields_set: + _dict['description'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UpdateCampaignRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name"), + "description": obj.get("description"), + "products": obj.get("products"), + "webpage_style": ListCampaigns200ResponseCampaignsInnerWebpageStyle.from_dict(obj["webpage_style"]) if obj.get("webpage_style") is not None else None, + "email_style": ListCampaigns200ResponseCampaignsInnerEmailStyle.from_dict(obj["email_style"]) if obj.get("email_style") is not None else None + }) + return _obj + + diff --git a/tremendous/version.py b/tremendous/version.py index 4eb28e3..7f5601d 100644 --- a/tremendous/version.py +++ b/tremendous/version.py @@ -1 +1 @@ -__version__ = '3.0.0' +__version__ = '3.1.0'