Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions fulfil_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
from functools import wraps

import requests
from more_itertools import chunked
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from more_itertools import chunked
from .serialization import dumps, loads

from .exceptions import (
UserError,
ClientError,
ServerError,
AuthenticationError,
ClientError,
Error, # noqa
RateLimitError,
ServerError,
UserError,
)
from .serialization import dumps, loads
from .signals import response_received
from .exceptions import Error # noqa


request_logger = logging.getLogger("fulfil_client.request")

Expand Down Expand Up @@ -322,9 +322,7 @@ def create(self, context=None):
ctx = self.client.context.copy()
ctx.update(context or {})
request_logger.debug("Wizard::%s.create" % (self.wizard_name,))
rv = self.client.session.put(
self.path + "/create", dumps([ctx]),
)
rv = self.client.session.put(self.path + "/create", dumps([ctx]))
# Call response signal
return rv

Expand Down Expand Up @@ -371,9 +369,15 @@ def proxy_method(*args, **kwargs):
request_logger.debug(
"%s.%s::%s::%s" % (self.model_name, name, args, kwargs)
)
rv = self.client.session.put(
http_method = (
"QUERY"
if name in ("search", "read", "search_read", "search_count")
else "PUT"
)
rv = self.client.session.request(
http_method,
self.path + "/%s" % name,
dumps(args),
data=dumps(args),
params={
"context": dumps(context),
},
Expand Down
6 changes: 3 additions & 3 deletions fulfil_client/serialization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: UTF-8 -*-
import datetime
from decimal import Decimal
from collections import namedtuple
from decimal import Decimal
from functools import partial

import isodate

try:
Expand All @@ -11,7 +12,6 @@
import json
import base64


CONTENT_TYPE = "application/vnd.fulfil.v3+json"


Expand Down Expand Up @@ -79,7 +79,7 @@ def timedelta_decoder(v):

@register_decoder("bytes")
def _bytes_decoder(v):
cast = bytearray if bytes == str else bytes
cast = bytearray if bytes is str else bytes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return cast(base64.decodebytes(v["base64"].encode("utf-8")))


Expand Down
Loading