Git Product home page Git Product logo

api_smith's People

Contributors

filtersquad avatar pranas avatar sutto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api_smith's Issues

use :from many levels deep

Hi,

I'm giving APISmith::Smash a try to map a rich JSON input to Ruby objects.

I have a situation where I have a nested piece of data that I want to map, but not some of its parents.

data = {
  article: {
    titleOfTheArticle: "My Title",
    authorList: {
      author: {
        name: "John Doe"
      }
    },
    details: {
      status: "published"
      updatedAt: '2013-05-10'
    }
  }
}

class Author < APISmith::Smash
  property :name
end

class Article < APISmith::Smash
  property :title, :from => :titleOfTheArticle
  property :author, :transformer => Author
  property :updated_at
end

Here we can see that

  1. there is a nested Author in Article and we do not need to keep the authorList intermediate
  2. the updated_at value, nested inside details would be mapped directly into Article.

Are such things doable with APISmith, or I have to maintain all the hierarchy with classes?

Thanks

Transforms dates by default

Hi,

When I have response containing a date on the form yyyy-mm-dd this is automatically transformed to a date, even without a proper Date.parse transformer.

I believe that it should be up to the developer to decide if the dates should be transformed or not, do you guys agree with me? And I also believe that this issue is created buy the Crack JSON parser, perhaps you can use another one if you? WebMock recently had the same problem, and they switched to their own version of Crack. See bblimke/webmock@772585e

This is an example of this behavior:

require 'crack/json'
puts Crack::JSON.parse('{"date":"2010-01-01"}')

Thanks for a great gem, looking forward to use this in my project!

hashie dependency

Any chance you think you'll update the dependency on hashie to '> 3.2'? I'm using some omniauth libraries that are dependent on '> 3.2'. I tried forking and updating dependencies but I got the following errors when running the spec ( you can check out all of my changes here:

  1. APISmith::Client should allow you to perform get requests
    Failure/Error: client.get('/echo').should == {"verb" => "get", "echo" => nil}
    NameError:
    undefined local variable or method `method' for #HTTParty::Response:0x00000003195840

    /home/.rvm/gems/ruby-2.1.5@api_smith/gems/httparty-0.11.0/lib/httparty/response.rb:61:in`method_missing'

    ./spec/api_smith/client_spec.rb:47:in `block (2 levels) in <top (required)>'

  2. APISmith::Client should allow you to perform post requests
    Failure/Error: client.post('/echo').should == {"verb" => "post", "echo" => nil}
    NameError:
    undefined local variable or method `method' for #HTTParty::Response:0x0000000311abb8

    /home/.rvm/gems/ruby-2.1.5@api_smith/gems/httparty-0.11.0/lib/httparty/response.rb:61:in`method_missing'

    ./spec/api_smith/client_spec.rb:51:in `block (2 levels) in <top (required)>'

  3. APISmith::Client should allow you to perform put requests
    Failure/Error: client.put('/echo').should == {"verb" => "put", "echo" => nil}
    NameError:
    undefined local variable or method `method' for #HTTParty::Response:0x000000030ff4f8

    /home/.rvm/gems/ruby-2.1.5@api_smith/gems/httparty-0.11.0/lib/httparty/response.rb:61:in`method_missing'

    ./spec/api_smith/client_spec.rb:55:in `block (2 levels) in <top (required)>'

  4. APISmith::Client should allow you to perform delete requests
    Failure/Error: client.delete('/echo').should == {"verb" => "delete", "echo" => nil}
    NameError:
    undefined local variable or method `method' for #HTTParty::Response:0x000000030ecb78

    /home/.rvm/gems/ruby-2.1.5@api_smith/gems/httparty-0.11.0/lib/httparty/response.rb:61:in`method_missing'

    ./spec/api_smith/client_spec.rb:59:in `block (2 levels) in <top (required)>'

  5. APISmith::Client unpacking requests should let you always skip the response container
    Failure/Error: client.get('/namespaced/test', :response_container => nil).should == {
    NameError:
    undefined local variable or method `method' for #HTTParty::Response:0x00000002ecf610

    /home/.rvm/gems/ruby-2.1.5@api_smith/gems/httparty-0.11.0/lib/httparty/response.rb:61:in`method_missing'

    ./spec/api_smith/client_spec.rb:145:in `block (3 levels) in <top (required)>'

Versioning via content negotiation

Hey guys-

This is more of a feature request than anything else. Here's the deal:

It's been kinda popular to version APIs by using some sort of prefix, like /v1/posts/1 vs /v2/posts/1. And this is bad. The Right Way is through content-negotiation. Most people go the prefix route because it's easy, and because it doesn't require a lot of work. That said, just like Rails made RESTful stuff easy, I'd love to see some work go into making the other parts of REST that Rails DOESN'T do be easy, too. And this would be part of it.

Anyway, I haven't dived into your code, and I don't think I'm going to have the time to work up a pull request of my own that'd do something like this, but you might want to think about it.

Set request timeout?

How can I set a request timeout? Are all the underlying HTTParty options exposed?

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.