twingly / twingly-search-api-ruby

:gem: Twingly Blog Search API in Ruby
https://developer.twingly.com/
MIT License
4 stars 0 forks source link

xmloutputversion is hardcoded to 2 #40

Closed walro closed 8 years ago

walro commented 8 years ago

If we were to add another version (or if a customer really wants to use 0 or 1) it's currently not possible.

roback commented 8 years ago

Not as easy as i thought :(

twingly-search-api-ruby/lib/twingly/search/post.rb:40:in `fetch': key not found: "blogRank" (KeyError)
    from twingly-search-api-ruby/lib/twingly/search/post.rb:40:in `set_values'
    from twingly-search-api-ruby/lib/twingly/search/parser.rb:48:in `parse_post'
    from twingly-search-api-ruby/lib/twingly/search/parser.rb:32:in `block in create_result'
    from ~/.gem/ruby/2.2.2/gems/nokogiri-1.6.7/lib/nokogiri/xml/node_set.rb:187:in `block in each'
...
walro commented 8 years ago

Ah, right. Hehe :)

roback commented 8 years ago

(The output version was set to 1 above.)

The XML root element isn't the same for version 0 as for version 1 or 2, so we probably have to do some thinking before adding support for all versions.

XML root node for version 0:

<TermSearch numberOfDocuments="1000" secondsElapsed="0.493">

XML root node for version 1 and 2:

<twinglydata numberOfMatchesReturned="1000" secondsElapsed="0.42" numberOfMatchesTotal="5328347">
walro commented 8 years ago

I think we can disregard 0 completely as we have listed it as deprecated in our documentation.

I thought that maybe we should stop hard-coding the "2", but default to it. We throw "NotImplementedError" if someone chooses anything but 2. Then we at least have some sort of base that we can change later on.

roback commented 8 years ago

Not sure what the best error is though, NotImplementedError or ArgumentError. In either case we must create a new error class under Twingly::Search::Error.

jage commented 8 years ago

Some ideas. I'm thinking the end user shouldn't be concerned about which XML output version the API is using, the should just be able to use whatever features/data they want. Are there any benefits for the end user with version 0 or 1 compared to 2? (I'm thinking there are none except XML size).

walro commented 8 years ago

Are there any benefits for the end user with version 0 or 1 compared to 2? (I'm thinking there are none except XML size).

Can't think of ay advantages except what you listed. When I created this issue I was thinking about getting existing API users to switch to our official clients, and we might have some "0" and "1" people out there. I also considered the possibility of us adding a version "3" in the future, this was just a very loose thought though, we are probably likely do something else.

roback commented 8 years ago

Since the gem doesn't allow access to the raw xml the users shouldn't have to worry about this.

walro commented 8 years ago

Ah, I understand what you were getting at now. Indeed - you are right the output version does not really matter. Everyone should be able to use 2 and just disregard the extra information that newer output versions includes.

Perhaps just close this then?

roback commented 8 years ago

Perhaps just close this then?

Yes :)