Skip to content

Instantly share code, notes, and snippets.

@jaredk2g
Last active July 27, 2017 14:11
Show Gist options
  • Save jaredk2g/4db10bb911ef2a5f258c46ee3f3a8480 to your computer and use it in GitHub Desktop.
Save jaredk2g/4db10bb911ef2a5f258c46ee3f3a8480 to your computer and use it in GitHub Desktop.
Invoiced API Impotence
require 'invoiced'
require 'securerandom'
invoiced = Invoiced::Client.new('api_key_here')
# This will create a customer
customer = invoiced.Customer.create({
:name => 'My Customer'
}, {
:idempotency_key => SecureRandom.uuid
})
# Future calls with the same idempotency key will return the previously created customer
for i in 0..5
customer2 = invoiced.Customer.create({
:name => 'My Customer'
}, {
:idempotency_key => SecureRandom.uuid
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment