Module: GogoKit::Utils
- Included in:
- Client::Address, Client::Category, Client::Country, Client::Currency, Client::Event, Client::Language, Client::Listing, Client::MetroArea, Client::OAuth, Client::PaymentMethod, Client::Root, Client::Search, Client::SellerListing, Client::User, Client::Venue
- Defined in:
- lib/gogokit/utils.rb
Overview
Utility methods for Client
Instance Method Summary collapse
-
#object_from_response(klass, klass_representer, method, url, options) ⇒ Object
Perform an HTTP request an map the to a Representable::JSON.
Instance Method Details
#object_from_response(klass, klass_representer, method, url, options) ⇒ Object
Perform an HTTP request an map the to a Representable::JSON
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gogokit/utils.rb', line 5 def object_from_response(klass, klass_representer, method, url, ) response = send(method.to_sym, url, ) return nil if response[:status] < 200 || response[:status] > 299 || response[:body].nil? klass.new.extend(klass_representer).from_json(response[:body]) end |