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

There seem to be typos in the code for the ZipMoney.api.heartbeat request #12

Open
isikyus opened this issue Oct 8, 2017 · 0 comments

Comments

@isikyus
Copy link

isikyus commented Oct 8, 2017

Hi,

The zipMoney API is mostly working for us, but we do have an intermittent problem with refunds taking a long time to go through.

Last week I tried to use the heartbeat API method to see if zipMoney was up while we were having the issue, but it doesn't seem to be working.

What I expected to see happen

Calling ZipMoney.api.heartbeat should tell me whether the API is up or not.

What actually happened

A crashe due to an undefined constant:

2.0.0-p247 :007 > ZipMoney.api.heartbeat
NameError: uninitialized constant ZipMoney::Resources::RESOURCE_HEARTBEAT
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/zipmoney-ruby-sdk-24117fd94f8a/lib/zipMoney/api.rb:189:in `heartbeat'
    from (irb):7
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/rails-d6d63767795d/railties/lib/rails/commands/console.rb:90:in `start'
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/rails-d6d63767795d/railties/lib/rails/commands/console.rb:9:in `start'
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/rails-d6d63767795d/railties/lib/rails/commands.rb:66:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

What I did to get it working in that console session

  • Define the undefined constant, using the existing RESOURCE_HEART_BEAT one.
  • Ensure the constant is defined in lower-case, so that matching against it works correctly.
  • Manually make the request as a GET rather than a POST one.
2.0.0-p247 :008 > ZipMoney::Resources::RESOURCE_HEARTBEAT = ZipMoney::Resources::RESOURCE_HEART_BEAT
 => "Heartbeat" 
2.0.0-p247 :009 > ZipMoney.api.heartbeat
NoMethodError: undefined method `post' for false:FalseClass
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/zipmoney-ruby-sdk-24117fd94f8a/lib/zipMoney/api.rb:81:in `request'
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/zipmoney-ruby-sdk-24117fd94f8a/lib/zipMoney/api.rb:189:in `heartbeat'
    from (irb):9
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/rails-d6d63767795d/railties/lib/rails/commands/console.rb:90:in `start'
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/rails-d6d63767795d/railties/lib/rails/commands/console.rb:9:in `start'
    from /home/nest/apps/merlin/shared/bundle/ruby/2.0.0/bundler/gems/rails-d6d63767795d/railties/lib/rails/commands.rb:66:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
2.0.0-p247 :010 > ZipMoney::Resources::RESOURCE_HEARTBEAT = ZipMoney::Resources::RESOURCE_HEART_BEAT.downcase
(irb):10: warning: already initialized constant ZipMoney::Resources::RESOURCE_HEARTBEAT
(irb):8: warning: previous definition of RESOURCE_HEARTBEAT was here
 => "heartbeat" 
2.0.0-p247 :011 > ZipMoney.api.heartbeat
 => #<ZipMoney::Response:0x00000007f1de50 @_response="{\"Message\":\"The requested resource does not support http method 'POST'.\"}", @_statusCode=405, @_responseBody="{\"Message\":\"The requested resource does not support http method 'POST'.\"}">
2.0.0-p247 :013 > ZipMoney.api.request(ZipMoney::Resources::RESOURCE_HEARTBEAT, ZipMoney::Api::HTTP_METHOD_GET)
 => #<ZipMoney::Response:0x000000082da688 @_response="", @_statusCode=200, @_responseBody="">

I understand this is a minor issue -- presumably no-one usually uses the heartbeat method -- but it would be handy if it could be fixed if there's ever another release of the gem.

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