My client has a nodejs SDK that fetches entries using a client that makes http requests. Their api looks like this:
var Query = Client.ContentType('blog').Query();
Query
.where("title", "welcome")
.includeSchema()
.includeCount()
.toJSON()
.find().then((response) => resolvePromise etc...))
I have been tasked with mirroring this api but in an idiomatic way in ruby.
My earlier attemps at doing entries = client.entries({content_type: 'blog'}) were rejected. They now want me to now write an api that reads like this:
query = client.content_type('blog').query;
entries = query
.where("title", "welcome")
.include_schema
.include_count
.to_json
.find;
Somehow this doesn't make sense to me (perhaps due to the level of misdirections involved) and I don't exactly know why.
If I write a method like content_type('content_uid') on my client class, I am writing a parameterized setter that already breaks rules.
If you are a rubyist, does this look like good api design to you? How can I improve on this?