Class: Ruze::Kamereon
- Inherits:
-
Object
- Object
- Ruze::Kamereon
- Defined in:
- lib/ruze/kamereon.rb
Constant Summary collapse
- BASE_URL =
'https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1'.freeze
- COUNTRY =
'DE'.freeze
Instance Attribute Summary collapse
-
#gigya_token ⇒ Object
readonly
Returns the value of attribute gigya_token.
-
#person_id ⇒ Object
readonly
Returns the value of attribute person_id.
Instance Method Summary collapse
- #account_id ⇒ Object
- #accounts ⇒ Object
- #battery ⇒ Object
- #cockpit ⇒ Object
-
#initialize(person_id, gigya_token, vin = nil) ⇒ Kamereon
constructor
A new instance of Kamereon.
- #location ⇒ Object
- #vehicles ⇒ Object
- #vin ⇒ Object
Constructor Details
#initialize(person_id, gigya_token, vin = nil) ⇒ Kamereon
Returns a new instance of Kamereon.
9 10 11 12 13 14 15 |
# File 'lib/ruze/kamereon.rb', line 9 def initialize(person_id, gigya_token, vin = nil) raise ArgumentError unless person_id.is_a?(String) && gigya_token.is_a?(String) @person_id = person_id @gigya_token = gigya_token @vin = vin end |
Instance Attribute Details
#gigya_token ⇒ Object (readonly)
Returns the value of attribute gigya_token.
16 17 18 |
# File 'lib/ruze/kamereon.rb', line 16 def gigya_token @gigya_token end |
#person_id ⇒ Object (readonly)
Returns the value of attribute person_id.
16 17 18 |
# File 'lib/ruze/kamereon.rb', line 16 def person_id @person_id end |
Instance Method Details
#account_id ⇒ Object
18 19 20 |
# File 'lib/ruze/kamereon.rb', line 18 def account_id accounts.first['accountId'] end |
#accounts ⇒ Object
22 23 24 25 26 27 |
# File 'lib/ruze/kamereon.rb', line 22 def accounts @accounts ||= return_from get( uri("/persons/#{person_id}?country=#{COUNTRY}"), headers ), keys: %w[accounts] end |
#battery ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ruze/kamereon.rb', line 40 def battery @battery ||= return_from get( uri("/accounts/#{account_id}/kamereon/kca/car-adapter/v2/cars/#{vin}/battery-status?country=#{COUNTRY}"), headers ), keys: %w[data attributes] end |
#cockpit ⇒ Object
47 48 49 50 51 52 |
# File 'lib/ruze/kamereon.rb', line 47 def cockpit @cockpit ||= return_from get( uri("/accounts/#{account_id}/kamereon/kca/car-adapter/v1/cars/#{vin}/cockpit?country=#{COUNTRY}"), headers ), keys: %w[data attributes] end |
#location ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ruze/kamereon.rb', line 54 def location @location ||= return_from get( uri("/accounts/#{account_id}/kamereon/kca/car-adapter/v1/cars/#{vin}/location?country=#{COUNTRY}"), headers ), keys: %w[data attributes] rescue Error => e raise e unless e..include?('404') {} end |
#vehicles ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ruze/kamereon.rb', line 29 def vehicles @vehicles ||= return_from get( uri("/accounts/#{account_id}/vehicles?country=#{COUNTRY}"), headers ), keys: %w[vehicleLinks] end |
#vin ⇒ Object
36 37 38 |
# File 'lib/ruze/kamereon.rb', line 36 def vin @vin ||= vehicles.first.dig('vehicleDetails', 'vin') end |