Sha256: 622751f8f2c4604099046cfe35836d8977aba288afb6a115c98cef6966c5d15d

Contents?: true

Size: 576 Bytes

Versions: 5

Compression:

Stored size: 576 Bytes

Contents

require 'active_interaction'
require 'net/http'

module MercadolibreApi
  module Categories
    module Queries
      class Find < ActiveInteraction::Base
        string :category_id

        def execute
          response = Net::HTTP.get_response(uri)
          response_body = JSON.parse(response.body, symbolize_names: true)
          MercadolibreApi::Categories::Entities::Category.represent(response_body).as_json
        end

        private

        def uri
          URI("https://api.mercadolibre.com/categories/#{category_id}")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mercadolibre_api-0.10 lib/mercadolibre_api/categories/queries/find.rb
mercadolibre_api-0.9 lib/mercadolibre_api/categories/queries/find.rb
mercadolibre_api-0.8 lib/mercadolibre_api/categories/queries/find.rb
mercadolibre_api-0.7 lib/mercadolibre_api/categories/queries/find.rb
mercadolibre_api-0.6 lib/mercadolibre_api/categories/queries/find.rb