smartcar / ruby-sdk Goto Github PK
View Code? Open in Web Editor NEWRuby gem to use Smartcar APIs
Home Page: https://smartcar.com/docs/api
License: MIT License
Ruby gem to use Smartcar APIs
Home Page: https://smartcar.com/docs/api
License: MIT License
Trying to create a basic request to get extended attributes using the ruby SDK.
def vehicle
@token = params[:token]
ap @token
vehicle_ids = Smartcar.get_vehicles(token: @token).vehicles
ap vehicle_ids
vehicle = Smartcar::Vehicle.new(token: @token, id: vehicle_ids.first, options: {unit_system: 'imperial'})
ap vehicle
# vehicle_attributes = vehicle.attributes
path = "#{vehicle.attributes.make}/attributes"
vehicle_attributes = vehicle.request("GET", path)
ap vehicle_attributes
vehicle_attributes.to_h.slice(*%I[id make model year]).to_json
# API calls to get vehicle info
ap vehicle.odometer
end
the vehicle.request is erroring out with a 404:
SmartcarError (RESOURCE_NOT_FOUND:PATH - The requested resource does not exist. Please check the URL and try again.):
the path is being written as 'FORD/attributes' - just like it shows in the API documentation.
I get the test vehicles, I get the basic attributes but cannot get the extended attributes, if someone could point me to what I'm doing wrong I would really appreciate it.
Thanks in advance.
Issue copied from vickodin#1
Some troubles:
In case of no data parameter here, there will be an error (try use nil as a a hash), but we don't have any hash as params here (USER_PATH only).
There is a required instance's method (unit_system) here, that is missing in the User.
Also, any method (get, post, etc) returns an array with two elements: body and meta here, but we use a hash here (['id']).
As result, we can't invoke user_id method without raise errors.
Is there any news on when this gem is expected to work with Ruby 3?
The oauth seems to work okay in ruby 3, but the api calls do not. Digging into it a bit, it looks like some method calls need to be updated:
eg.
# BAD
def get_vehicles(token:, paging: {}, version: Smartcar.get_api_version)
base_object = Base.new(
{
token: token,
version: version
}
)
base_object.build_response(*base_object.fetch(
{
path: PATHS[:vehicles],
query_params: paging
}
))
end
# BETTER
def get_vehicles(token:, paging: {}, version: Smartcar.get_api_version)
base_object = Base.new(
token: token,
version: version
)
base_object.build_response(*base_object.fetch(
path: PATHS[:vehicles],
query_params: paging
))
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.