GithubHelp home page GithubHelp logo

clio_client's People

Contributors

esakamoto-clio avatar fimmtiu avatar tvongaza avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

clio_client's Issues

Creating resource doesn't handle UnknownResponse error correctly

Was trying to create a resource, e.g.,

api.contacts.new(contact_params).save

Was receiving this error:

NoMethodError: undefined method `to_i' for false:FalseClass
Did you mean?  to_s
	from /app/vendor/bundle/ruby/2.3.0/gems/clio_client-0.1.9/lib/clio_client/resource.rb:164:in `convert_attribute'
	from /app/vendor/bundle/ruby/2.3.0/gems/clio_client-0.1.9/lib/clio_client/resource.rb:55:in `block (2 levels) in set_attributes'
	from /app/vendor/bundle/ruby/2.3.0/gems/clio_client-0.1.9/lib/clio_client/resource.rb:113:in `save'
	from (irb):28

Turns out, there was an error in our code where we were accidentally populating the 'id' field of one of the contact's phone numbers, so Clio was returning a 'conflict' error which ClioClient initially manifests with a Net::HTTPConflict error. This error is rescued in http.rb and ClioClient::UnknownResponse is thrown in its place.

Then crudable.rb rescues UnknownResponse and returns false.

Where it appears to go wrong is in resource.rb:

def save
  if self.id.nil?
    saved_item = api.create(self.to_params)
    self.id = saved_item && saved_item.id # Trying to assign 'false' to the 'id' attribute
    self
  else
    api.update(self.id, self.to_params)
    self
  end
end

I can make a PR with some guidance on the expected behavior.

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.