Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
fix: update TbdexHttpClient to look for error codes (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwlee authored May 8, 2024
1 parent b974204 commit 9d06f01
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/src/http_client/tbdex_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class TbdexHttpClient {
},
);

return response.statusCode == 200
? TbdexResponse(
return response.statusCode >= 400
? TbdexResponse(statusCode: response.statusCode)
: TbdexResponse(
data: Parser.parseExchange(response.body),
statusCode: response.statusCode,
)
: TbdexResponse(statusCode: response.statusCode);
);
}

static Future<TbdexResponse<List<String>?>> listExchanges(
Expand All @@ -67,12 +67,12 @@ class TbdexHttpClient {
},
);

return response.statusCode == 200
? TbdexResponse(
return response.statusCode >= 400
? TbdexResponse(statusCode: response.statusCode)
: TbdexResponse(
data: Parser.parseExchanges(response.body),
statusCode: response.statusCode,
)
: TbdexResponse(statusCode: response.statusCode);
);
}

static Future<TbdexResponse<List<Offering>?>> listOfferings(
Expand All @@ -86,12 +86,12 @@ class TbdexHttpClient {

final response = await _client.get(url);

return response.statusCode == 200
? TbdexResponse(
return response.statusCode >= 400
? TbdexResponse(statusCode: response.statusCode)
: TbdexResponse(
data: Parser.parseOfferings(response.body),
statusCode: response.statusCode,
)
: TbdexResponse(statusCode: response.statusCode);
);
}

static Future<TbdexResponse<void>> createExchange(
Expand Down

0 comments on commit 9d06f01

Please sign in to comment.