cwinters8 / gomap

Go module for interfacing with JMAP servers
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

implement `Result` struct #1

Closed cwinters8 closed 1 year ago

cwinters8 commented 1 year ago

Using Invocation for both making method calls and parsing responses is not working well. The methodResults object returned with a response seems to often have different fields than are necessary for a request method.

Right now, this is causing the TestMailbox/draft test to fail with the error:

mailbox_test.go:48: failed to create draft email: failed to send email set request: failed to unmarshal response body: failed to unmarshal args: failed to coerce create value to map. value is nil

because create is not an attribute on the result of the Email/set call. Instead, it looks something like

map[string]interface {} [
    "destroyed": nil,
    "notCreated": nil,
    "notDestroyed": nil,
    "notUpdated": nil,
    "accountId": "u69394015",
    "created": map[string]interface {} [
        "fb0c675a-01e4-4764-8677-bd6a1a3ecb6b": *(*interface {})(0xc0002474c8),
    ],
    "newState": "3566",
    "oldState": "3564",
    "updated": nil,
]

Currently thinking that a Result struct that could either:

The latter would be cleaner, but implementing will be more complex.

cwinters8 commented 1 year ago

Attempting to work out a way to parse a response into a certain type of result struct based on the type of arguments provided.

cwinters8 commented 1 year ago

Result and Results structs are created and tests indicate correct functionality. Next step is to utilize them when parsing request responses.

cwinters8 commented 1 year ago

Resolved with commit ac60a714e71e90f10171eddb0f09a840f53afc72