Skip to content

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

@isikyus

Description

@isikyus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions