aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2022-10-16 15:02:49 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2022-10-16 15:02:49 +0200
commit2ede7f2b2cf2a6b7344b5943a78d7852efa5e025 (patch)
tree22240dfb90ea9759bcd6ac0e0c5b48b0eb3b1bed
parenta3d0d5f7544fe38ae76438d46c530ce066664865 (diff)
move errors and responses out of call.go
-rw-r--r--call.go21
-rw-r--r--errors.go15
-rw-r--r--response.go9
3 files changed, 24 insertions, 21 deletions
diff --git a/call.go b/call.go
index cdf8869..547141f 100644
--- a/call.go
+++ b/call.go
@@ -3,7 +3,6 @@ package inwx
import (
"bytes"
"encoding/json"
- "fmt"
"net"
"net/http"
)
@@ -21,26 +20,6 @@ type Call interface {
expectedStatus() []Status
}
-// A Response contains the Status of a response to a Call
-// as well as the response parameters.
-// Data is nil if there are no response parameters.
-type Response struct {
- StatusCode Status `json:"code"`
- Data any `json:"resData"`
-}
-
-// ErrUnexpectedStatus indicates that a Call was responded to
-// but the Status doesn't match any of the expected Statuses of the Call.
-type ErrUnexpectedStatus struct {
- Expected []Status
- Got Status
-}
-
-func (e *ErrUnexpectedStatus) Error() string {
- const format = "unexpected status code: expected %v, got %v"
- return fmt.Sprintf(format, e.Expected, e.Got)
-}
-
// Call sends a Call to the API endpoint and waits for a response or an error.
// It returns net.ErrClosed if the Client is closed.
func (c *Client) Call(call Call) (*Response, error) {
diff --git a/errors.go b/errors.go
new file mode 100644
index 0000000..25e9e0c
--- /dev/null
+++ b/errors.go
@@ -0,0 +1,15 @@
+package inwx
+
+import "fmt"
+
+// ErrUnexpectedStatus indicates that a Call was responded to
+// but the Status doesn't match any of the expected Statuses of the Call.
+type ErrUnexpectedStatus struct {
+ Expected []Status
+ Got Status
+}
+
+func (e *ErrUnexpectedStatus) Error() string {
+ const format = "unexpected status code: expected %v, got %v"
+ return fmt.Sprintf(format, e.Expected, e.Got)
+}
diff --git a/response.go b/response.go
new file mode 100644
index 0000000..aaf256a
--- /dev/null
+++ b/response.go
@@ -0,0 +1,9 @@
+package inwx
+
+// A Response contains the Status of a response to a Call
+// as well as the response parameters.
+// Data is nil if there are no response parameters.
+type Response struct {
+ StatusCode Status `json:"code"`
+ Data any `json:"resData"`
+}