autoluv 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2c1c9582dd640d1f41544e3d6d417b49c95f0f4b3e6cf962c5c7e620c27e038
4
- data.tar.gz: f87e3add36257d549c375819d30593f98fff083fa0f317c9a729dc69287fe9f6
3
+ metadata.gz: 1d51c73c3127c1247d9aa92393cb6564946e0f59fadd1e40fd50c5b01c3c1ee4
4
+ data.tar.gz: 2533c26d888db4d95cafc1165d59423d2d287485a85a271e74b3687dabb7bfb8
5
5
  SHA512:
6
- metadata.gz: 58627856f17db2626d9d0a982c22aa5db0d850bf4a7621835d80fd92c192050a1525cac1cba298b6e103808d879dba64695528b8c5a7b8bd520333db68a5f737
7
- data.tar.gz: d60afa6416e62aa9755270dc820e58df3fd1337a6ee262ab5c90ac03dddf1e86e5b67bdad61753c2e9ce7fda792bebb58d9ec46909ac6078946caec1e2f4995a
6
+ metadata.gz: de5f6df35800981ad99500975c96143d8596ab5cd42437e335c622e246d0dde50ee5790ee134e7eb2356324a5d0a53c993ff6f1101c659bf71dc6161c6033546
7
+ data.tar.gz: c70a7031a4e27844ff6cfd1579c42b6e746abeca6488d57075a025a17409105d27c85f89365734651e57b9d3e0b79e4776d6c69fcfb837ecde68ce2a1cd61047
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  .DS_Store
2
2
  /*.gem
3
3
  /logs/
4
+ /pkg/
5
+ /Gemfile.lock
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "rake", "~> 13.0"
data/README.md CHANGED
@@ -2,86 +2,119 @@
2
2
 
3
3
  Automatically check in to Southwest flights using this easy-to-use gem. It'll also email you the results so you know ASAP whether a check in was successful. Seconds count when you're fighting for that window or aisle seat!
4
4
 
5
+ ## Requirements
6
+
7
+ * A *nix-based server that will be on when you need to check in
8
+ * Ruby 2.3 or higher
9
+ * The `at` command
10
+
11
+ Tested and working on an Ubuntu 20.04 server (hosted by DigitalOcean).
12
+
5
13
  ## Installation
6
14
 
15
+ ### Get Southwest Headers
16
+
17
+ The Southwest API now requires some randomly generated headers to check in. Because these headers change at a set interval, they need to be constantly refreshed for any check-in script (like this one) to work. To get these headers, please follow the instructions here:
18
+
19
+ https://github.com/byalextran/southwest-headers
20
+
21
+ Once a cron job has been scheduled, do these steps:
22
+
23
+ **Step 1:** Create the file `.autoluv.env` in your user's home directory.
24
+
25
+ nano ~/.autoluv.env
26
+
27
+ **Step 2:** Copy/paste the following into the text editor.
28
+
29
+ LUV_HEADERS_FILE = /PATH/TO/southwest_headers.json
30
+
31
+ **Step 3:** Update the path (and filename if changed from the default) to the correct path of the headers file.
32
+
33
+ **Step 4:** Hit `Ctrl+O` to save the file and then `Ctrl+X` to exit the text editor.
34
+
35
+ ### Install Gem
36
+
7
37
  gem install autoluv
8
38
 
9
39
  ## Usage
10
40
 
11
- ### Schedule a Check In
41
+ ### Schedule a Check-In
12
42
 
13
- # both departing and returning flights (if applicable) are scheduled.
14
43
  autoluv schedule ABCDEF John Doe
15
44
 
16
- # wrap names in double quotes if they have spaces
17
- autoluv schedule ABCDEF "John Doe" Smith
45
+ Both departing and returning flights (if applicable) will be scheduled for all passengers tied to the confirmation number. After scheduling, there's no need to keep the terminal window open or active. The check in will happen behind the scenes at the appropriate time.
46
+
47
+ **Note:** If a first or last name includes a space, wrap it in double quotes (e.g. "Mary Kate")
18
48
 
19
- ### Schedule a Check In With Email Notification
49
+ ### Schedule a Check-In With Email Notification
20
50
 
21
- Make sure you follow the instructions below for configuring email notifications.
51
+ Before using this command, follow the instructions below to configure the required settings.
22
52
 
23
- autoluv schedule ABCDEF John Doe john.doe@helloworld.com
53
+ autoluv schedule ABCDEF John Doe john.doe@email.com optional@bcc.com
24
54
 
25
- # you can optionally specify a second email address as well. useful if you
26
- # schedule flights for friends but also want to be notified of the results.
27
- # NOTE: put your email address in the first field and your friend's in the second.
28
- autoluv schedule ABCDEF John Doe your.email@helloworld.com john.doe@helloworld.com
55
+ The second email address is optional and will be BCCed the results.
29
56
 
30
57
  ### Check In Immediately
31
58
 
32
- autoluv checkin ABCDEF Jane Doe
59
+ autoluv checkin ABCDEF John Doe
33
60
 
34
61
  ## Configure Email Notifications
35
62
 
36
- This is optional, however, highly recommended. Especially if a scheduled check in fails, you'll get notified and can manually check in. Every second counts!
63
+ This is optional, however, highly recommended. Especially if a scheduled check-in fails, you'll get notified and can manually check in. Every second counts!
37
64
 
38
- On a successful check in, the email will share boarding positions for each passenger.
65
+ Boarding positions are shown for each passenger when a check-in succeeds.
39
66
 
40
- ### Step 1
67
+ **Step 1:** Open/create the file `.autoluv.env` in your user's home directory.
41
68
 
42
- Create the file `.autoluv.env` in your user's home directory.
69
+ nano ~/.autoluv.env
43
70
 
44
- cd ~
45
- nano .autoluv.env
46
-
47
- ### Step 2
48
-
49
- Copy/paste the following in the text editor.
71
+ **Step 2:** Copy/paste the following into the text editor.
50
72
 
51
73
  ```
52
- LUV_FROM_EMAIL = sendfrom@thisemail.com
53
- LUV_USER_NAME = loginfrom@thisemail.com
74
+ LUV_FROM_EMAIL = from@email.com
75
+ LUV_USER_NAME = from@email.com
54
76
  LUV_PASSWORD = supersecurepassword
55
- LUV_SMTP_SERVER = smtp.emailserver.com
77
+ LUV_SMTP_SERVER = smtp.email.com
56
78
  LUV_PORT = 587
57
79
  ```
58
80
 
59
- ### Step 3
81
+ **Step 3:** Replace the values with the appropriate SMTP settings for your email provider. `LUV_FROM_EMAIL` should be the email address associated with `LUV_USER_NAME`.
82
+
83
+ If your email account has two-factor authentication enabled, be sure to use an app-specific password and *not* your account password.
60
84
 
61
- Replace the values with the appropriate SMTP settings for your email provider and save the file (`Ctrl+O` to save, `Ctrl+X` to exit the editor).
85
+ **Step 4:** Hit `Ctrl+O` to save the file and then `Ctrl+X` to exit the text editor.
62
86
 
63
- `LUV_FROM_EMAIL` should be the email address associated with `LUV_USER_NAME`.
87
+ ### Test Email Notifications
64
88
 
65
- **Note**: If your email account has two-factor authentication enabled, be sure to use an app-specific password above (and *not* your account password).
89
+ To verify your SMTP settings, schedule a check-in with invalid information and a valid email address.
90
+
91
+ autoluv schedule AAAAAA Fake Name valid@email.com
92
+
93
+ If everything is set up correctly, you'll get an email notifying you of an unsuccessful check-in.
66
94
 
67
95
  ### Get Text Instead of Email Notifications
68
96
 
69
97
  [Use this Zap](https://zapier.com/apps/email/integrations/sms/9241/get-sms-alerts-for-new-email-messages) to get a custom Zapier email address that forwards emails as text messages. It's handy for people like me who don't have email notifications enabled on their phone or computer and want check-in results ASAP.
70
98
 
71
- ### Delete a Scheduled Check In
99
+ ## Manage Check-Ins
100
+
101
+ `autoluv` uses the `at` command behind the scenes to check in at a specific time. Use the related `atq` and `atrm` commands to manage check-ins.
72
102
 
73
- `autoluv` uses the `at` command behind the scenes to check in at a specific time. Use the related `atq` and `atrm` commands to view scheduled check-ins and delete them.
103
+ ### View Scheduled Check-Ins
104
+ Make note of the first column's number.
74
105
 
75
- # view scheduled check ins (make note of the first column's number)
76
106
  atq
77
107
  11 Tue Sep 22 08:05:00 2020 a user
78
108
  12 Mon Sep 28 15:45:00 2020 a user
79
109
  7 Wed Sep 23 11:40:00 2020 a user
80
110
 
81
- # cancel a check in
111
+ ### Cancel a Check-In
112
+
82
113
  atrm 11
83
114
 
84
- # view details about a check in. the last line in the output will show you the confirmation number and name.
115
+ ### View Check-In Details
116
+ The last line in the output will show you the confirmation number and name.
117
+
85
118
  at -c 11
86
119
 
87
120
  ## Update Gem
data/autoluv.gemspec CHANGED
@@ -12,9 +12,12 @@ Gem::Specification.new do |spec|
12
12
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
13
 
14
14
  spec.add_runtime_dependency "rest-client", "~> 2.1.0"
15
- spec.add_runtime_dependency "pony", "~> 1.13.0"
16
- spec.add_runtime_dependency "dotenv", "~> 2.7.0"
17
- spec.add_runtime_dependency "tzinfo", "~> 0.3.0"
15
+ spec.add_runtime_dependency "pony", "~> 1.13.1"
16
+ spec.add_runtime_dependency "dotenv", "~> 2.7.6"
17
+ spec.add_runtime_dependency "tzinfo", "~> 2.0.2"
18
+ spec.add_runtime_dependency "json", "~> 2.3.1"
19
+ spec.add_runtime_dependency "fileutils", "~> 1.4.1"
20
+ spec.add_runtime_dependency "logger", "~> 1.4.2"
18
21
 
19
22
  # Specify which files should be added to the gem when it is released.
20
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -2,11 +2,13 @@ require "rest-client"
2
2
  require "securerandom"
3
3
  require "json"
4
4
  require "tzinfo"
5
+ require "shellwords"
6
+ require "dotenv"
7
+
8
+ Dotenv.load("#{Dir.home}/.autoluv.env")
5
9
 
6
10
  module Autoluv
7
11
  class SouthwestClient
8
- @confirmation_number = @first_name = @last_name = @options = nil
9
-
10
12
  # minimum required headers for all API calls
11
13
  DEFAULT_HEADERS = {
12
14
  "Content-Type": "application/json",
@@ -20,6 +22,8 @@ module Autoluv
20
22
  TIME_ZONES_PATH = File.expand_path("../../data/airport_time_zones.json", __dir__)
21
23
 
22
24
  def self.schedule(confirmation_number, first_name, last_name, to = nil, bcc = nil)
25
+ self.check_for_header_file
26
+
23
27
  flights = self.departing_flights(confirmation_number, first_name, last_name)
24
28
 
25
29
  flights.each_with_index do |flight, x|
@@ -27,7 +31,7 @@ module Autoluv
27
31
 
28
32
  puts "Scheduling flight departing #{flight[:airport_code]} at #{flight[:departure_time]} on #{flight[:departure_date]}."
29
33
 
30
- command = "echo 'autoluv checkin #{confirmation_number} #{first_name} #{last_name} #{to} #{bcc}' | at #{check_in_time.strftime('%I:%M %p %m/%d/%y')}"
34
+ command = "echo 'autoluv checkin #{confirmation_number} #{Shellwords.shellescape(first_name)} #{Shellwords.shellescape(last_name)} #{to} #{bcc}' | at #{check_in_time.strftime('%I:%M %p %m/%d/%y')}"
31
35
  `#{command}`
32
36
 
33
37
  puts unless x == flights.size - 1
@@ -35,6 +39,8 @@ module Autoluv
35
39
  end
36
40
 
37
41
  def self.check_in(confirmation_number, first_name, last_name, to = nil, bcc = nil)
42
+ self.check_for_header_file
43
+
38
44
  check_in = attempt = nil
39
45
 
40
46
  # try checking in multiple times in case the our server time is out of sync with Southwest's.
@@ -46,7 +52,7 @@ module Autoluv
46
52
  begin
47
53
  attempt = x + 1
48
54
  post_data = self.check_in_post_data(confirmation_number, first_name, last_name)
49
- check_in = RestClient.post("#{CHECK_IN_URL}", post_data.to_json, self.headers)
55
+ check_in = RestClient.post("#{CHECK_IN_URL}", post_data.to_json, JSON.parse(File.read(ENV["LUV_HEADERS_FILE"])))
50
56
  break
51
57
  rescue RestClient::ExceptionWithResponse => ewr
52
58
  sleep(1)
@@ -88,6 +94,12 @@ module Autoluv
88
94
  DEFAULT_HEADERS.merge({ "X-User-Experience-ID": SecureRandom.uuid })
89
95
  end
90
96
 
97
+ def self.check_for_header_file
98
+ unless File.exist?(ENV["LUV_HEADERS_FILE"])
99
+ abort "Please create a valid Southwest header file before continuing. Learn more: https://github.com/byalextran/southwest-headers"
100
+ end
101
+ end
102
+
91
103
  def self.departing_flights(confirmation_number, first_name, last_name)
92
104
  reservation = RestClient.get("#{RESERVATION_URL}/#{confirmation_number}?first-name=#{first_name}&last-name=#{last_name}", self.headers)
93
105
  reservation_json = JSON.parse(reservation)
@@ -1,3 +1,3 @@
1
1
  module Autoluv
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/autoluv.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  require "autoluv/version"
2
2
  require "autoluv/southwestclient"
3
3
  require "pony"
4
-
4
+ require "logger"
5
+ require "fileutils"
5
6
  require "dotenv"
7
+
6
8
  Dotenv.load("#{Dir.home}/.autoluv.env")
7
9
 
8
10
  module Autoluv
@@ -55,19 +57,15 @@ module Autoluv
55
57
  # only send an email if we have all the environmental variables set
56
58
  return if PONY_OPTIONS.values.any? &:empty?
57
59
 
58
- # if we're BCCing someone, swap the fields so they don't see your TO address.
59
- # this is really for my personal use-case.
60
- unless bcc.nil?
61
- temp = bcc
62
- to = bcc
63
- bcc = temp
60
+ begin
61
+ Pony.mail(PONY_OPTIONS.merge({
62
+ to: to,
63
+ bcc: bcc,
64
+ subject: subject,
65
+ body: body,
66
+ }))
67
+ rescue => e
68
+ puts e.message
64
69
  end
65
-
66
- Pony.mail(PONY_OPTIONS.merge({
67
- to: to,
68
- bcc: bcc,
69
- subject: subject,
70
- body: body,
71
- }))
72
70
  end
73
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoluv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Tran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-24 00:00:00.000000000 Z
11
+ date: 2021-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -30,42 +30,84 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.13.0
33
+ version: 1.13.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.13.0
40
+ version: 1.13.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dotenv
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.7.0
47
+ version: 2.7.6
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.7.0
54
+ version: 2.7.6
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: tzinfo
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.3.0
61
+ version: 2.0.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.3.0
68
+ version: 2.0.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.3.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.3.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: fileutils
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.4.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.4.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: logger
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.4.2
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.4.2
69
111
  description:
70
112
  email:
71
113
  - hello@alextran.org
@@ -74,10 +116,8 @@ executables:
74
116
  extensions: []
75
117
  extra_rdoc_files: []
76
118
  files:
77
- - ".env"
78
119
  - ".gitignore"
79
120
  - Gemfile
80
- - Gemfile.lock
81
121
  - LICENSE.txt
82
122
  - README.md
83
123
  - Rakefile
@@ -108,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
148
  - !ruby/object:Gem::Version
109
149
  version: '0'
110
150
  requirements: []
111
- rubygems_version: 3.1.2
151
+ rubygems_version: 3.2.32
112
152
  signing_key:
113
153
  specification_version: 4
114
154
  summary: Easy-to-use gem to check in to Southwest flights automatically. Also supports
data/.env DELETED
@@ -1,6 +0,0 @@
1
- TO_EMAIL = hello@alextran.org
2
- FROM_EMAIL = autoluv@outlook.com
3
- SMTP_SERVER = smtp.office365.com
4
- PORT = 587
5
- USER_NAME = autoluv@outlook.com
6
- PASSWORD = cislmkwowwntafuw
data/Gemfile.lock DELETED
@@ -1,45 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- autoluv (0.1.0)
5
- dotenv (~> 2.7.0)
6
- pony (~> 1.13.0)
7
- rest-client (~> 2.1.0)
8
- tzinfo (~> 0.3.0)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- domain_name (0.5.20190701)
14
- unf (>= 0.0.5, < 1.0.0)
15
- dotenv (2.7.6)
16
- http-accept (1.7.0)
17
- http-cookie (1.0.3)
18
- domain_name (~> 0.5)
19
- mail (2.7.1)
20
- mini_mime (>= 0.1.1)
21
- mime-types (3.3.1)
22
- mime-types-data (~> 3.2015)
23
- mime-types-data (3.2020.0512)
24
- mini_mime (1.0.2)
25
- netrc (0.11.0)
26
- pony (1.13.1)
27
- mail (>= 2.0)
28
- rest-client (2.1.0)
29
- http-accept (>= 1.7.0, < 2.0)
30
- http-cookie (>= 1.0.2, < 2.0)
31
- mime-types (>= 1.16, < 4.0)
32
- netrc (~> 0.8)
33
- tzinfo (0.3.57)
34
- unf (0.1.4)
35
- unf_ext
36
- unf_ext (0.0.7.7)
37
-
38
- PLATFORMS
39
- ruby
40
-
41
- DEPENDENCIES
42
- autoluv!
43
-
44
- BUNDLED WITH
45
- 2.1.4