Skip to content

Commit

Permalink
Fix: Add params to PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
pitw committed Jun 24, 2024
1 parent c8c8542 commit 15a74d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ class ProffixClient implements BaseProffixClient {
Future<Response> put({
String endpoint = '',
Map<String, dynamic>? data,
Map<String, dynamic>? params,
}) async {
// return await call('post', path: path, headers: headers, data: data);
String pxsessionid = await getPxSessionId();
Expand All @@ -342,11 +343,15 @@ class ProffixClient implements BaseProffixClient {
_dioClient.options.headers['PxSessionId'] = pxsessionid;

try {
///
final postUri = _getUriUrl(
buildUriPx(restURL, [_options.apiPrefix, _options.version, endpoint])
.toString(),
params);

var resp = await _dioClient
.put(
buildUriPx(
restURL, [_options.apiPrefix, _options.version, endpoint]),
data: json.encode(data))
.put(postUri, data: json.encode(data))
.timeout(Duration(seconds: _options.timeout));
if (resp.statusCode == null ||
(resp.statusCode! < 200 || resp.statusCode! > 300)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/client_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ abstract class BaseProffixClient {
});

/// An alias of ProffixClient.call('put')
Future<Response> put({
required String endpoint,
Map<String, dynamic>? data,
});
Future<Response> put(
{required String endpoint,
Map<String, dynamic>? data,
Map<String, dynamic>? params = const {}});

/// An alias of ProffixClient.call('delete')
Future<Response> delete({
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_proffix_rest
description: A Dart wrapper for Proffix Rest API with automatic login and logout and many useful helper functions
version: 0.3.5
version: 0.3.6
repository: https://github.com/pitwch/dart_proffix_rest
homepage: https://github.com/pitwch/dart_proffix_rest
environment:
Expand Down

0 comments on commit 15a74d4

Please sign in to comment.