Repository: saleor/saleor

Issue:
Object of type AvataxConfiguration is not JSON serializable
### What I'm trying to achieve
Run avalara celery task

### Steps to reproduce the problem
1. Activate avalara plugin, fill credentials
2. create checkout and place order
3. check logs

### What I expected to happen
Request to avalara is send

### Screenshots
```
web_1         | Traceback (most recent call last):
web_1         |   File "/usr/local/lib/python3.8/site-packages/promise/promise.py", line 489, in _resolve_from_executor
web_1         |     executor(resolve, reject)
web_1         |   File "/usr/local/lib/python3.8/site-packages/promise/promise.py", line 756, in executor
web_1         |     return resolve(f(*args, **kwargs))
web_1         |   File "/usr/local/lib/python3.8/site-packages/graphql/execution/middleware.py", line 75, in make_it_promise
web_1         |     return next(*args, **kwargs)
web_1         |   File "/app/saleor/graphql/core/mutations.py", line 284, in mutate
web_1         |     response = cls.perform_mutation(root, info, **data)
web_1         |   File "/app/saleor/graphql/checkout/mutations.py", line 777, in perform_mutation
web_1         |     order = create_order(
web_1         |   File "/usr/local/lib/python3.8/contextlib.py", line 75, in inner
web_1         |     return func(*args, **kwds)
web_1         |   File "/app/saleor/checkout/utils.py", line 758, in create_order
web_1         |     order_created(order=order, user=user)
web_1         |   File "/app/saleor/order/actions.py", line 34, in order_created
web_1         |     manager.order_created(order)
web_1         |   File "/app/saleor/extensions/manager.py", line 215, in order_created
web_1         |     return self.__run_method_on_plugins("order_created", default_value, order)
web_1         |   File "/app/saleor/extensions/manager.py", line 56, in __run_method_on_plugins
web_1         |     value = self.__run_method_on_single_plugin(
web_1         |   File "/app/saleor/extensions/manager.py", line 79, in __run_method_on_single_plugin
web_1         |     returned_value = plugin_method(*args, **kwargs, previous_value=previous_value)
web_1         |   File "/app/saleor/extensions/plugins/avatax/plugin.py", line 258, in order_created
web_1         |     api_post_request_task.delay(transaction_url, data, self.config)
web_1         |   File "/usr/local/lib/python3.8/site-packages/celery/app/task.py", line 425, in delay
web_1         |     return self.apply_async(args, kwargs)
web_1         |   File "/usr/local/lib/python3.8/site-packages/celery/app/task.py", line 564, in apply_async
web_1         |     return app.send_task(
web_1         |   File "/usr/local/lib/python3.8/site-packages/celery/app/base.py", line 775, in send_task
web_1         |     amqp.send_task_message(P, name, message, **options)
web_1         |   File "/usr/local/lib/python3.8/site-packages/celery/app/amqp.py", line 550, in send_task_message
web_1         |     ret = producer.publish(
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/messaging.py", line 167, in publish
web_1         |     body, content_type, content_encoding = self._prepare(
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/messaging.py", line 252, in _prepare
web_1         |     body) = dumps(body, serializer=serializer)
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/serialization.py", line 221, in dumps
web_1         |     payload = encoder(data)
web_1         |   File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
web_1         |     self.gen.throw(type, value, traceback)
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/serialization.py", line 54, in _reraise_errors
web_1         |     reraise(wrapper, wrapper(exc), sys.exc_info()[2])
web_1         |   File "/usr/local/lib/python3.8/site-packages/vine/five.py", line 194, in reraise
web_1         |     raise value.with_traceback(tb)
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/serialization.py", line 50, in _reraise_errors
web_1         |     yield
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/serialization.py", line 221, in dumps
web_1         |     payload = encoder(data)
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/utils/json.py", line 69, in dumps
web_1         |     return _dumps(s, cls=cls or _default_encoder,
web_1         |   File "/usr/local/lib/python3.8/json/__init__.py", line 234, in dumps
web_1         |     return cls(
web_1         |   File "/usr/local/lib/python3.8/json/encoder.py", line 199, in encode
web_1         |     chunks = self.iterencode(o, _one_shot=True)
web_1         |   File "/usr/local/lib/python3.8/json/encoder.py", line 257, in iterencode
web_1         |     return _iterencode(o, 0)
web_1         |   File "/usr/local/lib/python3.8/site-packages/kombu/utils/json.py", line 59, in default
web_1         |     return super(JSONEncoder, self).default(o)
web_1         |   File "/usr/local/lib/python3.8/json/encoder.py", line 179, in default
web_1         |     raise TypeError(f'Object of type {o.__class__.__name__} '
web_1         | kombu.exceptions.EncodeError: Object of type AvataxConfiguration is not JSON serializable
```

**System information**
Operating system:



Discussion:

Resolving patch:
diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.py
--- a/saleor/plugins/avatax/plugin.py
+++ b/saleor/plugins/avatax/plugin.py
@@ -1,4 +1,5 @@
 import logging
+from dataclasses import asdict
 from decimal import Decimal
 from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Union
 from urllib.parse import urljoin
@@ -254,7 +255,7 @@ def order_created(self, order: "Order", previous_value: Any) -> Any:
         transaction_url = urljoin(
             get_api_url(self.config.use_sandbox), "transactions/createoradjust"
         )
-        api_post_request_task.delay(transaction_url, data, self.config)
+        api_post_request_task.delay(transaction_url, data, asdict(self.config))
         return previous_value
 
     def calculate_checkout_line_total(
diff --git a/saleor/plugins/avatax/tasks.py b/saleor/plugins/avatax/tasks.py
--- a/saleor/plugins/avatax/tasks.py
+++ b/saleor/plugins/avatax/tasks.py
@@ -1,7 +1,8 @@
 from ...celeryconf import app
-from . import api_post_request
+from . import AvataxConfiguration, api_post_request
 
 
 @app.task
 def api_post_request_task(transaction_url, data, config):
+    config = AvataxConfiguration(**config)
     api_post_request(transaction_url, data, config)


Test patch: