Add dry types to client (and also refactored dry types on job)#23
Merged
Add dry types to client (and also refactored dry types on job)#23
Conversation
lib/xpm_ruby/client.rb
Outdated
| end | ||
|
|
||
| def add(access_token:, xero_tenant_id:, client:) | ||
| validated_client = XpmRuby::Schema::Client::Add[client] |
Contributor
There was a problem hiding this comment.
Schema::Client::Add[client]
| end | ||
| end | ||
| end | ||
| end |
Contributor
There was a problem hiding this comment.
Should be able to remove the XpmRuby prefix here too.
Contributor
Author
|
@subskii BTW it's implicit in this code, but I thought I would make it explicit that if there are missing attributes we now raise a |
lankz
pushed a commit
that referenced
this pull request
Jun 10, 2025
* Need to use symbols so we can define optional attributes * Add client schema and spec * Use validated client to send to XPM * Rubocop fix * code review feedback * code review updates
lankz
pushed a commit
that referenced
this pull request
Jun 10, 2025
* Need to use symbols so we can define optional attributes * Add client schema and spec * Use validated client to send to XPM * Rubocop fix * code review feedback * code review updates
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unfortunately I found that when you use String keys on a dry types hash schema, you can't specify optional parameters (it just ignores them). The DSL needs to be defined with symbols so you can put the (
?) at the end to make it optional.You can however use
with_key_transform(&:to_sym)option at the end which will convert your string keys to symbols automatically.I updated the old job schema as well to reflect what I found with the client schema.
Even thought the keys are converted to symbols, when you export them to XML they are converted back to strings in any case (
:ClientIDbecomes<ClientID></ClientID>).if there are missing attributes we now raise a Dry::Types::ConstraintError which will need to be handled in whomever is using this gem.