Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguishing unprovided values from provided zero values #20

Open
ISE-Admin opened this issue Apr 15, 2022 · 0 comments
Open

Distinguishing unprovided values from provided zero values #20

ISE-Admin opened this issue Apr 15, 2022 · 0 comments

Comments

@ISE-Admin
Copy link

ISE-Admin commented Apr 15, 2022

I'm having an issue with loading public contracts using the ContractsApi.GetContractsPublicRegionId function.

For optional arguments (e.g. the "reward" field from the corresponding ESI endpoint), is there any way to distinguish between a field that wasn't provided (e.g. a contract that doesn't have a "reward" field, such as an item exchange), vs. a contract where that field was provided, but has a zero value (e.g. a courier contract where the reward is 0)?

I know I could do a conditional check based on the Type_ field of the resulting GetContractsPublicRegionId200Ok struct, and only check the Reward field if it's a contract of type courier, but that's a lot of switch statements over a lot of endpoints.

The conventional Go way to do this would be for these structs to use pointer type for the optional fields, which would be nil if they weren't provided in the ESI response.
@antihax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant