autoluv 0.2.1 → 0.3.1

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: 1fa9c3673d12aa12e12b72694adf279ad740f61766722994a4b2841089db4dee
4
- data.tar.gz: 95c3e70497b34a07facbbda0ae72f2107cf8e43849158022fddc1a4252b09438
3
+ metadata.gz: 6041a300159cacdee0647a8d80cdc02455a9d3b75c05fa3a0425083635975f41
4
+ data.tar.gz: 31f5f4315884761e5943c7f89fe741b985c7f3eb75adab347c693fd1913ef445
5
5
  SHA512:
6
- metadata.gz: 3eb77985fedabc42a7180c42e703e6685c15de245fbdf01d761f2d5ba72e4115c447b2eba6955c5c0a4305c9703e77056facf58daf94d0728c09cb1bb4af8e76
7
- data.tar.gz: df23cb0ac4b2eaeb5a1747f53eed6118556572e667e143be0b2334c8832741a7c22a36fa34ca74b679958503176d1c3c1d3248d8b45192153519858d0989aa69
6
+ metadata.gz: 1e7b8092eb200f0fd8a4db123707fecb6115b325f110bac8b0fbb093e53ece3172c969201faf59fd0ad784b97ed54ba33d39779b577db9f5908d413e057c1035
7
+ data.tar.gz: e4ed6cf0e6149f4acffbcb4b435829d47ac1031f70f35d0b891b3f2658635082879e9ab6d38114322b9454693f5ac0b5d3a3e23d7df94739178038d0f5f6c401
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  /*.gem
3
3
  /logs/
4
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,41 +2,69 @@
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
43
  autoluv schedule ABCDEF John Doe
14
44
 
15
- Both departing and returning flights (if applicable) will be scheduled. 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.
16
-
17
- **Note:** If a name includes a space, wrap it in double quotes (e.g. "John Doe")
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.
18
46
 
19
- ### Schedule a Check In With Email Notification
47
+ **Note:** If a first or last name includes a space, wrap it in double quotes (e.g. "Mary Kate")
20
48
 
21
- Follow the instructions below for configuring email notifications.
49
+ ### Schedule a Check-In With Email Notification
22
50
 
23
- autoluv schedule ABCDEF John Doe john.doe@email.com
51
+ Before using this command, follow the instructions below to configure the required settings.
24
52
 
25
- A second email address can be passed in as well and get the results BCCed to it.
53
+ autoluv schedule ABCDEF John Doe john.doe@email.com optional@bcc.com
26
54
 
27
- autoluv schedule ABCDEF John Doe john.doe@email.com second.email@bcc.com
55
+ The second email address is optional and will be BCCed the results.
28
56
 
29
57
  ### Check In Immediately
30
58
 
31
- autoluv checkin ABCDEF Jane Doe
59
+ autoluv checkin ABCDEF John Doe
32
60
 
33
61
  ## Configure Email Notifications
34
62
 
35
- 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!
36
64
 
37
- 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.
38
66
 
39
- **Step 1:** Create the file `.autoluv.env` in your user's home directory.
67
+ **Step 1:** Open/create the file `.autoluv.env` in your user's home directory.
40
68
 
41
69
  nano ~/.autoluv.env
42
70
 
@@ -52,17 +80,25 @@ LUV_PORT = 587
52
80
 
53
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`.
54
82
 
55
- If your email account has two-factor authentication enabled, be sure to use an app-specific password above (and *not* your account password).
83
+ If your email account has two-factor authentication enabled, be sure to use an app-specific password and *not* your account password.
56
84
 
57
85
  **Step 4:** Hit `Ctrl+O` to save the file and then `Ctrl+X` to exit the text editor.
58
86
 
87
+ ### Test Email Notifications
88
+
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.
94
+
59
95
  ### Get Text Instead of Email Notifications
60
96
 
61
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.
62
98
 
63
99
  ## Manage Check-Ins
64
100
 
65
- `autoluv` uses the `at` command behind the scenes to check in at a specific time. Use the related `atq` and `atrm` commands to manage them.
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.
66
102
 
67
103
  ### View Scheduled Check-Ins
68
104
  Make note of the first column's number.
@@ -92,6 +128,3 @@ Bug reports and pull requests are welcome.
92
128
  ## License
93
129
 
94
130
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
95
-
96
- # TODO: try getting it working on macos.
97
- # TODO: does scheduling pass two-word names to checkin properly?
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.
data/bin/autoluv CHANGED
@@ -10,6 +10,10 @@ to = ARGV[4]
10
10
  bcc = ARGV[5]
11
11
 
12
12
  begin
13
+ unless File.exist?(ENV["LUV_HEADERS_FILE"].to_s)
14
+ abort "Please create a valid Southwest header file before continuing. Learn more: https://github.com/byalextran/southwest-headers"
15
+ end
16
+
13
17
  case command.downcase
14
18
  when "schedule"
15
19
  Autoluv::SouthwestClient.schedule(confirmation_number, first_name, last_name, to, bcc)
@@ -6,8 +6,6 @@ require "shellwords"
6
6
 
7
7
  module Autoluv
8
8
  class SouthwestClient
9
- @confirmation_number = @first_name = @last_name = @options = nil
10
-
11
9
  # minimum required headers for all API calls
12
10
  DEFAULT_HEADERS = {
13
11
  "Content-Type": "application/json",
@@ -47,7 +45,7 @@ module Autoluv
47
45
  begin
48
46
  attempt = x + 1
49
47
  post_data = self.check_in_post_data(confirmation_number, first_name, last_name)
50
- check_in = RestClient.post("#{CHECK_IN_URL}", post_data.to_json, self.headers)
48
+ check_in = RestClient.post("#{CHECK_IN_URL}", post_data.to_json, JSON.parse(File.read(ENV["LUV_HEADERS_FILE"])))
51
49
  break
52
50
  rescue RestClient::ExceptionWithResponse => ewr
53
51
  sleep(1)
@@ -1,3 +1,3 @@
1
1
  module Autoluv
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.1"
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,11 +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
- Pony.mail(PONY_OPTIONS.merge({
59
- to: to,
60
- bcc: bcc,
61
- subject: subject,
62
- body: body,
63
- }))
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
69
+ end
64
70
  end
65
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.1
4
+ version: 0.3.1
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-25 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