dub 0.26.12__py3-none-any.whl → 0.27.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dub/qr_codes.py CHANGED
@@ -97,59 +97,54 @@ class QRCodes(BaseSDK):
97
97
  if utils.match_response(http_res, "200", "image/png"):
98
98
  return http_res.text
99
99
  if utils.match_response(http_res, "400", "application/json"):
100
- response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
101
- raise errors.BadRequest(data=response_data)
100
+ response_data = utils.unmarshal_json_response(
101
+ errors.BadRequestData, http_res
102
+ )
103
+ raise errors.BadRequest(response_data, http_res)
102
104
  if utils.match_response(http_res, "401", "application/json"):
103
- response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
104
- raise errors.Unauthorized(data=response_data)
105
+ response_data = utils.unmarshal_json_response(
106
+ errors.UnauthorizedData, http_res
107
+ )
108
+ raise errors.Unauthorized(response_data, http_res)
105
109
  if utils.match_response(http_res, "403", "application/json"):
106
- response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
107
- raise errors.Forbidden(data=response_data)
110
+ response_data = utils.unmarshal_json_response(
111
+ errors.ForbiddenData, http_res
112
+ )
113
+ raise errors.Forbidden(response_data, http_res)
108
114
  if utils.match_response(http_res, "404", "application/json"):
109
- response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
110
- raise errors.NotFound(data=response_data)
115
+ response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
116
+ raise errors.NotFound(response_data, http_res)
111
117
  if utils.match_response(http_res, "409", "application/json"):
112
- response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
113
- raise errors.Conflict(data=response_data)
118
+ response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
119
+ raise errors.Conflict(response_data, http_res)
114
120
  if utils.match_response(http_res, "410", "application/json"):
115
- response_data = utils.unmarshal_json(
116
- http_res.text, errors.InviteExpiredData
121
+ response_data = utils.unmarshal_json_response(
122
+ errors.InviteExpiredData, http_res
117
123
  )
118
- raise errors.InviteExpired(data=response_data)
124
+ raise errors.InviteExpired(response_data, http_res)
119
125
  if utils.match_response(http_res, "422", "application/json"):
120
- response_data = utils.unmarshal_json(
121
- http_res.text, errors.UnprocessableEntityData
126
+ response_data = utils.unmarshal_json_response(
127
+ errors.UnprocessableEntityData, http_res
122
128
  )
123
- raise errors.UnprocessableEntity(data=response_data)
129
+ raise errors.UnprocessableEntity(response_data, http_res)
124
130
  if utils.match_response(http_res, "429", "application/json"):
125
- response_data = utils.unmarshal_json(
126
- http_res.text, errors.RateLimitExceededData
131
+ response_data = utils.unmarshal_json_response(
132
+ errors.RateLimitExceededData, http_res
127
133
  )
128
- raise errors.RateLimitExceeded(data=response_data)
134
+ raise errors.RateLimitExceeded(response_data, http_res)
129
135
  if utils.match_response(http_res, "500", "application/json"):
130
- response_data = utils.unmarshal_json(
131
- http_res.text, errors.InternalServerErrorData
136
+ response_data = utils.unmarshal_json_response(
137
+ errors.InternalServerErrorData, http_res
132
138
  )
133
- raise errors.InternalServerError(data=response_data)
139
+ raise errors.InternalServerError(response_data, http_res)
134
140
  if utils.match_response(http_res, "4XX", "*"):
135
141
  http_res_text = utils.stream_to_text(http_res)
136
- raise errors.SDKError(
137
- "API error occurred", http_res.status_code, http_res_text, http_res
138
- )
142
+ raise errors.SDKError("API error occurred", http_res, http_res_text)
139
143
  if utils.match_response(http_res, "5XX", "*"):
140
144
  http_res_text = utils.stream_to_text(http_res)
141
- raise errors.SDKError(
142
- "API error occurred", http_res.status_code, http_res_text, http_res
143
- )
145
+ raise errors.SDKError("API error occurred", http_res, http_res_text)
144
146
 
145
- content_type = http_res.headers.get("Content-Type")
146
- http_res_text = utils.stream_to_text(http_res)
147
- raise errors.SDKError(
148
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
149
- http_res.status_code,
150
- http_res_text,
151
- http_res,
152
- )
147
+ raise errors.SDKError("Unexpected response received", http_res)
153
148
 
154
149
  async def get_async(
155
150
  self,
@@ -239,56 +234,51 @@ class QRCodes(BaseSDK):
239
234
  if utils.match_response(http_res, "200", "image/png"):
240
235
  return http_res.text
241
236
  if utils.match_response(http_res, "400", "application/json"):
242
- response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
243
- raise errors.BadRequest(data=response_data)
237
+ response_data = utils.unmarshal_json_response(
238
+ errors.BadRequestData, http_res
239
+ )
240
+ raise errors.BadRequest(response_data, http_res)
244
241
  if utils.match_response(http_res, "401", "application/json"):
245
- response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
246
- raise errors.Unauthorized(data=response_data)
242
+ response_data = utils.unmarshal_json_response(
243
+ errors.UnauthorizedData, http_res
244
+ )
245
+ raise errors.Unauthorized(response_data, http_res)
247
246
  if utils.match_response(http_res, "403", "application/json"):
248
- response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
249
- raise errors.Forbidden(data=response_data)
247
+ response_data = utils.unmarshal_json_response(
248
+ errors.ForbiddenData, http_res
249
+ )
250
+ raise errors.Forbidden(response_data, http_res)
250
251
  if utils.match_response(http_res, "404", "application/json"):
251
- response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
252
- raise errors.NotFound(data=response_data)
252
+ response_data = utils.unmarshal_json_response(errors.NotFoundData, http_res)
253
+ raise errors.NotFound(response_data, http_res)
253
254
  if utils.match_response(http_res, "409", "application/json"):
254
- response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
255
- raise errors.Conflict(data=response_data)
255
+ response_data = utils.unmarshal_json_response(errors.ConflictData, http_res)
256
+ raise errors.Conflict(response_data, http_res)
256
257
  if utils.match_response(http_res, "410", "application/json"):
257
- response_data = utils.unmarshal_json(
258
- http_res.text, errors.InviteExpiredData
258
+ response_data = utils.unmarshal_json_response(
259
+ errors.InviteExpiredData, http_res
259
260
  )
260
- raise errors.InviteExpired(data=response_data)
261
+ raise errors.InviteExpired(response_data, http_res)
261
262
  if utils.match_response(http_res, "422", "application/json"):
262
- response_data = utils.unmarshal_json(
263
- http_res.text, errors.UnprocessableEntityData
263
+ response_data = utils.unmarshal_json_response(
264
+ errors.UnprocessableEntityData, http_res
264
265
  )
265
- raise errors.UnprocessableEntity(data=response_data)
266
+ raise errors.UnprocessableEntity(response_data, http_res)
266
267
  if utils.match_response(http_res, "429", "application/json"):
267
- response_data = utils.unmarshal_json(
268
- http_res.text, errors.RateLimitExceededData
268
+ response_data = utils.unmarshal_json_response(
269
+ errors.RateLimitExceededData, http_res
269
270
  )
270
- raise errors.RateLimitExceeded(data=response_data)
271
+ raise errors.RateLimitExceeded(response_data, http_res)
271
272
  if utils.match_response(http_res, "500", "application/json"):
272
- response_data = utils.unmarshal_json(
273
- http_res.text, errors.InternalServerErrorData
273
+ response_data = utils.unmarshal_json_response(
274
+ errors.InternalServerErrorData, http_res
274
275
  )
275
- raise errors.InternalServerError(data=response_data)
276
+ raise errors.InternalServerError(response_data, http_res)
276
277
  if utils.match_response(http_res, "4XX", "*"):
277
278
  http_res_text = await utils.stream_to_text_async(http_res)
278
- raise errors.SDKError(
279
- "API error occurred", http_res.status_code, http_res_text, http_res
280
- )
279
+ raise errors.SDKError("API error occurred", http_res, http_res_text)
281
280
  if utils.match_response(http_res, "5XX", "*"):
282
281
  http_res_text = await utils.stream_to_text_async(http_res)
283
- raise errors.SDKError(
284
- "API error occurred", http_res.status_code, http_res_text, http_res
285
- )
282
+ raise errors.SDKError("API error occurred", http_res, http_res_text)
286
283
 
287
- content_type = http_res.headers.get("Content-Type")
288
- http_res_text = await utils.stream_to_text_async(http_res)
289
- raise errors.SDKError(
290
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
291
- http_res.status_code,
292
- http_res_text,
293
- http_res,
294
- )
284
+ raise errors.SDKError("Unexpected response received", http_res)