You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, granted I understand the HAL schema y'all are working off of, the fundamental basis of the schema will remain the same, but ideally my end goal would be to go
DWOLLA_CLIENT=DwollaV2::Client.new(params)DWOLLA_CLIENT.get('customers',limit: 1).links[0].get.funding_sources(params)# or funding_sources('get', params)
to accomplish roughly the same thing, where .links dynamcially dispatches the link information to methods to then re-call the client.
So, codewise, I'd imagine that the https://github.com/Dwolla/dwolla-v2-ruby/blob/main/lib/dwolla_v2/response.rb would contain a method that would look directly into the response maps, pull out the direct child _links and _embedded links object and create new methods based on that. The only caveat that would be tricky to work through is carrying over the same client request for both, which I think given the way token works, by adding the token to the initializer of the Response, we should (:crossed_fingers:) be able to easily pass over the request structure to the links by going
classResponsedefinitializeresponse,token@response=response@token=tokenenddeflinks@response.body["_links"].keys.eachdo |link|
# ideally we'd snakecase link heredefine_method(method,link,params=nil,headers=nil)do |path,params,headers|
full_url=self.class.full_urlclient,path@token.public_send(method,full_url,params_headers)endendendend
Granted I haven't tested this, but just thought it up over lunch, but if this is something amenable, I'd be happy to fork and set up a PR.
The text was updated successfully, but these errors were encountered:
Feel free to open a pull request! I can't promise it's something we'll merge in, but we'd definitely like to make some improvements along those lines. At the very least it'd be great to see how you'd go about things.
I need to give this some more thought, but what do you think of something like:
One thing I've been thinking about is how there should be an easier way to access the responses of
links
.Example
So, granted I understand the HAL schema y'all are working off of, the fundamental basis of the schema will remain the same, but ideally my end goal would be to go
to accomplish roughly the same thing, where
.links
dynamcially dispatches the link information to methods to then re-call the client.So, codewise, I'd imagine that the https://github.com/Dwolla/dwolla-v2-ruby/blob/main/lib/dwolla_v2/response.rb would contain a method that would look directly into the response maps, pull out the direct child
_links
and_embedded
links object and create new methods based on that. The only caveat that would be tricky to work through is carrying over the same client request for both, which I think given the way token works, by adding the token to the initializer of theResponse
, we should (:crossed_fingers:) be able to easily pass over the request structure to the links by goingGranted I haven't tested this, but just thought it up over lunch, but if this is something amenable, I'd be happy to fork and set up a PR.
The text was updated successfully, but these errors were encountered: