bmtc 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: 1beee60fd03a611684ab48bfa6cf4931d60761d9
4
- data.tar.gz: 0572b9f08b6c85111c91a9d86dc412c340794fa7
3
+ metadata.gz: 8fd7b040144f15d0a6aa3c56f3e3108b18c5a3cf
4
+ data.tar.gz: efc96266ce11a1787389cdb2d5f64749c332c749
5
5
  SHA512:
6
- metadata.gz: 733c5f3a9a18c7b3ba99c5beedf454e75ef9e9205081ca8ebd90512332b47f58a8030706b079f69a17462101cf776c2bfc64ec0f95fc0c85ce32a7b2c6c909b7
7
- data.tar.gz: 4eee1c22ffa800bea3b4af769223c6a0bcb64f4500abd794ab3218544698f3e0e650fd8775f134f010b2bffd215af4c88054dbb1f34c6380b139f47a3bcb8bba
6
+ metadata.gz: fa95eba4530bad1d024012d46619986c6aa62bbb1db3e0a88a2274011d7785ecd03de2648c0bd3718e6685bc1f1bb2f63ad37d5d82b61f9f28f9234977b097a6
7
+ data.tar.gz: 31bf1078aa81a552399cae452aa245a094bc9fe23085215f82cac2b0b2d585cf833f182b698d683f9a4619efb980578ff96fb6444c4dd1318580792df3d3addc
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.swp
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Bmtc
2
2
 
3
- Bangalore Metropolitan Transport Corporation BMTC its Intelligent Transport System (ITS) , But as of now there is no public api available . This is an reverse engineering approach to solve the issue
3
+ Bangalore Metropolitan Transport Corporation BMTC recently released its Intelligent Transport System (ITS) , But as of now there is no public api available . This is an reverse engineering approach to solve the issue
4
+
5
+ API Reference : https://github.com/tachyons/bmtc_api
4
6
 
5
7
  ## Installation
6
8
 
@@ -47,6 +49,14 @@ Get route map
47
49
  BMTC::route_map <route_id>
48
50
  BMTC::route_map "171"
49
51
  ```
52
+
53
+ Get Trip fare
54
+
55
+ ```ruby
56
+ BMTC.trip_fare(source: "HSR CPWD Quarters",destination:"Shanthinagara TTMC",service_type: :ordinary,no_adults: 1)
57
+ ```
58
+
59
+ Service types can be oridninary,vajra,vayu_vajra,atal_sarige,nice_service and bengaluru_darshini
50
60
  ## Development
51
61
 
52
62
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/bmtc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bmtc
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
data/lib/bmtc.rb CHANGED
@@ -4,6 +4,15 @@ require 'bmtc/ttmc'
4
4
  require 'httparty'
5
5
  BMTC = Bmtc
6
6
  module Bmtc
7
+ SERVICE_TYPES = {
8
+ ordinary: 1,
9
+ vayu_vajra: 2,
10
+ vajra: 3,
11
+ atal_sarige: 5,
12
+ nice_service: 11,
13
+ bengaluru_darshini: 14
14
+
15
+ }.freeze
7
16
  include HTTParty
8
17
  base_uri 'http://bmtcmob.hostg.in/api/'
9
18
  def self.post_request(path, options)
@@ -26,13 +35,17 @@ module Bmtc
26
35
  Bmtc.post_request('/routemap/details', options)
27
36
  end
28
37
 
29
- def self.trip_fare(no_adults, service_type, source, _destination)
38
+ def self.trip_fare(_input_options = {})
39
+ service_type = SERVICE_TYPES[_input_options[:service_type]] || _input_options[:service_type] || "1"
40
+ source = _input_options[:source]
41
+ destination = _input_options[:destination]
42
+ no_adults= (_input_options[:no_adults].to_s || 1).to_s
30
43
  options = {
31
- 'adults' => no_adults.to_s,
32
- 'destination' => source,
44
+ 'adults' => no_adults,
45
+ 'destination' => destination,
33
46
  'serviceType' => service_type,
34
47
  'source' => source
35
48
  }
36
- Bmtc.post_request('/tripfare/details', options)
49
+ JSON.parse Bmtc.post_request('/tripfare/details', options)
37
50
  end
38
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmtc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aboobacker MK
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-28 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler