sutto / api_smith Goto Github PK
View Code? Open in Web Editor NEWAPI Smith makes building structured API clients even simpler.
License: MIT License
API Smith makes building structured API clients even simpler.
License: MIT License
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!
How can I set a request timeout? Are all the underlying HTTParty options exposed?
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.
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:
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
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
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
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
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
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
Author
in Article
and we do not need to keep the authorList
intermediateupdated_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
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.