Stripe_Invoice_Gem 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/stripe_invoice_gem.rb +69 -0
- metadata +43 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6eacecae58ce3cfeb7a0eb602b48f5fd3a3aeea00439a235e88306bffb71773e
|
|
4
|
+
data.tar.gz: 4fa261b47a23b57027b541ad3b35b57429342851b2971a48b083b239260d6861
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 165295e8fca5c5b691c17fe5ee5b0cae9118c8452df577c784bf6dc37433a4bcf376ec5ae18fa26d1e34016202c614e1716df18fc3ed95a57dbc486a6d610feb
|
|
7
|
+
data.tar.gz: 1b87861f07991a54b8eadf78e0d80649815e03db0a7dcf14488f273efe05aa1c9a5949358b1e29cb3ad9ac157ca9ae2e610dd1826fb2abffc7b5ca7388a35a58
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#Ruby gem to Download all your Stripe PDF invoices in bulk.
|
|
2
|
+
|
|
3
|
+
require 'stripe'
|
|
4
|
+
require 'open-uri'
|
|
5
|
+
|
|
6
|
+
puts 'Please note the process to download all of your invoice PDFs may take several minutes depending on the number of invoices in your account'
|
|
7
|
+
puts ""
|
|
8
|
+
puts 'Please enter your Stripe API key to retrieve your invoice PDFs in bulk: '
|
|
9
|
+
api_key = gets.chomp
|
|
10
|
+
|
|
11
|
+
Stripe.api_key = api_key
|
|
12
|
+
|
|
13
|
+
#Ask for user input to determine whether to download all invoices or only invoices before or after a certain invoice
|
|
14
|
+
puts ""
|
|
15
|
+
puts 'Please enter 1 if you would like to download all of your invoices. Please enter 2 if you would like to download invoices created after a given invoice.
|
|
16
|
+
Please enter 3 if you would like to download invoices created before a given invoice.'
|
|
17
|
+
option = nil
|
|
18
|
+
until option == 3 || option == 2 || option == 1
|
|
19
|
+
option = gets.chomp.to_i
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
if option == 2
|
|
23
|
+
puts ""
|
|
24
|
+
puts 'Please enter an invoice ID (in_xxx). Only invoices created after this invoice will be downloaded.'
|
|
25
|
+
starting_after = gets.chomp
|
|
26
|
+
elsif option == 3
|
|
27
|
+
puts ""
|
|
28
|
+
puts 'Please enter an invoice ID (in_xxx). Only invoices created before this invoice will be downloaded.'
|
|
29
|
+
ending_before = gets.chomp
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#creates the invoices directory if it does not exist. This is where the invoice PDFs will be downloaded
|
|
33
|
+
directory_name = "invoices"
|
|
34
|
+
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
|
35
|
+
|
|
36
|
+
puts "Please wait..."
|
|
37
|
+
|
|
38
|
+
case option
|
|
39
|
+
#option to dowload all invoices
|
|
40
|
+
when 1
|
|
41
|
+
invoices = Stripe::Invoice.list({limit: 100})
|
|
42
|
+
#option to download all invoices after a given invoice
|
|
43
|
+
when 2
|
|
44
|
+
invoices = Stripe::Invoice.list({limit: 100, starting_after: starting_after})
|
|
45
|
+
#option to download all invoices before a given invoice
|
|
46
|
+
when 3
|
|
47
|
+
invoices = Stripe::Invoice.list({limit: 100, ending_before: ending_before})
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#Stripe pagination to retrieve the full list of a User's invoices
|
|
51
|
+
invoice_ids = Hash.new
|
|
52
|
+
invoices.auto_paging_each do |invoice|
|
|
53
|
+
#This conditional statement ensures only invoices with a PDF are stored in our list
|
|
54
|
+
if !invoice.invoice_pdf.nil?
|
|
55
|
+
invoice_ids[invoice.id] = invoice.invoice_pdf
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#prints the total number of a User's invoices which have an invoice PDF
|
|
60
|
+
puts "Now downloading the following number of invoices: " + String(invoice_ids.length)
|
|
61
|
+
|
|
62
|
+
#This block copies each of the invoice PDFs to the /invoices directory
|
|
63
|
+
invoice_ids.each do |k, v|
|
|
64
|
+
open(v) do |image|
|
|
65
|
+
File.open("./invoices/"+k+".pdf", "wb") do |file|
|
|
66
|
+
file.write(image.read)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: Stripe_Invoice_Gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Hector Otero
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-05-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A simple hello world gem
|
|
14
|
+
email: hotero001@icloud.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/stripe_invoice_gem.rb
|
|
20
|
+
homepage: https://rubygems.org/gems/stripe_invoice_gem
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubygems_version: 3.2.33
|
|
40
|
+
signing_key:
|
|
41
|
+
specification_version: 4
|
|
42
|
+
summary: Ruby Gem to Download all your Stripe PDF invoices in bulk.
|
|
43
|
+
test_files: []
|