rlyft 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,45 +2,38 @@ module Lyft
2
2
  class Client
3
3
  module Api
4
4
  class User < Lyft::Client::Api::Base
5
- ENDPOINTS = {
6
- history: "/#{API_VERSION}/rides",
7
- profile: "/#{API_VERSION}/profile"
8
- }
9
-
10
5
  ##
11
6
  # Get ride history
12
7
  #
13
- # @param [Hash] args
14
- # @option args [String] :access_token (*required*)
15
- # @option args [DateTime] :start_time (*required*)
16
- # @option args [DateTime] :end_time
17
- # @option args [Integer] :limit
8
+ # @param access_token [String] The access_token (*required*)
9
+ # @param params [Hash] The lyft parameters.
10
+ # @option params [DateTime] :start_time (*required*)
11
+ # @option params [DateTime] :end_time
12
+ # @option params [Integer] :limit
18
13
  #
19
- def ride_history(args = {})
20
- args.delete(:end_time) if args[:end_time].blank?
21
- args.delete(:limit) if args[:limit].blank?
14
+ def ride_history(access_token:, params: {})
15
+ params.delete(:end_time) if params[:end_time].blank?
16
+ params.delete(:limit) if params[:limit].blank?
22
17
 
23
- make_request(
24
- http_method: :get,
25
- endpoint: path_for(:history),
26
- access_token: args.delete(:access_token),
27
- options: { query: args }
28
- )
18
+ resp = connection(access_token).get do |req|
19
+ req.url "/#{Api::VERSION}/rides"
20
+ req.params = params
21
+ end
22
+ handle_response(resp)
29
23
  end
30
24
 
31
25
  ##
32
26
  # Get user's profile
33
27
  #
34
- # @param [Hash] args
35
- # @option args [String] :access_token (*required*)
28
+ # @param access_token [String] The access_token (*required*)
29
+ # @param params [Hash] The lyft parameters.
36
30
  #
37
- def profile(args = {})
38
- make_request(
39
- http_method: :get,
40
- endpoint: path_for(:profile),
41
- access_token: args.delete(:access_token),
42
- options: { query: args }
43
- )
31
+ def profile(access_token:, params: {})
32
+ resp = connection(access_token).get do |req|
33
+ req.url "/#{Api::VERSION}/profile"
34
+ req.params = params
35
+ end
36
+ handle_response(resp)
44
37
  end
45
38
  end
46
39
  end
@@ -1,7 +1,8 @@
1
1
  module Lyft
2
2
  class Client
3
3
  class Configuration
4
- attr_reader :client_id, :client_secret, :debug_output, :use_sandbox
4
+ attr_accessor :access_token
5
+ attr_reader :client_id, :client_secret, :headers, :use_sandbox
5
6
 
6
7
  def initialize(args = {})
7
8
  raise ArgumentError, ':client_id is missing' if args[:client_id].blank?
@@ -10,7 +11,7 @@ module Lyft
10
11
  @client_id = args.fetch(:client_id)
11
12
  @client_secret = args.fetch(:client_secret)
12
13
  @use_sandbox = args.fetch(:use_sandbox, false)
13
- @debug_output = args[:debug_output]
14
+ @headers = args[:headers] || {}
14
15
 
15
16
  @client_secret = "SANDBOX-#{@client_secret}" if sandbox?
16
17
  end
@@ -0,0 +1,8 @@
1
+ module Lyft
2
+ class Response < Faraday::Response
3
+ def initialize(response)
4
+ super()
5
+ finish(response.env)
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Lyft
2
- VERSION = '1.0.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -27,17 +27,16 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_runtime_dependency 'httparty'
31
30
  spec.add_runtime_dependency 'activesupport'
32
- spec.add_runtime_dependency 'hashie'
31
+ spec.add_runtime_dependency 'faraday'
32
+ spec.add_runtime_dependency 'faraday_middleware'
33
33
 
34
34
  spec.add_development_dependency "bundler", "~> 1.11"
35
35
  spec.add_development_dependency "rake", "~> 10.0"
36
36
  spec.add_development_dependency "rspec"
37
37
  spec.add_development_dependency "rspec-its"
38
- spec.add_development_dependency "rubocop", "~> 0.47.1"
39
- spec.add_development_dependency "pry"
40
- spec.add_development_dependency "vcr"
38
+ spec.add_development_dependency "rubocop"
39
+ spec.add_development_dependency "byebug"
41
40
  spec.add_development_dependency "webmock"
42
41
  spec.add_development_dependency "yard"
43
42
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rlyft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Scott
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2018-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httparty
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: hashie
42
+ name: faraday_middleware
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -110,20 +110,6 @@ dependencies:
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.47.1
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.47.1
125
- - !ruby/object:Gem::Dependency
126
- name: pry
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -137,7 +123,7 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
125
  - !ruby/object:Gem::Dependency
140
- name: vcr
126
+ name: byebug
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - ">="
@@ -198,13 +184,16 @@ files:
198
184
  - bin/setup
199
185
  - lib/lyft.rb
200
186
  - lib/lyft/client.rb
187
+ - lib/lyft/client/api.rb
201
188
  - lib/lyft/client/api/availability.rb
202
189
  - lib/lyft/client/api/base.rb
203
190
  - lib/lyft/client/api/oauth.rb
191
+ - lib/lyft/client/api/oauth/grant_type.rb
192
+ - lib/lyft/client/api/oauth/scope.rb
204
193
  - lib/lyft/client/api/rides.rb
205
194
  - lib/lyft/client/api/user.rb
206
195
  - lib/lyft/client/configuration.rb
207
- - lib/lyft/client/mashed_parser.rb
196
+ - lib/lyft/response.rb
208
197
  - lib/lyft/ride.rb
209
198
  - lib/lyft/ride/status.rb
210
199
  - lib/lyft/ride/type.rb
@@ -1,31 +0,0 @@
1
- module Lyft
2
- class Client
3
- class MashedParser < HTTParty::Parser
4
- protected
5
-
6
- def xml
7
- mashed super
8
- end
9
-
10
- def json
11
- mashed super
12
- end
13
-
14
- def yaml
15
- mashed super
16
- end
17
-
18
- private
19
-
20
- def mashed(body)
21
- if body.is_a? Hash
22
- Hashie::Mash.new body
23
- elsif body.is_a? Array
24
- body.map(&method(:mashed))
25
- else
26
- body
27
- end
28
- end
29
- end
30
- end
31
- end