Sha256: 0849987c0998b114d8dc5612b3827549594132c335804d851eeb0ca5c131e1c0

Contents?: true

Size: 492 Bytes

Versions: 2

Compression:

Stored size: 492 Bytes

Contents

require 'active_interaction'
require 'net/http'

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

        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/#{product_id}")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mercadolibre_api-0.10 lib/mercadolibre_api/sellers/queries/get_id.rb
mercadolibre_api-0.9 lib/mercadolibre_api/sellers/queries/get_id.rb