Class: Smartcar::User
Overview
Class to get to user API.
Constant Summary collapse
- USER_PATH =
Path for hitting user end point
'/user'.freeze
Constants inherited from Base
Instance Attribute Summary collapse
-
#id ⇒ String
Smartcar user id.
-
#token ⇒ String
Access token used to connect to Smartcar API.
Attributes inherited from Base
Class Method Summary collapse
-
.user_id(token:) ⇒ User
Class method Used to get user id EX : Smartcar::User.fetch API - https://smartcar.com/docs/api#get-user.
Instance Method Summary collapse
-
#initialize(token:) ⇒ User
constructor
A new instance of User.
Methods inherited from Base
Methods included from Utils
Constructor Details
#initialize(token:) ⇒ User
Returns a new instance of User.
10 11 12 13 |
# File 'lib/smartcar/user.rb', line 10 def initialize(token:) raise InvalidParameterValue.new, "Access Token(token) is a required field" if token.nil? @token = token end |
Instance Attribute Details
#id ⇒ String
Smartcar user id.
5 6 7 |
# File 'lib/smartcar/user.rb', line 5 def id @id end |
#token ⇒ String
Access token used to connect to Smartcar API.
5 6 7 |
# File 'lib/smartcar/user.rb', line 5 def token @token end |
Class Method Details
.user_id(token:) ⇒ User
Class method Used to get user id EX : Smartcar::User.fetch API - https://smartcar.com/docs/api#get-user
21 22 23 |
# File 'lib/smartcar/user.rb', line 21 def self.user_id(token:) new(token: token).get(USER_PATH)['id'] end |