Sha256: 61268711fb0f589b3f3238f3d4e575ea2fd21bd4312aca67d3b280cafaa23e63

Contents?: true

Size: 531 Bytes

Versions: 6

Compression:

Stored size: 531 Bytes

Contents

require 'active_interaction'
require 'net/http'

module MercadolibreApi
  module Sellers
    module Queries
      class GetID < ActiveInteraction::Base
        integer :product_id
        string :site_code

        def execute
          response = Net::HTTP.get_response(product_uri)
          JSON.parse(response.body, symbolize_names: true).dig(:seller_id)
        end

        private

        def product_uri
          URI("https://api.mercadolibre.com/items/#{site_code}#{product_id}")
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mercadolibre_api-0.8 lib/mercadolibre_api/sellers/queries/get_id.rb
mercadolibre_api-0.7 lib/mercadolibre_api/sellers/queries/get_id.rb
mercadolibre_api-0.6 lib/mercadolibre_api/sellers/queries/get_id.rb
mercadolibre_api-0.5 lib/mercadolibre_api/sellers/queries/get_id.rb
mercadolibre_api-0.4 lib/mercadolibre_api/sellers/queries/get_id.rb
mercadolibre_api-0.3 lib/mercadolibre_api/sellers/queries/get_id.rb