turksatkablo_cli 0.1.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: '096030e8ac0d782b5897e41e38cd54865f8a6f54'
4
+ data.tar.gz: c49dd97392189e456bca3ecb33879887b829a09e
5
+ SHA512:
6
+ metadata.gz: 7ae7ece1c55733ed7fa3ebf7d1e4036ef0f6ad88ddc5c106a948d42dc6de73428151b907966d93820207c5f1c232b7c4a0e4f655c494db6ff73586f0045eb418
7
+ data.tar.gz: 4b4b6debe522b4ba07d7bfac1ecc3a70b0b4bc2d96b729f39075662ebfd62740bc07398db28b1e7424a6672c40f49f4d79c89880e5184febd057e915c08e1ce4
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+ rspec_logs.json
12
+ test_output/
13
+ .DS_STORE
14
+ .keys
15
+ *.png
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
+
34
+ # Dotenv
35
+ .env
36
+
37
+ .byebug_history
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at rokumatsumoto@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in turksatkablo_cli.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Samet Gunaydin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ Turksat Kablo CLI :black_medium_square:
2
+ =================
3
+
4
+ A command-line interface for the Turksat Kablo Online Islemler - https://online.turksatkablo.com.tr/
5
+
6
+ ## Setup
7
+
8
+ turksatkablo_cli supports Ruby (MRI) 2.0+
9
+
10
+ 1. Install via rubygems
11
+
12
+ ```bash
13
+ gem install turksatkablo_cli
14
+ ```
15
+
16
+ 2. Install PhantomJS
17
+
18
+ https://github.com/teampoltergeist/poltergeist#installing-phantomjs
19
+
20
+
21
+
22
+ Verify the `turksatkablo` command is in your path by running it. You should see information about available commands.
23
+
24
+ ```
25
+ $ turksatkablo
26
+ Commands:
27
+ turksatkablo anlikborc # Anlık borç - kısa kodu b
28
+ turksatkablo help [COMMAND] # Describe available commands or one specific command
29
+ turksatkablo hizmet # Mevcut hizmetler - kısa kodu h
30
+ turksatkablo kampanya # Kampanya bilgileri - kısa kodu ka
31
+ turksatkablo kota # Kalan kota - kısa kodu k
32
+ turksatkablo kotadetay # Son 3 ayın günlük takibi v.s
33
+ turksatkablo musterino # Müşteri no - kısa kodu mn
34
+ turksatkablo ozet # Hizmetler genel durum - kısa kodu o
35
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "turksatkablo_cli"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/turksatkablo ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ ## encoding: utf-8
3
+
4
+ if RUBY_VERSION < '2.0.0'
5
+ abort "turksatkablo_cli requires Ruby 2.0.0 or higher"
6
+ end
7
+
8
+ lib_dir = File.expand_path("../../lib", __FILE__)
9
+ $LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
10
+
11
+ require 'turksatkablo_cli'
12
+
13
+ # catch control-c and exit
14
+ trap("SIGINT") do
15
+ Capybara.current_session.driver.quit
16
+ exit!
17
+ end
18
+
19
+
20
+ at_exit{
21
+ # cleanup temp files
22
+ # close open connections
23
+ Capybara.current_session.driver.quit
24
+ }
25
+
26
+ TurksatkabloCli.main
@@ -0,0 +1,12 @@
1
+ # Require the gems
2
+ require 'capybara/poltergeist'
3
+
4
+ # Configure Poltergeist to not blow up on websites with js errors aka every website with js
5
+ # See more options at https://github.com/teampoltergeist/poltergeist#customization
6
+ options = { js_errors: false, phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes'] }
7
+ Capybara.register_driver :poltergeist do |app|
8
+ Capybara::Poltergeist::Driver.new(app, options)
9
+ end
10
+
11
+ # Configure Capybara to use Poltergeist as the driver
12
+ Capybara.default_driver = :poltergeist
@@ -0,0 +1,39 @@
1
+ require 'turksatkablo_cli/online_operations/helpers'
2
+ require 'turksatkablo_cli/online_operations/enums'
3
+ require 'turksatkablo_cli/online_operations/version'
4
+ require 'turksatkablo_cli/base'
5
+ require 'turksatkablo_cli/online_operations/agent'
6
+ require 'turksatkablo_cli/online_operations/auth'
7
+ require "init/poltergeist"
8
+
9
+
10
+ module TurksatkabloCli
11
+ class << self
12
+ include TurksatkabloCli::OnlineOperations::Helpers
13
+ def main
14
+ add_commands
15
+
16
+ if internet_connection? == false
17
+ abort 'İnternet bağlantınızı kontrol ediniz!'
18
+ # Check your internet connection!
19
+ end
20
+
21
+
22
+ require 'turksatkablo_cli/online_operations/cli'
23
+
24
+ TurksatkabloCli::OnlineOperations::Cli.start(ARGV)
25
+
26
+ end
27
+
28
+
29
+ end
30
+
31
+ end
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
@@ -0,0 +1,15 @@
1
+ require 'thor'
2
+
3
+ module TurksatkabloCli
4
+ module OnlineOperations
5
+ class Base < Thor
6
+
7
+
8
+ # exit with return code 1 in case of a error
9
+ def self.exit_on_failure?
10
+ Capybara.current_session.driver.quit
11
+ true
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,147 @@
1
+ require 'highline'
2
+
3
+
4
+ module TurksatkabloCli
5
+ module OnlineOperations
6
+ class Agent
7
+ include Helpers
8
+ attr_accessor :login_choose, :username, :password, :radio_btn_value,
9
+ :fail_login_attempt, :session
10
+
11
+ def initialize
12
+ @session = Capybara::Session.new(:poltergeist)
13
+ @login_type = { musterino: {username_label: "Müşteri No", password_label: "Şifre", radio_btn_value: 1},
14
+ tckimlikno: {username_label: "T.C. Kimlik No", password_label: "Şifre", radio_btn_value: 2},
15
+ email: {username_label: "E-mail", password_label: "Şifre", radio_btn_value: 4},
16
+ ceptelefonu: {username_label: "Cep Telefonu (Başında 0 olmadan 10 haneli olmalı.)", password_label: "Şifre", radio_btn_value: 5} }
17
+ @fail_login_attempt = 0
18
+
19
+ end
20
+
21
+ def authenticated?
22
+ begin
23
+ if agent.session.current_url != Enums::BASE_URL_SUCCESS
24
+ auth = TurksatkabloCli::OnlineOperations::Auth.instance
25
+ set_login_data(auth)
26
+
27
+ if agent.session.current_url != Enums::BASE_URL
28
+ if agent.user_authenticated?
29
+ true
30
+ else
31
+ false
32
+ end
33
+ else
34
+ true
35
+ end
36
+
37
+ else
38
+ true
39
+ end
40
+ rescue Exception => e
41
+ false
42
+ end
43
+
44
+ end
45
+
46
+ def get_login
47
+ cli = HighLine.new
48
+
49
+ cli.say("Kablo TV Giriş")
50
+ cli.say("* Bilgileriniz daha sonraki girişleriniz için bilgisayarınızda şifrelenerek saklanacaktır.")
51
+
52
+ cli.choose do |menu|
53
+ menu.prompt = 'Abonesi olduğunuz Türksat hizmetleri ile ilgili giriş türü seçiniz: '
54
+ menu.choices(*@login_type.keys) do |chosen|
55
+
56
+ self.username = cli.ask(@login_type[chosen][:username_label])
57
+ self.password = cli.ask(@login_type[chosen][:password_label]) { |q| q.echo = "*" }
58
+
59
+ self.login_choose = chosen
60
+ self.radio_btn_value = @login_type[chosen][:radio_btn_value]
61
+
62
+ user_authenticated?
63
+ end
64
+ end
65
+ end
66
+
67
+
68
+
69
+ def end_session
70
+ @session.driver.quit
71
+ @session = nil
72
+ end
73
+
74
+ def screenshot
75
+ @session.save_screenshot
76
+ end
77
+
78
+ def retry_authenticate
79
+ if (@fail_login_attempt == 0)
80
+ puts "Türksat Kablo Online İşlemler sayfasına şuan ulaşılamıyor, tekrar deniyoruz..."
81
+ @fail_login_attempt = 1
82
+
83
+ user_authenticated?
84
+ else
85
+ puts "Türksat Kablo Online İşlemler sayfasına şuan ulaşılamıyor."
86
+ @fail_login_attempt = 0
87
+
88
+ false
89
+ end
90
+ end
91
+
92
+ def user_authenticated?
93
+ begin
94
+ if @session.current_url != Enums::BASE_URL_SUCCESS
95
+ visit_status = @session.visit(Enums::BASE_URL)
96
+ if visit_status["status"] == 'success' && @session.current_url == Enums::BASE_URL
97
+ @fail_login_attempt = 0
98
+ puts "#{Enums::BASE_URL} adresine erişim başarılı. Giriş yapılıyor..."
99
+
100
+ @session.find(:css, "div.radio-container div:nth-child(#{self.radio_btn_value}) > label").click
101
+ kullanici_id = @session.find('input#KullaniciID')
102
+ kullanici_id.send_keys(self.username)
103
+
104
+ kullanici_sifre = @session.find('input#KullaniciSifre')
105
+ kullanici_sifre.send_keys(self.password)
106
+
107
+ @session.find_link(id: 'Button1').click
108
+
109
+ if @session.current_url == Enums::BASE_URL_SUCCESS
110
+ puts "\nGiriş işlemi başarılı"
111
+ add_line
112
+
113
+
114
+ true
115
+ else
116
+ puts "\nGiriş bilgileriniz hatalı, kontrol ederek tekrar deneyiniz."
117
+ add_line
118
+
119
+ get_login
120
+ end
121
+ else
122
+ retry_authenticate
123
+ end
124
+ else
125
+ true
126
+ end
127
+
128
+ rescue Exception => e
129
+ retry_authenticate
130
+ end
131
+ end
132
+
133
+ private
134
+ def set_login_data(auth)
135
+ if auth.login_data.kind_of?(Hash)
136
+ agent.username = auth.login_data[:username]
137
+ agent.password = auth.login_data[:password]
138
+ agent.radio_btn_value = auth.login_data[:radio_btn_value]
139
+
140
+ else
141
+
142
+ end
143
+ end
144
+
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,66 @@
1
+ require 'singleton'
2
+ require 'openssl'
3
+ require 'yaml'
4
+
5
+
6
+ module TurksatkabloCli
7
+ module OnlineOperations
8
+ class Auth
9
+ include Singleton
10
+ include Helpers
11
+ attr_reader :path, :login_type, :login_data
12
+
13
+ FILE_NAME = '.turksatkablo'.freeze
14
+ KEY = "m\x13\x95\xBE6\x81\xEEN\xE6\xDC\xA0\x83K\xE8X2\a\xD7\xB2\x94L\xF2\xEC\xF9\x80\x9F_\xDB\xDB\xD05\v".freeze
15
+ private_constant :KEY
16
+
17
+ def initialize
18
+ @path = File.join(File.expand_path('~'), FILE_NAME)
19
+ @login_data = get
20
+ end
21
+
22
+
23
+ def get
24
+ return read_file if File.exists?(@path)
25
+ begin
26
+ if agent.get_login
27
+
28
+ login_info = { :radio_btn_value => agent.radio_btn_value, :username => agent.username,
29
+ :password => agent.password }
30
+
31
+ save_file(login_info) if @path
32
+ puts "Bilgileriniz bilgisayarınızda şifrelenerek saklandı." if File.exists?(@path)
33
+ login_info
34
+ end
35
+ rescue Exception => e
36
+ puts "Bir sorun oluştu."
37
+ end
38
+ end
39
+
40
+ def read_file
41
+ YAML.load(decryption(File.read(@path)))
42
+ end
43
+
44
+ private
45
+ def save_file(hash)
46
+ File.open(@path, 'w') { |file| file.write encryption(YAML.dump(hash)) }
47
+ end
48
+
49
+ def encryption(data)
50
+ cipher = OpenSSL::Cipher::AES256.new :CBC
51
+ cipher.encrypt
52
+ cipher.key = KEY
53
+ cipher.update(data) + cipher.final
54
+ end
55
+
56
+ def decryption(data)
57
+ decipher = OpenSSL::Cipher::AES256.new :CBC
58
+ decipher.decrypt
59
+ decipher.key = KEY
60
+ decipher.update(data) + decipher.final
61
+ end
62
+
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,128 @@
1
+ require 'terminal-table'
2
+
3
+
4
+ module TurksatkabloCli
5
+ module OnlineOperations
6
+ class Cli < Base
7
+ include TurksatkabloCli::OnlineOperations::Helpers
8
+ include Thor::Actions
9
+
10
+ # check_unknown_options!
11
+
12
+
13
+ def initialize(*)
14
+ @session = agent.session
15
+ super
16
+ end
17
+
18
+ desc "ozet", "Hizmetler genel durum - kısa kodu o"
19
+ def ozet
20
+ if agent.authenticated?
21
+ invoke :kota
22
+ invoke :musterino
23
+ invoke :anlikborc
24
+ end
25
+ end
26
+ map "o" => "ozet"
27
+
28
+ desc "kota", "Kalan kota - kısa kodu k"
29
+ def kota
30
+ if agent.authenticated?
31
+ puts @session.find(:css, "div.circle-container div.toplam span").text + " GB AKN Kaldı."
32
+ end
33
+ end
34
+ map "k" => "kota"
35
+
36
+ desc "musterino", "Müşteri no - kısa kodu mn"
37
+ def musterino
38
+ if agent.authenticated?
39
+ puts @session.find(:css, "div.musteri div.musteri-id").text
40
+
41
+ end
42
+ end
43
+ map "mn" => "musterino"
44
+
45
+ desc "hizmet", "Mevcut hizmetler - kısa kodu h"
46
+ def hizmet
47
+ if agent.authenticated?
48
+ visit_status = @session.visit(Enums::SERVICE_OPERATIONS_URL)
49
+ if visit_status["status"] == 'success' && @session.current_url == Enums::SERVICE_OPERATIONS_URL
50
+
51
+ # TODO: REFACTOR table helper
52
+
53
+ rows = []
54
+ services_td_list = @session.all(:css, 'table#hizmetTable tr td:nth-child(-n+4)').map(&:text)
55
+
56
+ if services_td_list.size > 0
57
+ (0..services_td_list.size).step(4) do |n|
58
+ rows << services_td_list[n...n+4]
59
+ end
60
+
61
+ table = Terminal::Table.new :headings => [Enums::HIZMET, Enums::HIZMET_TURU, Enums::HIZMET_DURUMU, Enums::TARIFE_TIPI], :rows => rows
62
+ puts table
63
+ else
64
+ puts "Mevcut bir hizmetiniz bulunmamaktadır."
65
+ end
66
+
67
+ else
68
+ puts "Hizmet İşlemleri menüsüne şuan ulaşılamıyor."
69
+ end
70
+
71
+ end
72
+ end
73
+ map "h" => "hizmet"
74
+
75
+ desc "kampanya", "Kampanya bilgileri - kısa kodu ka"
76
+ def kampanya
77
+ if agent.authenticated?
78
+ visit_status = @session.visit(Enums::CAMPAIGN_INFO_URL)
79
+ if visit_status["status"] == 'success' && @session.current_url == Enums::CAMPAIGN_INFO_URL
80
+
81
+ # TODO: REFACTOR table helper
82
+ rows = []
83
+ campaigns_td_list = @session.all(:css, 'table.table tr td').map(&:text)
84
+
85
+ if campaigns_td_list.size > 0
86
+ (0..campaigns_td_list.size).step(4) do |n|
87
+ rows << campaigns_td_list[n...n+4]
88
+ end
89
+
90
+ table = Terminal::Table.new :headings => [Enums::HIZMET_ID, Enums::KAMPANYA_ADI, Enums::TAAHHUT_BAS_TRH, Enums::TAAHHUT_BIT_TRH], :rows => rows
91
+ puts table
92
+ else
93
+ puts "Mevcut bir kampanyanız bulunmamaktadır."
94
+ end
95
+
96
+ else
97
+ puts "Kampanya Bilgileri menüsüne şuan ulaşılamıyor."
98
+ end
99
+
100
+ end
101
+ end
102
+ map "ka" => "kampanya"
103
+
104
+ desc "anlikborc", "Anlık borç - kısa kodu b"
105
+ def anlikborc
106
+ if agent.authenticated?
107
+ visit_status = @session.visit(Enums::INSTANT_DEBT_URL)
108
+ if visit_status["status"] == 'success' && @session.current_url == Enums::INSTANT_DEBT_URL
109
+ @session.find(:css, "div.anlik-borc").all("p, h1, small").map(&:text).each { |val| puts val }
110
+ else
111
+ puts "Anlık Borç menüsüne şuan ulaşılamıyor."
112
+ end
113
+ end
114
+ end
115
+ map "b" => "anlikborc"
116
+
117
+ # default_task :ozet
118
+
119
+
120
+ desc "kotadetay", "Son 3 ayın günlük takibi v.s"
121
+ subcommand 'kotadetay', Commands::Quota
122
+ map "kd" => "kotadetay"
123
+
124
+
125
+ end
126
+ end
127
+ end
128
+
@@ -0,0 +1,17 @@
1
+ module TurksatkabloCli
2
+ module OnlineOperations
3
+ module Commands
4
+ class Quota < Base
5
+
6
+ desc "donem", "Dönem takibi"
7
+ def donem
8
+ end
9
+
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+
16
+
17
+
@@ -0,0 +1,27 @@
1
+ require 'ruby-enum'
2
+
3
+ module TurksatkabloCli
4
+ module OnlineOperations
5
+ class Enums
6
+ include Ruby::Enum
7
+
8
+ define :BASE_URL, "https://online.turksatkablo.com.tr/"
9
+ define :BASE_URL_SUCCESS, "https://online.turksatkablo.com.tr/hosgeldiniz.aspx"
10
+ define :SERVICE_OPERATIONS_URL, "https://online.turksatkablo.com.tr/MusteriHizmetleri.aspx#Hizmet-Islemleri"
11
+ define :CAMPAIGN_INFO_URL, "https://online.turksatkablo.com.tr/KampanyaBilgileri.aspx#Hizmet-Islemleri"
12
+ define :INSTANT_DEBT_URL, "https://online.turksatkablo.com.tr/AnlikBorc.aspx#Fatura-Islemleri"
13
+
14
+
15
+ define :HIZMET, "HİZMET"
16
+ define :HIZMET_TURU, "HİZMET TÜRÜ"
17
+ define :HIZMET_DURUMU, "HİZMET DURUMU"
18
+ define :TARIFE_TIPI, "TARİFE TİPİ"
19
+
20
+
21
+ define :HIZMET_ID, "HİZMET ID"
22
+ define :KAMPANYA_ADI, "KAMPANYA ADI"
23
+ define :TAAHHUT_BAS_TRH, "TAAHHÜT BAŞLANGIÇ TARİHİ"
24
+ define :TAAHHUT_BIT_TRH, "TAAHHÜT BİTİŞ TARİHİ"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,47 @@
1
+ require 'open3'
2
+ require 'net/ping'
3
+
4
+
5
+ module TurksatkabloCli
6
+ module OnlineOperations
7
+ module Helpers
8
+
9
+ def run(*commands)
10
+ stdin, stdout, stderr, w = Open3.popen3(*commands)
11
+ [stdout.gets(nil), stderr.gets(nil), w.value]
12
+ end
13
+
14
+ def internet_connection?
15
+ begin
16
+ Net::Ping::External.new("8.8.8.8").ping?
17
+ rescue
18
+ false
19
+ end
20
+ end
21
+
22
+ def add_commands
23
+
24
+ begin
25
+ Dir[File.expand_path(File.join('../..','online_operations', 'commands', '*.rb'), __FILE__)].each do |file|
26
+ require file
27
+ end
28
+ rescue Exception => e
29
+ end
30
+
31
+ end
32
+
33
+ def agent
34
+ unless $agent
35
+ $agent = TurksatkabloCli::OnlineOperations::Agent.new
36
+ end
37
+ $agent
38
+ end
39
+
40
+ def add_line
41
+ puts "\n"
42
+ end
43
+
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ module TurksatkabloCli
2
+ module OnlineOperations
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "turksatkablo_cli/online_operations/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "turksatkablo_cli"
8
+ spec.version = TurksatkabloCli::OnlineOperations::VERSION
9
+ spec.authors = ["Samet Gunaydin"]
10
+ spec.email = ["rokumatsumoto@gmail.com"]
11
+
12
+ spec.summary = %q{Türksat Kablo Online İşlemler CLI}
13
+ spec.description = %q{A command-line interface for the Türksat Kablo Online İşlemler - https://online.turksatkablo.com.tr/}
14
+ spec.homepage = "https://github.com/rokumatsumoto/turksatkablo_cli"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ # spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ # f.match(%r{^(test|spec|features)/})
28
+ # end
29
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
+ spec.files = `git ls-files`.split("\n")
31
+ spec.require_paths = ["lib"]
32
+ spec.add_development_dependency "bundler", "~> 1.16"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+
35
+ spec.add_runtime_dependency "thor", '~> 0.20.0'
36
+ spec.add_runtime_dependency 'highline', '~> 1.7', '>= 1.7.8'
37
+ spec.add_runtime_dependency 'net-ping', '~> 2.0', '>= 2.0.2'
38
+ spec.add_runtime_dependency 'capybara', '~> 2.16', '>= 2.16.1'
39
+ spec.add_runtime_dependency 'poltergeist', '~> 1.16', '>= 1.16.0'
40
+ spec.add_runtime_dependency "ruby-enum", '~> 0.7.1'
41
+ spec.add_runtime_dependency 'terminal-table', '~> 1.8', '>= 1.8.0'
42
+ end
metadata ADDED
@@ -0,0 +1,224 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turksatkablo_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Samet Gunaydin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.20.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.20.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: highline
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.7.8
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.7'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.7.8
75
+ - !ruby/object:Gem::Dependency
76
+ name: net-ping
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.0'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 2.0.2
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '2.0'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 2.0.2
95
+ - !ruby/object:Gem::Dependency
96
+ name: capybara
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '2.16'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 2.16.1
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '2.16'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 2.16.1
115
+ - !ruby/object:Gem::Dependency
116
+ name: poltergeist
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '1.16'
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 1.16.0
125
+ type: :runtime
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.16'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.16.0
135
+ - !ruby/object:Gem::Dependency
136
+ name: ruby-enum
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: 0.7.1
142
+ type: :runtime
143
+ prerelease: false
144
+ version_requirements: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: 0.7.1
149
+ - !ruby/object:Gem::Dependency
150
+ name: terminal-table
151
+ requirement: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '1.8'
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: 1.8.0
159
+ type: :runtime
160
+ prerelease: false
161
+ version_requirements: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '1.8'
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: 1.8.0
169
+ description: A command-line interface for the Türksat Kablo Online İşlemler - https://online.turksatkablo.com.tr/
170
+ email:
171
+ - rokumatsumoto@gmail.com
172
+ executables:
173
+ - console
174
+ - setup
175
+ - turksatkablo
176
+ extensions: []
177
+ extra_rdoc_files: []
178
+ files:
179
+ - ".gitignore"
180
+ - CODE_OF_CONDUCT.md
181
+ - Gemfile
182
+ - LICENSE.txt
183
+ - README.md
184
+ - Rakefile
185
+ - bin/console
186
+ - bin/setup
187
+ - bin/turksatkablo
188
+ - lib/init/poltergeist.rb
189
+ - lib/turksatkablo_cli.rb
190
+ - lib/turksatkablo_cli/base.rb
191
+ - lib/turksatkablo_cli/online_operations/agent.rb
192
+ - lib/turksatkablo_cli/online_operations/auth.rb
193
+ - lib/turksatkablo_cli/online_operations/cli.rb
194
+ - lib/turksatkablo_cli/online_operations/commands/quota.rb
195
+ - lib/turksatkablo_cli/online_operations/enums.rb
196
+ - lib/turksatkablo_cli/online_operations/helpers.rb
197
+ - lib/turksatkablo_cli/online_operations/version.rb
198
+ - turksatkablo_cli.gemspec
199
+ homepage: https://github.com/rokumatsumoto/turksatkablo_cli
200
+ licenses:
201
+ - MIT
202
+ metadata:
203
+ allowed_push_host: https://rubygems.org/
204
+ post_install_message:
205
+ rdoc_options: []
206
+ require_paths:
207
+ - lib
208
+ required_ruby_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ required_rubygems_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: '0'
218
+ requirements: []
219
+ rubyforge_project:
220
+ rubygems_version: 2.6.13
221
+ signing_key:
222
+ specification_version: 4
223
+ summary: Türksat Kablo Online İşlemler CLI
224
+ test_files: []