rlyft 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5387bcd03848cc82eb4d43de5355a830825ab252
4
+ data.tar.gz: 930f6d562dbd1f1df4ffc8087da655344ccab834
5
+ SHA512:
6
+ metadata.gz: 01dd62c99f9eb34162042a571c39c2a96120d4a2a2dffa3652dd918191be1081b9ac842f7ca31e733de275faf449574ff682d79982b2d93a481b613648e66240
7
+ data.tar.gz: 93d6f9caac191b93c2ded4fd858b824b3f15d58f747dd9979ae9fdab4d5c8b18e1be477d83912d9da2e04b461896c1d44ed87bd1cb218e5d3902fcd7293fc4b4
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ lyft_setup.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lyft.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Taylor Scott
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.
@@ -0,0 +1,70 @@
1
+ # Lyft
2
+
3
+ Simple wrapper for interacting with Lyft's public api.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'lyft', git: 'git@github.com:skukx/lyft.git'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ ## Setup
18
+
19
+ ```ruby
20
+ client = Lyft::Client.new do |c|
21
+ c.client_id = 'client_id'
22
+ c.client_secret = 'client_secret'
23
+ end
24
+ ```
25
+
26
+ ## Using Public Api
27
+ Calculate Lyft cost.
28
+
29
+ ```ruby
30
+ client.cost start_lat: 37.7772,
31
+ start_lng: -122.4233,
32
+ end_lat: 37.7972,
33
+ end_lng: -122.4533
34
+ ```
35
+
36
+ Time for nearest driver to reach location.
37
+
38
+ ```ruby
39
+ client.eta lat: 37.7772,
40
+ lng: -122.4233
41
+ ```
42
+
43
+ Get the location of nearby drivers.
44
+
45
+ ```ruby
46
+ client.nearby_drivers lat: 37.7772,
47
+ lng: -122.4233
48
+ ```
49
+
50
+ Get available ride types.
51
+
52
+ ```ruby
53
+ client.ride_types lat: 37.7772,
54
+ lng: -122.4233
55
+ ```
56
+
57
+ ## Development
58
+
59
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lyft.
66
+
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lyft"
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
@@ -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
@@ -0,0 +1,14 @@
1
+ # 3rd party Libraries
2
+ require 'httparty'
3
+ require 'active_support/all'
4
+
5
+ # Gem libraries
6
+ Dir[File.dirname(__FILE__) + '/lyft/**/*.rb'].each { |file| require file }
7
+
8
+ module Lyft
9
+ API_URI = 'https://api.lyft.com'
10
+
11
+ def self.endpoint(path)
12
+ API_URI + path
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ module Lyft
2
+ module Api
3
+ module Availability
4
+ def cost(args = {})
5
+ uri = Lyft.endpoint('/v1/cost')
6
+ options = {
7
+ headers: {
8
+ Authorization: "Bearer #{public_token.access_token}"
9
+ }.as_json,
10
+ query: {
11
+ start_lat: args.fetch(:start_lat),
12
+ start_lng: args.fetch(:start_lng),
13
+ end_lat: args.fetch(:end_lat),
14
+ end_lng: args.fetch(:end_lng)
15
+ }
16
+ }
17
+
18
+ HTTParty.get(uri, options)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module Lyft
2
+ module Api
3
+ module Availability
4
+ def eta(args = {})
5
+ uri = Lyft.endpoint('/v1/eta')
6
+ options = {
7
+ headers: {
8
+ Authorization: "Bearer #{public_token.access_token}"
9
+ }.as_json,
10
+ query: {
11
+ lat: args.fetch(:lat),
12
+ lng: args.fetch(:lng)
13
+ }
14
+ }
15
+
16
+ HTTParty.get(uri, options)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Lyft
2
+ module Api
3
+ module Availability
4
+ def nearby_drivers(args = {})
5
+ uri = Lyft.endpoint('/v1/drivers')
6
+ options = {
7
+ headers: {
8
+ Authorization: "Bearer #{public_token.access_token}"
9
+ }.as_json,
10
+ query: {
11
+ lat: args.fetch(:lat),
12
+ lng: args.fetch(:lng)
13
+ }
14
+ }
15
+
16
+ HTTParty.get(uri, options)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Lyft
2
+ module Api
3
+ module Availability
4
+ def ride_types(args = {})
5
+ uri = Lyft.endpoint('/v1/ridetypes')
6
+ options = {
7
+ headers: {
8
+ Authorization: "Bearer #{public_token.access_token}"
9
+ }.as_json,
10
+ query: {
11
+ lat: args.fetch(:lat),
12
+ lng: args.fetch(:lng)
13
+ }
14
+ }
15
+
16
+ HTTParty.get(uri, options)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ module Lyft
2
+ module Api
3
+ module Oauth
4
+ def public_token(renew = false)
5
+ # return @public_token unless @public_token.nil? && !renew
6
+
7
+ uri = Lyft.endpoint('/oauth/token')
8
+ options = {
9
+ body: {
10
+ grant_type: 'client_credentials',
11
+ scope: 'public'
12
+ },
13
+ basic_auth: {
14
+ username: @client_id,
15
+ password: @client_secret
16
+ }
17
+ }
18
+
19
+ response = HTTParty.post(uri, options).deep_symbolize_keys!
20
+ @public_token = Struct.new(*response.keys).new(*response.values)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ module Api
3
+ module Rides
4
+ def ride
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ module Api
3
+ module Rides
4
+ def ride_cancel
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ module Api
3
+ module Rides
4
+ def ride_details
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ module Api
3
+ module Rides
4
+ def ride_rating_and_tipping
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ module Api
3
+ module Rides
4
+ def ride_receipt
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ module Api
3
+ module Users
4
+ def profile
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ module Api
3
+ module Users
4
+ def ride_history
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module Lyft
2
+ class Client
3
+ include Api::Oauth
4
+ include Api::Availability
5
+ include Api::Rides
6
+ include Api::Users
7
+
8
+ attr_accessor :client_id,
9
+ :client_secret
10
+
11
+ def initialize
12
+ yield self
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Lyft
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lyft/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rlyft"
8
+ spec.version = Lyft::VERSION
9
+ spec.authors = ["Taylor Scott"]
10
+ spec.email = ["t.skukx@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby wrapper for Lyft API.}
13
+ spec.description = %q{Ruby wrapper for Lyft API.}
14
+ spec.homepage = "https://github.com/skukx/lyft"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "https://github.com/skukx/lyft"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_runtime_dependency 'httparty'
31
+ spec.add_runtime_dependency 'activesupport'
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.11"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec"
36
+ spec.add_development_dependency "pry"
37
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rlyft
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Taylor Scott
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Ruby wrapper for Lyft API.
98
+ email:
99
+ - t.skukx@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - bin/console
110
+ - bin/setup
111
+ - lib/lyft.rb
112
+ - lib/lyft/api/availability/cost.rb
113
+ - lib/lyft/api/availability/eta.rb
114
+ - lib/lyft/api/availability/nearby_drivers.rb
115
+ - lib/lyft/api/availability/ride_types.rb
116
+ - lib/lyft/api/oauth/public_token.rb
117
+ - lib/lyft/api/rides/ride.rb
118
+ - lib/lyft/api/rides/ride_cancel.rb
119
+ - lib/lyft/api/rides/ride_details.rb
120
+ - lib/lyft/api/rides/ride_rating_and_tipping.rb
121
+ - lib/lyft/api/rides/ride_receipt.rb
122
+ - lib/lyft/api/users/profile.rb
123
+ - lib/lyft/api/users/ride_history.rb
124
+ - lib/lyft/client.rb
125
+ - lib/lyft/version.rb
126
+ - lyft.gemspec
127
+ homepage: https://github.com/skukx/lyft
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.5.1
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Ruby wrapper for Lyft API.
151
+ test_files: []
152
+ has_rdoc: