diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5facd49..f382d37 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -26,6 +26,13 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run tests - run: bundle exec rspec + env: + GOOGLE_ACCOUNT_TYPE: ${{ secrets.GOOGLE_ACCOUNT_TYPE }} + GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} + GOOGLE_API_SPREADSHEET_ID: ${{ secrets.GOOGLE_API_SPREADSHEET_ID }} + GOOGLE_CLIENT_EMAIL: ${{ secrets.GOOGLE_CLIENT_EMAIL }} + GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} + GOOGLE_PRIVATE_KEY: ${{ secrets.GOOGLE_PRIVATE_KEY }} + run: bundle exec rake spec - name: Run RuboCop run: bundle exec rubocop diff --git a/.gitignore b/.gitignore index b04a8c8..4221ae4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ # rspec failure tracking .rspec_status + +.byebug_history + diff --git a/Gemfile b/Gemfile index ecf170e..87da6ec 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,9 @@ group :development, :test do end group :test do + gem 'byebug', require: false gem 'rspec', require: false gem 'simplecov', require: false + gem 'vcr', require: false + gem 'webmock', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 514e799..5a1086d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,23 +2,76 @@ PATH remote: . specs: sheet_zoukas (0.1.0) + google-apis-sheets_v4 GEM remote: https://rubygems.org/ specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + byebug (11.1.3) + crack (1.0.0) + bigdecimal + rexml + declarative (0.0.20) diff-lcs (1.5.1) docile (1.4.1) + faraday (2.12.0) + faraday-net_http (>= 2.0, < 3.4) + json + logger + faraday-net_http (3.3.0) + net-http + google-apis-core (0.15.1) + addressable (~> 2.5, >= 2.5.1) + googleauth (~> 1.9) + httpclient (>= 2.8.3, < 3.a) + mini_mime (~> 1.0) + mutex_m + representable (~> 3.0) + retriable (>= 2.0, < 4.a) + google-apis-sheets_v4 (0.36.0) + google-apis-core (>= 0.15.0, < 2.a) + google-cloud-env (2.2.1) + faraday (>= 1.0, < 3.a) + googleauth (1.11.1) + faraday (>= 1.0, < 3.a) + google-cloud-env (~> 2.1) + jwt (>= 1.4, < 3.0) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (>= 0.16, < 2.a) + hashdiff (1.1.1) + httpclient (2.8.3) json (2.7.2) + jwt (2.9.3) + base64 language_server-protocol (3.17.0.3) + logger (1.6.1) + mini_mime (1.1.5) + multi_json (1.15.0) + mutex_m (0.2.0) + net-http (0.4.1) + uri + os (1.1.4) parallel (1.26.3) parser (3.3.5.0) ast (~> 2.4.1) racc + public_suffix (6.0.1) racc (1.8.1) rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) + representable (3.2.0) + declarative (< 0.1.0) + trailblazer-option (>= 0.1.1, < 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rexml (3.3.8) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -49,19 +102,34 @@ GEM rubocop-rspec (3.1.0) rubocop (~> 1.61) ruby-progressbar (1.13.0) + signet (0.19.0) + addressable (~> 2.8) + faraday (>= 0.17.5, < 3.a) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) + trailblazer-option (0.1.2) + uber (0.1.0) unicode-display_width (2.6.0) + uri (0.13.1) + vcr (6.3.1) + base64 + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) PLATFORMS arm64-darwin-23 ruby DEPENDENCIES + byebug rake (~> 13.0) rspec rubocop @@ -69,6 +137,8 @@ DEPENDENCIES rubocop-rspec sheet_zoukas! simplecov + vcr + webmock BUNDLED WITH 2.5.16 diff --git a/README.md b/README.md index ab26081..5a4494a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # SheetZoukas -TODO: Delete this and the text below, and describe your gem - -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sheet_zoukas`. To experiment with that code, run `bin/console` for an interactive prompt. +Expose Google Sheets as JSON. ## Installation @@ -16,7 +14,6 @@ If bundler is not being used to manage dependencies, install the gem by executin ## Usage -TODO: Write usage instructions here ## Development diff --git a/lib/sheet_zoukas.rb b/lib/sheet_zoukas.rb index cf71f85..9ec65e8 100644 --- a/lib/sheet_zoukas.rb +++ b/lib/sheet_zoukas.rb @@ -4,5 +4,4 @@ module SheetZoukas class Error < StandardError; end - # Your code goes here... end diff --git a/lib/sheet_zoukas/google_sheets.rb b/lib/sheet_zoukas/google_sheets.rb new file mode 100644 index 0000000..7f1f946 --- /dev/null +++ b/lib/sheet_zoukas/google_sheets.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'google/apis/sheets_v4' +require 'googleauth' + +module SheetZoukas + # Interact with Google Sheets API + class GoogleSheets + DEFAULT_SCOPE = 'https://www.googleapis.com/auth/spreadsheets.readonly' + + def initialize(scope = DEFAULT_SCOPE) + @authorizer = Google::Auth::ServiceAccountCredentials.from_env(scope: scope) + end + + def retrieve_sheet(sheet_id, tab_name, range = nil) + sheets = Google::Apis::SheetsV4::SheetsService.new + sheets.authorization = @authorizer + + computed_range = SheetZoukas::GoogleSheets.send :create_range, tab_name, range + sheets.get_spreadsheet_values(sheet_id, computed_range) + end + + private_class_method def self.create_range(tab_name, range = nil) + return tab_name unless range + + "#{tab_name}!#{range}" + end + end +end diff --git a/sheet_zoukas.gemspec b/sheet_zoukas.gemspec index 9762880..c92584c 100644 --- a/sheet_zoukas.gemspec +++ b/sheet_zoukas.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] # spec.add_development_dependency 'rspec' + spec.add_dependency 'google-apis-sheets_v4' spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/spec/fixtures/vcr_cassettes/get_spreadsheet_values_no_range.yml b/spec/fixtures/vcr_cassettes/get_spreadsheet_values_no_range.yml new file mode 100644 index 0000000..6288e39 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/get_spreadsheet_values_no_range.yml @@ -0,0 +1,1243 @@ +--- +http_interactions: +- request: + method: post + uri: https://www.googleapis.com/oauth2/v4/token + body: + encoding: ASCII-8BIT + string: grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJzdHAtZm9vZC1zZXJ2aWNlQHN0cC1mb29kLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwiYXVkIjoiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vb2F1dGgyL3Y0L3Rva2VuIiwiZXhwIjoxNzI4NzcyNjE4LCJpYXQiOjE3Mjg3NzI0OTgsInNjb3BlIjoiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vYXV0aC9kcml2ZS5yZWFkb25seSJ9.C7iPR9Lavlv44wtQcNs2orahR_Er7QjjBn7TJTMfd7lI5eE3tRC2ixwuS1oGEXPG1ColjAc3gojKFtJxTJsWUYiCTwdFk1Kx6U8lBJV_sNY8F8Y_LxiDfS8zGPldXJ5RBabHRzJofRfXPOK1q6M8IpPgoK1jV3ilynfnUajlwpmhIcHUOeGmu0h2XxHzcXgKhJFBxVRw5PjOmdC0EOqyGIC6KVu2JJKPDhZ-LE4WCNuiFZIEfNY2huzxKYxhTz-C9dWkmlS2TDeGkWLWsD1QLN3p5D2TCO3V3jmQ3SQpncbSZQ475OcpRdCnAnByo49qVxR8U6lR6XEdqQbwKInibg + headers: + User-Agent: + - Faraday v2.12.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=UTF-8 + Vary: + - Origin + - Referer + - X-Origin + Date: + - Sat, 12 Oct 2024 22:35:58 GMT + Server: + - scaffolding on HTTPServer2 + Cache-Control: + - private + X-Xss-Protection: + - '0' + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + Transfer-Encoding: + - chunked + body: + encoding: ASCII-8BIT + string: '{"access_token":"ya29.c.c0ASRK0GYEVGz-_kslN9gKdl0NhSMljNMSKv-F2fBcXarlK3Itsq5TzaHMHf-opp_pMdKmgG5FZp7s3iATwMYaRTjbi50PjyYk17kmZKZPf079yhIw68aqnMLfZ8UeRBHN1Uvby2RXh9ExZjcGWBTQt7tRF0n-nOHwr0e7rnEQuyNeSDHTTvsp7ckSJ6BwnErQUIdI0B6rCU1-V6pl7nlV60rnKg0O23MtYjThWjmtZAdC6OB-DHbfjkrpaFB5ZqhJljDpbDixfVqqiX-W6sv0RXZuaHlR3Z-Soxhk0isUyXZg7fOXm5WlsxleesaaPyOLsGT8YNcuNDNvOcSN14K0dkGY9IXMypt67F9U6bPpSimxFgSebiugVIAN384PakY4_Ut97ol-n4M8m1kbwf5Q5pRwj7S9WWmBZjFi43hsMwiq-RjyZfRc17yQR776Bpnv0sSoZzacZ4tRtfmc4k-uZIXXmeQgyjM4niOW7v2BZ1RyuxcdskmWWgssM1cM18wWecpk4eBoWnwzcx6lZQ0h_aSaJmrFQvMURqwZp1eQg426vyaOs7xw61hF7Se4z5X08laBwZe6lBaXUXdyyRBB8j9eiSsgB9sXBO04sYzUMSVw1qzlc9atWIbczvjupQYpmlysyoz_feviOpjwn1lXU2j6URbmbc1iSBleOwf5nb5W_cveUc7jmkl128-pn6pnl2RS_v3dyyUhV4wj8FBpgvWMyBYRWb3q3WiR820_9c-MiQtBxURos01wYRyXcurulcWatrz_bd6VnOZBjpQRBYdvVyeqWQFpxFjJgyV-J2Xq5jy5eh8a-ahc0tonYr14R37hU7um5wgz31QQhI3c0hVZmzV00-aod0tg53g3BZ01conosyoaZj-axdjsB8zlIcO3dQtvo-xf6igxfbWxOa416vJkI1oSnot0fQeW87qyMW7bofi27MicXgfUIhrkOyVuuR2SOmtRUj_esm_r6O-mW_icS-gpR9uoZ2x1OvegOqmB7XviR1k","expires_in":3599,"token_type":"Bearer"}' + recorded_at: Sat, 12 Oct 2024 22:35:58 GMT +- request: + method: get + uri: https://sheets.googleapis.com/v4/spreadsheets//values/Log + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - unknown/0.0.0 google-apis-sheets_v4/0.36.0 Mac OS X/14.6.1 (gzip) + Accept: + - "*/*" + Accept-Encoding: + - gzip,deflate + Date: + - Sat, 12 Oct 2024 22:35:58 GMT + X-Goog-Api-Client: + - gl-ruby/3.3.5 gdcl/1.36.0 + Authorization: + - Bearer ya29.c.c0ASRK0GYEVGz-_kslN9gKdl0NhSMljNMSKv-F2fBcXarlK3Itsq5TzaHMHf-opp_pMdKmgG5FZp7s3iATwMYaRTjbi50PjyYk17kmZKZPf079yhIw68aqnMLfZ8UeRBHN1Uvby2RXh9ExZjcGWBTQt7tRF0n-nOHwr0e7rnEQuyNeSDHTTvsp7ckSJ6BwnErQUIdI0B6rCU1-V6pl7nlV60rnKg0O23MtYjThWjmtZAdC6OB-DHbfjkrpaFB5ZqhJljDpbDixfVqqiX-W6sv0RXZuaHlR3Z-Soxhk0isUyXZg7fOXm5WlsxleesaaPyOLsGT8YNcuNDNvOcSN14K0dkGY9IXMypt67F9U6bPpSimxFgSebiugVIAN384PakY4_Ut97ol-n4M8m1kbwf5Q5pRwj7S9WWmBZjFi43hsMwiq-RjyZfRc17yQR776Bpnv0sSoZzacZ4tRtfmc4k-uZIXXmeQgyjM4niOW7v2BZ1RyuxcdskmWWgssM1cM18wWecpk4eBoWnwzcx6lZQ0h_aSaJmrFQvMURqwZp1eQg426vyaOs7xw61hF7Se4z5X08laBwZe6lBaXUXdyyRBB8j9eiSsgB9sXBO04sYzUMSVw1qzlc9atWIbczvjupQYpmlysyoz_feviOpjwn1lXU2j6URbmbc1iSBleOwf5nb5W_cveUc7jmkl128-pn6pnl2RS_v3dyyUhV4wj8FBpgvWMyBYRWb3q3WiR820_9c-MiQtBxURos01wYRyXcurulcWatrz_bd6VnOZBjpQRBYdvVyeqWQFpxFjJgyV-J2Xq5jy5eh8a-ahc0tonYr14R37hU7um5wgz31QQhI3c0hVZmzV00-aod0tg53g3BZ01conosyoaZj-axdjsB8zlIcO3dQtvo-xf6igxfbWxOa416vJkI1oSnot0fQeW87qyMW7bofi27MicXgfUIhrkOyVuuR2SOmtRUj_esm_r6O-mW_icS-gpR9uoZ2x1OvegOqmB7XviR1k + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=UTF-8 + Vary: + - Origin + - Referer + - X-Origin + Content-Encoding: + - gzip + Date: + - Sat, 12 Oct 2024 22:35:59 GMT + Server: + - ESF + Cache-Control: + - private + X-Xss-Protection: + - '0' + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + X-L2-Request-Path: + - l2-managed-6 + Transfer-Encoding: + - chunked + body: + encoding: UTF-8 + string: | + { + "range": "Log!A1:AB1000", + "majorDimension": "ROWS", + "values": [ + [ + "Place", + "Deal", + "Deal Earned", + "Deal Used", + "Deal Starts", + "Deal Ends", + "Notes", + "Money Saved", + "Reward Type" + ], + [ + "Slice Brothers", + "2 slices for $5.99", + "", + "03/30", + "", + "", + "no longer active", + "4.99", + "no longer active", + "", + "TOTAL SAVED", + "124.15" + ], + [ + "Slice Brothers", + "2 slices for $5.99", + "", + "04/11", + "", + "", + "no longer active", + "4.99", + "no longer active" + ], + [ + "Pot Belly", + "1 free sandwich with the purchase of sandwich between 04/01 and 04/07", + "04/04", + "04/08", + "04/01", + "04/07", + "", + "10.66", + "rewards" + ], + [ + "Jimmy John's", + "1 free sandwich with purchase of first sandwich online", + "04/15", + "04/23", + "", + "", + "", + "9.76", + "signup offer" + ], + [ + "Jimmy John's", + "$5.99 sandwich offer for rewards members valid for 3 days", + "05/01", + "05/03", + "", + "05/03", + "", + "3.06", + "rewards" + ], + [ + "Cassie's", + "$7.99 sandwich and fries", + "", + "05/01", + "", + "", + "$8.78 with tax", + "1.48", + "daily deal" + ], + [ + "Skyway New Masala", + "10% off Wednesdays", + "", + "05/08", + "", + "", + "", + "1.2", + "daily deal" + ], + [ + "Afro Deli", + "5% back through T-Mobile", + "", + "05/09", + "", + "", + "", + "0.6" + ], + [ + "Pot Belly", + "5% back through my credit card", + "", + "", + "", + "06/10" + ], + [ + "Subway ", + "5% back through my credit card", + "", + "05/10", + "", + "05/13", + "", + "0.43" + ], + [ + "Subway", + "BOGO with code FLBOGO", + "", + "05/10", + "", + "5/15", + "", + "8.77", + "promotion" + ], + [ + "White Castle", + "$25 gift cards for $19.21", + "", + "", + "", + "05/31", + "", + "", + "promotion" + ], + [ + "My Burger", + "20% off with code TWOLVES20", + "", + "", + "", + "05/22", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "Free dessert", + "", + "", + "", + "06/01", + "", + "", + "rewards" + ], + [ + "Rival House", + "20% off all menu items", + "", + "", + "", + "06/30", + "", + "", + "rewards" + ], + [ + "Chipotle", + "BOGO buritto when order through GrubHub", + "", + "06/03", + "", + "", + "", + "11.7" + ], + [ + "Pizza Luce", + "Fee appetizer with specialty pizza coupon", + "", + "06/04", + "", + "", + "", + "10.79", + "mailer" + ], + [ + "Domino's", + "50% off all menu-priced pizzas with code 9413", + "", + "", + "06/03", + "06/09", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$2 off $10 online or using the app", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Arby's", + "5 for $5 online or using the app", + "", + "", + "06/10", + "06/15", + "", + "", + "promotion" + ], + [ + "Leeann Chin", + "BOGO 50% off with Instagram post: Follow us on Instagram, like this post, and show this offer to the cashier to redeem.", + "", + "", + "06/05", + "06/11", + "", + "", + "promotion" + ], + [ + "Culver's", + "Free single scoop of frozen custard with one topping (birthday)", + "", + "", + "06/06", + "06/20", + "", + "", + "rewards" + ], + [ + "McDonald's", + "BOGO Big Mac", + "", + "06/08", + "", + "", + "", + "4.59", + "rewards" + ], + [ + "Rival House", + "10% off (birthday)", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "Free side with order", + "", + "", + "06/10", + "06/13", + "", + "", + "rewards" + ], + [ + "Smash Burger", + "$15 with $60 gift card purchase", + "", + "", + "06/10", + "06/16", + "", + "", + "promotion" + ], + [ + "Longfellow Grill", + "$5 Freehouse beers 18:00 - close for dad", + "", + "", + "06/16", + "06/16", + "", + "", + "promotion" + ], + [ + "Highland Grill", + "$5 Freehouse beers 18:00 - close for dad", + "", + "", + "06/16", + "06/16", + "", + "", + "promotion" + ], + [ + "Qdoba", + "Buy $50 gift card get $10 to use between 07/01/24 and 08/31/24", + "", + "", + "05/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Afro Deli", + "5% back from T-Mobile dining rewards", + "", + "06/12", + "", + "", + "", + "0.71" + ], + [ + "Afro Deli", + "$10 off $10 or more from T-Mobile dining rewards", + "", + "06/12", + "06/11", + "06/17", + "", + "10" + ], + [ + "Leeann Chin", + "25% off $20", + "", + "", + "06/12", + "06/18", + "", + "", + "rewards" + ], + [ + "Smash Burger", + "$1 tots every Thursday", + "", + "", + "06/13", + "7/11", + "", + "", + "rewards" + ], + [ + "Red Rabbit", + "1 free beer for dad dining in", + "", + "", + "06/16", + "06/16", + "", + "", + "promotion" + ], + [ + "Red Lobster", + "Buy $50 gift card get two $10 gift cards. First gift card good 07/2/24 - 07/31/24; second 08/01/24 - 08/31/24. Both good only when spending $40 exclusive of alcohol, tax, gratiuity, and other gift cards.", + "", + "", + "", + "07/01", + "", + "", + "promotion" + ], + [ + "Qdoba", + "$3 off for joining rewards", + "", + "", + "", + "06/14", + "", + "", + "rewards" + ], + [ + "Lund's & Byerly's", + "$10 off $100 online order with code NEWSITE", + "", + "", + "05/21", + "06/30", + "", + "", + "promotion" + ], + [ + "Door Dash ", + "25% off $12 or more order", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Subway", + "BOGO sandwich with code FLBOGO", + "", + "06/16", + "06/12", + "06/22", + "", + "8.59", + "promotion" + ], + [ + "Subway ", + "5% cash back via credit card", + "", + "06/16", + "", + "06/30", + "", + "0.43" + ], + [ + "Jersey Mike's", + "10% cash back via credit card", + "", + "", + "", + "06/29" + ], + [ + "CVS", + "20% cash back via credit card", + "", + "06/16", + "", + "06/29", + "", + "2.26" + ], + [ + "Buffalo Wild Wings", + "$10 coupon valid 6/17/24–7/31/24 with purchase of $40 gift card", + "", + "", + "05/28", + "06/16", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "$3 off $15", + "", + "", + "06/17", + "06/19", + "", + "", + "rewards" + ], + [ + "Taco John's", + "$5 off for three visits", + "", + "", + "06/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Buffalo Wild Wings", + "6 free wings ", + "", + "", + "", + "06/26", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "$5 off $25", + "", + "", + "", + "06/19", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "All you can eat wings and fries Mondays and Wednesdays", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "BOGO wings Tuesdays", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Slice Brothers", + "$5 off (birthday month)", + "", + "", + "06/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Buttered Tin", + "$5 off (birthday month)", + "", + "", + "06/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Arby's", + "$1 shake with deluxe burger purchase (once per day)", + "", + "", + "", + "06/30", + "", + "", + "rewards" + ], + [ + "My Burger", + "$5 off $15 lunch order with MACFIVE", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "My Burger", + "%15 off online order with MACFIFTEEN", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "Iron Ranger", + "10% off $50 dine-in", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "Green Mill", + "$5 off $25", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Green Mill", + "BOGO take & bake pizza", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "FireBox BBQ", + "$5 off $20", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "FireBox BBQ", + "$10 off Firebox Feast", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Habañero Tacos", + "Free taco when you mention ad in mailer", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "Habañero Tacos", + "$5 off $15", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Potsticker", + "$5 off $20", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Potsticker", + "$10 off $40", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Maverick's Pizza", + "$5 off $30 except Fridays", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Billy's", + "$5 off $20", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Billy's", + "$10 off $40", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Uptowner", + "$5 off $25", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Subway", + "BOGO sandwich with code FLBOGO", + "", + "06/18", + "06/12", + "06/22", + "", + "9.77", + "promotion" + ], + [ + "Subway ", + "5% cash back via credit card", + "", + "06/18", + "", + "06/30", + "", + "0.48" + ], + [ + "Leeann Chin", + "2 entrees for $18 by following instructions on Instagram", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Portillos's", + "Buy 1 sandwich, side, and drink and get a sandwich free", + "", + "06/22", + "", + "", + "They gave me credit for the sandwich that was $9.79 and charged me for the hot dog that was $4.29", + "9.79", + "coupon card from the Saints game" + ], + [ + "Jimmy John's", + "Buy one Firecracker Wrap and score 50% off your next wrap", + "", + "", + "06/20", + "06/25", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$5 off $20", + "", + "", + "", + "06/28", + "", + "", + "rewards" + ], + [ + "Pino's Pizzaria", + "$9 for two slices and a drink", + "", + "06/27", + "", + "", + "", + "2", + "deal" + ], + [ + "Domino's", + "Free dessert with $10 order", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Leeann Chin", + "$5 off $20", + "", + "", + "06/26", + "07/02", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$2 off $10", + "", + "", + "", + "07/03", + "", + "", + "rewards" + ], + [ + "Taco John's", + "$5 for visiting 3 times after 7:00 PM", + "", + "", + "07/01", + "07/31", + "", + "", + "rewards" + ], + [ + "Buffalo Wild Wings", + "$7 off $25", + "", + "", + "", + "07/03", + "", + "", + "promotion" + ], + [ + "Dairy Queen", + "$3 off a 6-pc Chicken Strip Basket with Drink Purchase", + "", + "", + "", + "07/05", + "", + "", + "rewards" + ], + [ + "Domino's", + "Sign up for text alerts and get 20% off next order", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "Free side: pickle, cookie, brownie or chips", + "", + "", + "", + "07/16", + "", + "", + "rewards" + ], + [ + "Subway", + "20% off any order with code TWENTYOFF", + "", + "07/03", + "", + "08/28", + "", + "2.42", + "promotion" + ], + [ + "Leeann Chin", + "BOGO 50% off with Instagram post: Follow us on Instagram, like this post, and show this offer to the cashier to redeem.", + "", + "", + "", + "07/09", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "$5.99 sandwich offer for rewards members valid for 3 days", + "", + "", + "", + "07/06", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "BOGO free firecracker wrap", + "", + "", + "07/04", + "07/04", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "$5 off $20", + "", + "", + "", + "07/06", + "", + "", + "rewards" + ], + [ + "Arby's", + "$4 gyro", + "", + "", + "", + "07/15", + "", + "", + "rewards" + ], + [ + "Buffalo Wild Wings", + "6 free wings with $10 purchase with promo GOWINGS", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Taco John's", + "Free fried chicken taco with $3 purchase", + "", + "", + "07/06", + "07/06", + "", + "", + "promotion" + ], + [ + "Domino's", + "Tip $3 get $3 off next week's order", + "", + "", + "", + "07/15", + "", + "", + "promotion" + ], + [ + "India Palace", + "%5 back with T-Mobile dining rewards", + "", + "07/06", + "", + "", + "", + "1.62" + ], + [ + "Chipotle", + "125 extra points with entree", + "", + "", + "07/08", + "07/14", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$4.99 regular sandwich", + "", + "07/11", + "", + "07/12", + "", + "3.06", + "rewards" + ], + [ + "Leeann Chin", + "$5 off $20", + "", + "", + "", + "07/16", + "", + "", + "rewards" + ], + [ + "Smash Burger", + "Free fries with purchase using code FRYDAY24", + "", + "", + "07/12", + "07/12", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "$5 off $20", + "", + "", + "", + "07/17", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "Free brownie", + "", + "", + "", + "09/09", + "", + "", + "rewards" + ], + [ + "Subway", + "5% cash back", + "", + "", + "", + "07/31", + "", + "", + "rewards" + ], + [ + "Leeann Chin", + "Buy two entrees get one free with Instagram post", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Rival House", + "20% off for birthday", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$5 off $20", + "", + "", + "", + "07/21", + "", + "", + "rewards" + ], + [ + "Domino's", + "35% off when you pay with Venmo", + "", + "", + "7/15", + "08/11", + "", + "", + "promotion" + ] + ] + } + recorded_at: Sat, 12 Oct 2024 22:35:59 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/fixtures/vcr_cassettes/get_spreadsheet_values_range.yml b/spec/fixtures/vcr_cassettes/get_spreadsheet_values_range.yml new file mode 100644 index 0000000..01b2b2c --- /dev/null +++ b/spec/fixtures/vcr_cassettes/get_spreadsheet_values_range.yml @@ -0,0 +1,1243 @@ +--- +http_interactions: +- request: + method: post + uri: https://www.googleapis.com/oauth2/v4/token + body: + encoding: ASCII-8BIT + string: grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJzdHAtZm9vZC1zZXJ2aWNlQHN0cC1mb29kLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwiYXVkIjoiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vb2F1dGgyL3Y0L3Rva2VuIiwiZXhwIjoxNzI4NzcyNjE4LCJpYXQiOjE3Mjg3NzI0OTgsInNjb3BlIjoiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vYXV0aC9kcml2ZS5yZWFkb25seSJ9.C7iPR9Lavlv44wtQcNs2orahR_Er7QjjBn7TJTMfd7lI5eE3tRC2ixwuS1oGEXPG1ColjAc3gojKFtJxTJsWUYiCTwdFk1Kx6U8lBJV_sNY8F8Y_LxiDfS8zGPldXJ5RBabHRzJofRfXPOK1q6M8IpPgoK1jV3ilynfnUajlwpmhIcHUOeGmu0h2XxHzcXgKhJFBxVRw5PjOmdC0EOqyGIC6KVu2JJKPDhZ-LE4WCNuiFZIEfNY2huzxKYxhTz-C9dWkmlS2TDeGkWLWsD1QLN3p5D2TCO3V3jmQ3SQpncbSZQ475OcpRdCnAnByo49qVxR8U6lR6XEdqQbwKInibg + headers: + User-Agent: + - Faraday v2.12.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=UTF-8 + Vary: + - Origin + - Referer + - X-Origin + Date: + - Sat, 12 Oct 2024 22:35:58 GMT + Server: + - scaffolding on HTTPServer2 + Cache-Control: + - private + X-Xss-Protection: + - '0' + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + Transfer-Encoding: + - chunked + body: + encoding: ASCII-8BIT + string: '{"access_token":"ya29.c.c0ASRK0GbFIkrrzSnGUpIS3wiTPBIJGQZLMy78KWhu-et3-yUzcuy-219qqUZoHTfuXUB9IkW-qgQn9my7j5KYKaENaHK3H--SbiBCIU0u4NnEUz_ydHIDDwmPD12jykdTvlah89EdPm3ITP00Lwd-TmFBtsRCPnHhcqGxE_qYivEliNHIoiSnuzOnle43iiopj4rFCKaeIer8U5rBzix8dzpN9c3ktGXhy3jXKvxSItiz180Z-l7mFulztaB-09nHG4BxdxAFDDdi9Z3jdx4J6sQa9sgV0k0ULvawiGr0g-EdPOc-EBmoUPtRGahrKepkslgMDma_JsmwO-Lskv79JtpYN6KsuRv1oiLm25J0zAao0JclzMXlc3VwN385DJFrl_uFqVMkaetr3RvBnUdU3xnxRM93arssih09Ulwv9BFl2WdWb6rXmQ6f09q8JU0aW-7noSYZobfs5Ob-3Q6WS3VzppzFFoFnF9wx40iU8Z619ckuZy429haWyj1U52XmBpwux_mWjZQatJFZ0yeqhbof9vVdmFY_ncjgojQfe54_srtm3S2lnexejs4q6ozJaZqItcqjtsu9pr_JwF-myfJjS54IaOue82p34Mx_zz4vnvuUI7Ieapid6XqfxMwUqJS6luQxf1U8-9l5qOwl-qx29wSi0WWbkQVj-8n2Rj7pn33V48JihwOMjIJW6i5oRUwyBgkQMif2y-xWSW4fRrlVBc417020B9tt4imnmelcwsX-vfWBUuIlO35w0S1bmMixgwdbX8Yn9lZr1Uv3f5VeFev48k59q7gwSR9uZZdg7Z3qfw_ZX7YBttFvXFjn_nwy8Va0aoRRw9o3r0euJ0nv_fSBywpYb_wjSVb9kmOdbqa5mzeV4jiv8x_xqo-vOy5ZmVyyv6qsjSWtfBq3U62xOUQYhZzxj5yXFh1yBYJv38zb_7JkSoZcQ4SS8-qUp4pf7zd-MUum2jmq6FsFlUre5U9lXZlY5bxI760cSbpzMXQerMVWcj4","expires_in":3599,"token_type":"Bearer"}' + recorded_at: Sat, 12 Oct 2024 22:35:58 GMT +- request: + method: get + uri: https://sheets.googleapis.com/v4/spreadsheets//values/Log!A:Z + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - unknown/0.0.0 google-apis-sheets_v4/0.36.0 Mac OS X/14.6.1 (gzip) + Accept: + - "*/*" + Accept-Encoding: + - gzip,deflate + Date: + - Sat, 12 Oct 2024 22:35:58 GMT + X-Goog-Api-Client: + - gl-ruby/3.3.5 gdcl/1.36.0 + Authorization: + - Bearer ya29.c.c0ASRK0GbFIkrrzSnGUpIS3wiTPBIJGQZLMy78KWhu-et3-yUzcuy-219qqUZoHTfuXUB9IkW-qgQn9my7j5KYKaENaHK3H--SbiBCIU0u4NnEUz_ydHIDDwmPD12jykdTvlah89EdPm3ITP00Lwd-TmFBtsRCPnHhcqGxE_qYivEliNHIoiSnuzOnle43iiopj4rFCKaeIer8U5rBzix8dzpN9c3ktGXhy3jXKvxSItiz180Z-l7mFulztaB-09nHG4BxdxAFDDdi9Z3jdx4J6sQa9sgV0k0ULvawiGr0g-EdPOc-EBmoUPtRGahrKepkslgMDma_JsmwO-Lskv79JtpYN6KsuRv1oiLm25J0zAao0JclzMXlc3VwN385DJFrl_uFqVMkaetr3RvBnUdU3xnxRM93arssih09Ulwv9BFl2WdWb6rXmQ6f09q8JU0aW-7noSYZobfs5Ob-3Q6WS3VzppzFFoFnF9wx40iU8Z619ckuZy429haWyj1U52XmBpwux_mWjZQatJFZ0yeqhbof9vVdmFY_ncjgojQfe54_srtm3S2lnexejs4q6ozJaZqItcqjtsu9pr_JwF-myfJjS54IaOue82p34Mx_zz4vnvuUI7Ieapid6XqfxMwUqJS6luQxf1U8-9l5qOwl-qx29wSi0WWbkQVj-8n2Rj7pn33V48JihwOMjIJW6i5oRUwyBgkQMif2y-xWSW4fRrlVBc417020B9tt4imnmelcwsX-vfWBUuIlO35w0S1bmMixgwdbX8Yn9lZr1Uv3f5VeFev48k59q7gwSR9uZZdg7Z3qfw_ZX7YBttFvXFjn_nwy8Va0aoRRw9o3r0euJ0nv_fSBywpYb_wjSVb9kmOdbqa5mzeV4jiv8x_xqo-vOy5ZmVyyv6qsjSWtfBq3U62xOUQYhZzxj5yXFh1yBYJv38zb_7JkSoZcQ4SS8-qUp4pf7zd-MUum2jmq6FsFlUre5U9lXZlY5bxI760cSbpzMXQerMVWcj4 + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=UTF-8 + Vary: + - Origin + - Referer + - X-Origin + Content-Encoding: + - gzip + Date: + - Sat, 12 Oct 2024 22:35:58 GMT + Server: + - ESF + Cache-Control: + - private + X-Xss-Protection: + - '0' + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Alt-Svc: + - h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 + X-L2-Request-Path: + - l2-managed-6 + Transfer-Encoding: + - chunked + body: + encoding: UTF-8 + string: | + { + "range": "Log!A1:Z1000", + "majorDimension": "ROWS", + "values": [ + [ + "Place", + "Deal", + "Deal Earned", + "Deal Used", + "Deal Starts", + "Deal Ends", + "Notes", + "Money Saved", + "Reward Type" + ], + [ + "Slice Brothers", + "2 slices for $5.99", + "", + "03/30", + "", + "", + "no longer active", + "4.99", + "no longer active", + "", + "TOTAL SAVED", + "124.15" + ], + [ + "Slice Brothers", + "2 slices for $5.99", + "", + "04/11", + "", + "", + "no longer active", + "4.99", + "no longer active" + ], + [ + "Pot Belly", + "1 free sandwich with the purchase of sandwich between 04/01 and 04/07", + "04/04", + "04/08", + "04/01", + "04/07", + "", + "10.66", + "rewards" + ], + [ + "Jimmy John's", + "1 free sandwich with purchase of first sandwich online", + "04/15", + "04/23", + "", + "", + "", + "9.76", + "signup offer" + ], + [ + "Jimmy John's", + "$5.99 sandwich offer for rewards members valid for 3 days", + "05/01", + "05/03", + "", + "05/03", + "", + "3.06", + "rewards" + ], + [ + "Cassie's", + "$7.99 sandwich and fries", + "", + "05/01", + "", + "", + "$8.78 with tax", + "1.48", + "daily deal" + ], + [ + "Skyway New Masala", + "10% off Wednesdays", + "", + "05/08", + "", + "", + "", + "1.2", + "daily deal" + ], + [ + "Afro Deli", + "5% back through T-Mobile", + "", + "05/09", + "", + "", + "", + "0.6" + ], + [ + "Pot Belly", + "5% back through my credit card", + "", + "", + "", + "06/10" + ], + [ + "Subway ", + "5% back through my credit card", + "", + "05/10", + "", + "05/13", + "", + "0.43" + ], + [ + "Subway", + "BOGO with code FLBOGO", + "", + "05/10", + "", + "5/15", + "", + "8.77", + "promotion" + ], + [ + "White Castle", + "$25 gift cards for $19.21", + "", + "", + "", + "05/31", + "", + "", + "promotion" + ], + [ + "My Burger", + "20% off with code TWOLVES20", + "", + "", + "", + "05/22", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "Free dessert", + "", + "", + "", + "06/01", + "", + "", + "rewards" + ], + [ + "Rival House", + "20% off all menu items", + "", + "", + "", + "06/30", + "", + "", + "rewards" + ], + [ + "Chipotle", + "BOGO buritto when order through GrubHub", + "", + "06/03", + "", + "", + "", + "11.7" + ], + [ + "Pizza Luce", + "Fee appetizer with specialty pizza coupon", + "", + "06/04", + "", + "", + "", + "10.79", + "mailer" + ], + [ + "Domino's", + "50% off all menu-priced pizzas with code 9413", + "", + "", + "06/03", + "06/09", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$2 off $10 online or using the app", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Arby's", + "5 for $5 online or using the app", + "", + "", + "06/10", + "06/15", + "", + "", + "promotion" + ], + [ + "Leeann Chin", + "BOGO 50% off with Instagram post: Follow us on Instagram, like this post, and show this offer to the cashier to redeem.", + "", + "", + "06/05", + "06/11", + "", + "", + "promotion" + ], + [ + "Culver's", + "Free single scoop of frozen custard with one topping (birthday)", + "", + "", + "06/06", + "06/20", + "", + "", + "rewards" + ], + [ + "McDonald's", + "BOGO Big Mac", + "", + "06/08", + "", + "", + "", + "4.59", + "rewards" + ], + [ + "Rival House", + "10% off (birthday)", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "Free side with order", + "", + "", + "06/10", + "06/13", + "", + "", + "rewards" + ], + [ + "Smash Burger", + "$15 with $60 gift card purchase", + "", + "", + "06/10", + "06/16", + "", + "", + "promotion" + ], + [ + "Longfellow Grill", + "$5 Freehouse beers 18:00 - close for dad", + "", + "", + "06/16", + "06/16", + "", + "", + "promotion" + ], + [ + "Highland Grill", + "$5 Freehouse beers 18:00 - close for dad", + "", + "", + "06/16", + "06/16", + "", + "", + "promotion" + ], + [ + "Qdoba", + "Buy $50 gift card get $10 to use between 07/01/24 and 08/31/24", + "", + "", + "05/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Afro Deli", + "5% back from T-Mobile dining rewards", + "", + "06/12", + "", + "", + "", + "0.71" + ], + [ + "Afro Deli", + "$10 off $10 or more from T-Mobile dining rewards", + "", + "06/12", + "06/11", + "06/17", + "", + "10" + ], + [ + "Leeann Chin", + "25% off $20", + "", + "", + "06/12", + "06/18", + "", + "", + "rewards" + ], + [ + "Smash Burger", + "$1 tots every Thursday", + "", + "", + "06/13", + "7/11", + "", + "", + "rewards" + ], + [ + "Red Rabbit", + "1 free beer for dad dining in", + "", + "", + "06/16", + "06/16", + "", + "", + "promotion" + ], + [ + "Red Lobster", + "Buy $50 gift card get two $10 gift cards. First gift card good 07/2/24 - 07/31/24; second 08/01/24 - 08/31/24. Both good only when spending $40 exclusive of alcohol, tax, gratiuity, and other gift cards.", + "", + "", + "", + "07/01", + "", + "", + "promotion" + ], + [ + "Qdoba", + "$3 off for joining rewards", + "", + "", + "", + "06/14", + "", + "", + "rewards" + ], + [ + "Lund's & Byerly's", + "$10 off $100 online order with code NEWSITE", + "", + "", + "05/21", + "06/30", + "", + "", + "promotion" + ], + [ + "Door Dash ", + "25% off $12 or more order", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Subway", + "BOGO sandwich with code FLBOGO", + "", + "06/16", + "06/12", + "06/22", + "", + "8.59", + "promotion" + ], + [ + "Subway ", + "5% cash back via credit card", + "", + "06/16", + "", + "06/30", + "", + "0.43" + ], + [ + "Jersey Mike's", + "10% cash back via credit card", + "", + "", + "", + "06/29" + ], + [ + "CVS", + "20% cash back via credit card", + "", + "06/16", + "", + "06/29", + "", + "2.26" + ], + [ + "Buffalo Wild Wings", + "$10 coupon valid 6/17/24–7/31/24 with purchase of $40 gift card", + "", + "", + "05/28", + "06/16", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "$3 off $15", + "", + "", + "06/17", + "06/19", + "", + "", + "rewards" + ], + [ + "Taco John's", + "$5 off for three visits", + "", + "", + "06/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Buffalo Wild Wings", + "6 free wings ", + "", + "", + "", + "06/26", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "$5 off $25", + "", + "", + "", + "06/19", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "All you can eat wings and fries Mondays and Wednesdays", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "BOGO wings Tuesdays", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Slice Brothers", + "$5 off (birthday month)", + "", + "", + "06/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Buttered Tin", + "$5 off (birthday month)", + "", + "", + "06/01", + "06/30", + "", + "", + "rewards" + ], + [ + "Arby's", + "$1 shake with deluxe burger purchase (once per day)", + "", + "", + "", + "06/30", + "", + "", + "rewards" + ], + [ + "My Burger", + "$5 off $15 lunch order with MACFIVE", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "My Burger", + "%15 off online order with MACFIFTEEN", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "Iron Ranger", + "10% off $50 dine-in", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "Green Mill", + "$5 off $25", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Green Mill", + "BOGO take & bake pizza", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "FireBox BBQ", + "$5 off $20", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "FireBox BBQ", + "$10 off Firebox Feast", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Habañero Tacos", + "Free taco when you mention ad in mailer", + "", + "", + "", + "", + "", + "", + "mailer" + ], + [ + "Habañero Tacos", + "$5 off $15", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Potsticker", + "$5 off $20", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Potsticker", + "$10 off $40", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Maverick's Pizza", + "$5 off $30 except Fridays", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Billy's", + "$5 off $20", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Billy's", + "$10 off $40", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Uptowner", + "$5 off $25", + "", + "", + "", + "08/31", + "", + "", + "mailer" + ], + [ + "Subway", + "BOGO sandwich with code FLBOGO", + "", + "06/18", + "06/12", + "06/22", + "", + "9.77", + "promotion" + ], + [ + "Subway ", + "5% cash back via credit card", + "", + "06/18", + "", + "06/30", + "", + "0.48" + ], + [ + "Leeann Chin", + "2 entrees for $18 by following instructions on Instagram", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Portillos's", + "Buy 1 sandwich, side, and drink and get a sandwich free", + "", + "06/22", + "", + "", + "They gave me credit for the sandwich that was $9.79 and charged me for the hot dog that was $4.29", + "9.79", + "coupon card from the Saints game" + ], + [ + "Jimmy John's", + "Buy one Firecracker Wrap and score 50% off your next wrap", + "", + "", + "06/20", + "06/25", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$5 off $20", + "", + "", + "", + "06/28", + "", + "", + "rewards" + ], + [ + "Pino's Pizzaria", + "$9 for two slices and a drink", + "", + "06/27", + "", + "", + "", + "2", + "deal" + ], + [ + "Domino's", + "Free dessert with $10 order", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Leeann Chin", + "$5 off $20", + "", + "", + "06/26", + "07/02", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$2 off $10", + "", + "", + "", + "07/03", + "", + "", + "rewards" + ], + [ + "Taco John's", + "$5 for visiting 3 times after 7:00 PM", + "", + "", + "07/01", + "07/31", + "", + "", + "rewards" + ], + [ + "Buffalo Wild Wings", + "$7 off $25", + "", + "", + "", + "07/03", + "", + "", + "promotion" + ], + [ + "Dairy Queen", + "$3 off a 6-pc Chicken Strip Basket with Drink Purchase", + "", + "", + "", + "07/05", + "", + "", + "rewards" + ], + [ + "Domino's", + "Sign up for text alerts and get 20% off next order", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "Free side: pickle, cookie, brownie or chips", + "", + "", + "", + "07/16", + "", + "", + "rewards" + ], + [ + "Subway", + "20% off any order with code TWENTYOFF", + "", + "07/03", + "", + "08/28", + "", + "2.42", + "promotion" + ], + [ + "Leeann Chin", + "BOGO 50% off with Instagram post: Follow us on Instagram, like this post, and show this offer to the cashier to redeem.", + "", + "", + "", + "07/09", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "$5.99 sandwich offer for rewards members valid for 3 days", + "", + "", + "", + "07/06", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "BOGO free firecracker wrap", + "", + "", + "07/04", + "07/04", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "$5 off $20", + "", + "", + "", + "07/06", + "", + "", + "rewards" + ], + [ + "Arby's", + "$4 gyro", + "", + "", + "", + "07/15", + "", + "", + "rewards" + ], + [ + "Buffalo Wild Wings", + "6 free wings with $10 purchase with promo GOWINGS", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Taco John's", + "Free fried chicken taco with $3 purchase", + "", + "", + "07/06", + "07/06", + "", + "", + "promotion" + ], + [ + "Domino's", + "Tip $3 get $3 off next week's order", + "", + "", + "", + "07/15", + "", + "", + "promotion" + ], + [ + "India Palace", + "%5 back with T-Mobile dining rewards", + "", + "07/06", + "", + "", + "", + "1.62" + ], + [ + "Chipotle", + "125 extra points with entree", + "", + "", + "07/08", + "07/14", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$4.99 regular sandwich", + "", + "07/11", + "", + "07/12", + "", + "3.06", + "rewards" + ], + [ + "Leeann Chin", + "$5 off $20", + "", + "", + "", + "07/16", + "", + "", + "rewards" + ], + [ + "Smash Burger", + "Free fries with purchase using code FRYDAY24", + "", + "", + "07/12", + "07/12", + "", + "", + "promotion" + ], + [ + "Buffalo Wild Wings", + "$5 off $20", + "", + "", + "", + "07/17", + "", + "", + "promotion" + ], + [ + "Jimmy John's", + "Free brownie", + "", + "", + "", + "09/09", + "", + "", + "rewards" + ], + [ + "Subway", + "5% cash back", + "", + "", + "", + "07/31", + "", + "", + "rewards" + ], + [ + "Leeann Chin", + "Buy two entrees get one free with Instagram post", + "", + "", + "", + "", + "", + "", + "promotion" + ], + [ + "Rival House", + "20% off for birthday", + "", + "", + "", + "", + "", + "", + "rewards" + ], + [ + "Jimmy John's", + "$5 off $20", + "", + "", + "", + "07/21", + "", + "", + "rewards" + ], + [ + "Domino's", + "35% off when you pay with Venmo", + "", + "", + "7/15", + "08/11", + "", + "", + "promotion" + ] + ] + } + recorded_at: Sat, 12 Oct 2024 22:35:58 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/sheet_zoukas/google_sheets_spec.rb b/spec/sheet_zoukas/google_sheets_spec.rb new file mode 100644 index 0000000..ce1a84f --- /dev/null +++ b/spec/sheet_zoukas/google_sheets_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'sheet_zoukas/google_sheets' + +RSpec.describe SheetZoukas::GoogleSheets do + describe '#initialize' do + it 'uses default scope' do + ret = described_class.new.instance_variable_get(:@authorizer).scope + expect(ret.first).to eq(described_class::DEFAULT_SCOPE) + end + + it 'uses passed-in scope' do + scope = 'https://www.googleapis.com/auth/spreadsheets' + ret = described_class.new(scope).instance_variable_get(:@authorizer).scope + expect(ret.first).to eq(scope) + end + end + + describe '.create_range' do + it 'returns range when no tab' do + range = described_class.send :create_range, 'sheet_2' + expect(range).to eq('sheet_2') + end + + it 'returns range and tab when no tab' do + range = described_class.send :create_range, 'sheet_2', 'A1:B2' + expect(range).to eq('sheet_2!A1:B2') + end + end + + describe '#retrieve_sheet' do + it 'retrieves sheet with range' do + VCR.use_cassette('get_spreadsheet_values_range') do + sheet = described_class.new.retrieve_sheet(ENV.fetch('GOOGLE_API_SPREADSHEET_ID', nil), 'Log', 'A:Z') + expect(sheet.values.first).to include('Reward Type') + end + end + + it 'retrieves sheet without range' do + VCR.use_cassette('get_spreadsheet_values_no_range') do + sheet = described_class.new.retrieve_sheet(ENV.fetch('GOOGLE_API_SPREADSHEET_ID', nil), 'Log') + expect(sheet.values.first).to include('Reward Type') + end + end + end +end diff --git a/spec/sheet_zoukas_spec.rb b/spec/sheet_zoukas_spec.rb index c837e1b..bc9b846 100644 --- a/spec/sheet_zoukas_spec.rb +++ b/spec/sheet_zoukas_spec.rb @@ -4,8 +4,4 @@ it 'has a version number' do expect(SheetZoukas::VERSION).not_to be_nil end - - # it 'does something useful' do - # expect(false).to eq(true) - # end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5256c05..71572f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,9 +2,14 @@ require 'sheet_zoukas' require 'simplecov' +require 'vcr' +require 'webmock/rspec' + +require 'byebug' SimpleCov.start do enable_coverage :branch + add_filter 'spec/' end RSpec.configure do |config| @@ -18,3 +23,28 @@ c.syntax = :expect end end + +VCR.configure do |config| + config.cassette_library_dir = 'spec/fixtures/vcr_cassettes' + config.hook_into :webmock + config.filter_sensitive_data('') { ENV.fetch('GOOGLE_API_KEY', nil) } + config.filter_sensitive_data('') { ENV.fetch('GOOGLE_API_SPREADSHEET_ID', nil) } +end + +REQUIRED_VARS = %w[GOOGLE_ACCOUNT_TYPE GOOGLE_API_KEY GOOGLE_CLIENT_EMAIL GOOGLE_CLIENT_ID GOOGLE_PRIVATE_KEY + GOOGLE_API_SPREADSHEET_ID].freeze + +def check_vars + err = false + REQUIRED_VARS.each do |var| + if ENV.fetch(var, nil)&.chars + puts "✅ #{var}" + else + err = true + puts "⛔️ #{var} required for tests to run." + end + end + exit 1 if err +end + +check_vars