updateWageSetting method
Creates or updates a WageSetting object.
The object is created if a WageSetting with the specified team_member_id does not exist. Otherwise, it fully replaces the WageSetting object for the team member. The WageSetting is returned on a successful update. Learn about Troubleshooting the Team API.
Implementation
Future<WageSetting> updateWageSetting({
required WageSetting wageSetting,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.accessToken;
Map<String, String> headers = {
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/json; charset=UTF-8',
'Accept': 'application/json',
};
Uri endpoint = Uri.https(
baseUrl, "/v2/team-members/${wageSetting.teamMemberId}/wage-setting");
//print (endpoint.toString());
var response = await
http.put(endpoint, body: wageSetting, headers: headers);
if (response.statusCode == 200) {
print (jsonDecode(response.body));
return WageSettingResponse.fromJson(jsonDecode(response.body)).wageSetting!;
}
else {
print (response.body);
throw TeamMemberException(statusCode: response.statusCode, message: WageSettingResponse.fromJson(jsonDecode(response.body)).errors?[0].detail?.toString());
}
}