Skip to content

Commit c530054

Browse files
committed
Blacken main source.
1 parent b102d4c commit c530054

File tree

1 file changed

+73
-21
lines changed

1 file changed

+73
-21
lines changed

nexmo/__init__.py

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ def __init__(
8686

8787
self.api_host = "api.nexmo.com"
8888

89-
user_agent = "nexmo-python/{version}/{python_version}".format(version=__version__, python_version=python_version())
89+
user_agent = "nexmo-python/{version}/{python_version}".format(
90+
version=__version__, python_version=python_version()
91+
)
9092

9193
if app_name and app_version:
92-
user_agent += "/{app_name}/{app_version}".format(app_name=app_name, app_version=app_version)
94+
user_agent += "/{app_name}/{app_version}".format(
95+
app_name=app_name, app_version=app_version
96+
)
9397

9498
self.headers = {"User-Agent": user_agent}
9599

@@ -296,18 +300,26 @@ def get_applications(self, params=None, **kwargs):
296300
return self.get(self.api_host, "/v1/applications", params or kwargs)
297301

298302
def get_application(self, application_id):
299-
return self.get(self.api_host, "/v1/applications/{application_id}".format(application_id=application_id))
303+
return self.get(
304+
self.api_host,
305+
"/v1/applications/{application_id}".format(application_id=application_id),
306+
)
300307

301308
def create_application(self, params=None, **kwargs):
302309
return self.post(self.api_host, "/v1/applications", params or kwargs)
303310

304311
def update_application(self, application_id, params=None, **kwargs):
305312
return self.put(
306-
self.api_host, "/v1/applications/{application_id}".format(application_id=application_id), params or kwargs
313+
self.api_host,
314+
"/v1/applications/{application_id}".format(application_id=application_id),
315+
params or kwargs,
307316
)
308317

309318
def delete_application(self, application_id):
310-
return self.delete(self.api_host, "/v1/applications/{application_id}".format(application_id=application_id))
319+
return self.delete(
320+
self.api_host,
321+
"/v1/applications/{application_id}".format(application_id=application_id),
322+
)
311323

312324
def create_call(self, params=None, **kwargs):
313325
return self._jwt_signed_post("/v1/calls", params or kwargs)
@@ -319,22 +331,30 @@ def get_call(self, uuid):
319331
return self._jwt_signed_get("/v1/calls/{uuid}".format(uuid=uuid))
320332

321333
def update_call(self, uuid, params=None, **kwargs):
322-
return self._jwt_signed_put("/v1/calls/{uuid}".format(uuid=uuid), params or kwargs)
334+
return self._jwt_signed_put(
335+
"/v1/calls/{uuid}".format(uuid=uuid), params or kwargs
336+
)
323337

324338
def send_audio(self, uuid, params=None, **kwargs):
325-
return self._jwt_signed_put("/v1/calls/{uuid}/stream".format(uuid=uuid), params or kwargs)
339+
return self._jwt_signed_put(
340+
"/v1/calls/{uuid}/stream".format(uuid=uuid), params or kwargs
341+
)
326342

327343
def stop_audio(self, uuid):
328344
return self._jwt_signed_delete("/v1/calls/{uuid}/stream".format(uuid=uuid))
329345

330346
def send_speech(self, uuid, params=None, **kwargs):
331-
return self._jwt_signed_put("/v1/calls/{uuid}/talk".format(uuid=uuid), params or kwargs)
347+
return self._jwt_signed_put(
348+
"/v1/calls/{uuid}/talk".format(uuid=uuid), params or kwargs
349+
)
332350

333351
def stop_speech(self, uuid):
334352
return self._jwt_signed_delete("/v1/calls/{uuid}/talk".format(uuid=uuid))
335353

336354
def send_dtmf(self, uuid, params=None, **kwargs):
337-
return self._jwt_signed_put("/v1/calls/{uuid}/dtmf".format(uuid=uuid), params or kwargs)
355+
return self._jwt_signed_put(
356+
"/v1/calls/{uuid}/dtmf".format(uuid=uuid), params or kwargs
357+
)
338358

339359
def get_recording(self, url):
340360
hostname = urlparse(url).hostname
@@ -348,24 +368,32 @@ def redact_transaction(self, id, product, type=None):
348368

349369
def list_secrets(self, api_key):
350370
return self.get(
351-
self.api_host, "/accounts/{api_key}/secrets".format(api_key=api_key), header_auth=True
371+
self.api_host,
372+
"/accounts/{api_key}/secrets".format(api_key=api_key),
373+
header_auth=True,
352374
)
353375

354376
def get_secret(self, api_key, secret_id):
355377
return self.get(
356378
self.api_host,
357-
"/accounts/{api_key}/secrets/{secret_id}".format(api_key=api_key, secret_id=secret_id),
379+
"/accounts/{api_key}/secrets/{secret_id}".format(
380+
api_key=api_key, secret_id=secret_id
381+
),
358382
header_auth=True,
359383
)
360384

361385
def create_secret(self, api_key, secret):
362386
body = {"secret": secret}
363-
return self._post_json(self.api_host, "/accounts/{api_key}/secrets".format(api_key=api_key), body)
387+
return self._post_json(
388+
self.api_host, "/accounts/{api_key}/secrets".format(api_key=api_key), body
389+
)
364390

365391
def delete_secret(self, api_key, secret_id):
366392
return self.delete(
367393
self.api_host,
368-
"/accounts/{api_key}/secrets/{secret_id}".format(api_key=api_key, secret_id=secret_id),
394+
"/accounts/{api_key}/secrets/{secret_id}".format(
395+
api_key=api_key, secret_id=secret_id
396+
),
369397
header_auth=True,
370398
)
371399

@@ -404,7 +432,11 @@ def get(self, host, request_uri, params=None, header_auth=False):
404432
headers = self.headers
405433
if header_auth:
406434
h = base64.b64encode(
407-
("{api_key}:{api_secret}".format(api_key=self.api_key, api_secret=self.api_secret).encode("utf-8"))
435+
(
436+
"{api_key}:{api_secret}".format(
437+
api_key=self.api_key, api_secret=self.api_secret
438+
).encode("utf-8")
439+
)
408440
).decode("ascii")
409441
headers = dict(headers or {}, Authorization="Basic {hash}".format(hash=h))
410442
else:
@@ -419,7 +451,11 @@ def post(self, host, request_uri, params, header_auth=False):
419451
headers = self.headers
420452
if header_auth:
421453
h = base64.b64encode(
422-
("{api_key}:{api_secret}".format(api_key=self.api_key, api_secret=self.api_secret).encode("utf-8"))
454+
(
455+
"{api_key}:{api_secret}".format(
456+
api_key=self.api_key, api_secret=self.api_secret
457+
).encode("utf-8")
458+
)
423459
).decode("ascii")
424460
headers = dict(headers or {}, Authorization="Basic {hash}".format(hash=h))
425461
else:
@@ -430,7 +466,11 @@ def post(self, host, request_uri, params, header_auth=False):
430466
def _post_json(self, host, request_uri, json):
431467
uri = "https://{host}{request_uri}".format(host=host, request_uri=request_uri)
432468
auth = base64.b64encode(
433-
("{api_key}:{api_secret}".format(api_key=self.api_key, api_secret=self.api_secret).encode("utf-8"))
469+
(
470+
"{api_key}:{api_secret}".format(
471+
api_key=self.api_key, api_secret=self.api_secret
472+
).encode("utf-8")
473+
)
434474
).decode("ascii")
435475
headers = dict(
436476
self.headers or {}, Authorization="Basic {hash}".format(hash=auth)
@@ -454,7 +494,11 @@ def delete(self, host, request_uri, header_auth=False):
454494
headers = self.headers
455495
if header_auth:
456496
h = base64.b64encode(
457-
("{api_key}:{api_secret}".format(api_key=self.api_key, api_secret=self.api_secret).encode("utf-8"))
497+
(
498+
"{api_key}:{api_secret}".format(
499+
api_key=self.api_key, api_secret=self.api_secret
500+
).encode("utf-8")
501+
)
458502
).decode("ascii")
459503
headers = dict(headers or {}, Authorization="Basic {hash}".format(hash=h))
460504
else:
@@ -508,29 +552,37 @@ def parse(self, host, response):
508552
raise ServerError(message)
509553

510554
def _jwt_signed_get(self, request_uri, params=None):
511-
uri = "https://{api_host}{request_uri}".format(api_host=self.api_host, request_uri=request_uri)
555+
uri = "https://{api_host}{request_uri}".format(
556+
api_host=self.api_host, request_uri=request_uri
557+
)
512558

513559
return self.parse(
514560
self.api_host,
515561
requests.get(uri, params=params or {}, headers=self._headers()),
516562
)
517563

518564
def _jwt_signed_post(self, request_uri, params):
519-
uri = "https://{api_host}{request_uri}".format(api_host=self.api_host, request_uri=request_uri)
565+
uri = "https://{api_host}{request_uri}".format(
566+
api_host=self.api_host, request_uri=request_uri
567+
)
520568

521569
return self.parse(
522570
self.api_host, requests.post(uri, json=params, headers=self._headers())
523571
)
524572

525573
def _jwt_signed_put(self, request_uri, params):
526-
uri = "https://{api_host}{request_uri}".format(api_host=self.api_host, request_uri=request_uri)
574+
uri = "https://{api_host}{request_uri}".format(
575+
api_host=self.api_host, request_uri=request_uri
576+
)
527577

528578
return self.parse(
529579
self.api_host, requests.put(uri, json=params, headers=self._headers())
530580
)
531581

532582
def _jwt_signed_delete(self, request_uri):
533-
uri = "https://{api_host}{request_uri}".format(api_host=self.api_host, request_uri=request_uri)
583+
uri = "https://{api_host}{request_uri}".format(
584+
api_host=self.api_host, request_uri=request_uri
585+
)
534586

535587
return self.parse(self.api_host, requests.delete(uri, headers=self._headers()))
536588

0 commit comments

Comments
 (0)