Giter Club home page Giter Club logo

ruby-sdk's People

Contributors

allisonc07 avatar aytekin-smartcar avatar dependabot[bot] avatar evanpeterson1324 avatar gurpreetatwal avatar hhovsepi avatar jacobandrewsmith92 avatar mdheri avatar naomiperez avatar nbry avatar rsimari avatar s-ashwinkumar avatar sektek avatar wikiadrian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ruby-sdk's Issues

Broken Smartcar::User.user_id method #1

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.

404 on any vehicle.request() type

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.

Ruby 3

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.