-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Support new API version error format
While FreshBooks API versions are not yet documented, the recent versions (2022-10-31 and forward) feature a slightly different response format when some /accounting endpoints fail. Update the accounting handlers to handle both formats. Fixes #41
- Loading branch information
Andrew McIntosh
committed
Aug 7, 2023
1 parent
462b045
commit caecf94
Showing
10 changed files
with
146 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ local.properties | |
# Editor config | ||
.vscode/ | ||
.idea/ | ||
.settings/ | ||
lib/bin/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/src/main/java/net/amcintosh/freshbooks/models/api/AccountingErrorDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.amcintosh.freshbooks.models.api; | ||
|
||
import com.google.api.client.util.Key; | ||
|
||
|
||
public class AccountingErrorDetails { | ||
@Key("@type") | ||
public String type; | ||
|
||
@Key | ||
public String reason; | ||
@Key | ||
public String domain; | ||
@Key | ||
public AccountingErrorDetailsMetadata metadata; | ||
|
||
public int getReason() { | ||
return Integer.parseInt(reason); | ||
} | ||
|
||
public static class AccountingErrorDetailsMetadata { | ||
@Key | ||
public String object; | ||
@Key | ||
public String message; | ||
@Key | ||
public String field; | ||
@Key | ||
public String value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
lib/src/test/resources/fixtures/get_client_response__no_auth.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"code": 16, | ||
"message": "Request failed with status_code: 401", | ||
"details": [ | ||
{ | ||
"@type": "type.googleapis.com/google.rpc.ErrorInfo", | ||
"reason": "1003", | ||
"domain": "accounting.api.freshbooks.com", | ||
"metadata": { | ||
"object": "", | ||
"message": "The server could not verify that you are authorized to access the URL requested.", | ||
"value": "", | ||
"field": "" | ||
} | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
lib/src/test/resources/fixtures/get_client_response__not_found_new.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"code": 5, | ||
"message": "Request failed with status_code: 404", | ||
"details": [ | ||
{ | ||
"@type": "type.googleapis.com/google.rpc.ErrorInfo", | ||
"reason": "1012", | ||
"domain": "accounting.api.freshbooks.com", | ||
"metadata": { | ||
"object": "client", | ||
"message": "Client not found.", | ||
"value": "12345", | ||
"field": "userid" | ||
} | ||
} | ||
] | ||
} |
File renamed without changes.