Last active
          July 27, 2017 14:11 
        
      - 
      
- 
        Save jaredk2g/4db10bb911ef2a5f258c46ee3f3a8480 to your computer and use it in GitHub Desktop. 
    Invoiced API Impotence
  
        
  
    
      This file contains hidden or 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 '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