-
-
Save mjallday/47b943f57096b4a9c471 to your computer and use it in GitHub Desktop.
Balanced Ruby Filtering
This file contains 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
require 'balanced' | |
key = Balanced::ApiKey.new.save | |
Balanced.configure(key.secret) | |
Balanced::Marketplace.new.save | |
card = Balanced::Card.new( | |
:card_number => "5105105105105100", | |
:expiration_month => "12", | |
:expiration_year => "2015", | |
).save | |
buyer = Balanced::Marketplace.my_marketplace.create_buyer("buyer@example.org", | |
card.uri) | |
hold1 = buyer.hold 10000 | |
hold2 = buyer.hold 5000 | |
puts hold1.id, hold2.id | |
# we should print hmmmm once because we're not actually filtering by anything | |
puts 'hmmmm' if Balanced::Hold.find(:first, id: hold1.id).id != hold1.id | |
puts 'hmmmm' if Balanced::Hold.find(:first, id: hold2.id).id != hold2.id | |
# puts aha twice because it does filter correctly. | |
puts 'aha' if Balanced::Hold.find(hold1.uri).id == hold1.id | |
puts 'aha' if Balanced::Hold.find(hold2.uri).id == hold2.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment