Skip to content

Commit

Permalink
Add method to get information for an array of domain keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ileibovich committed Dec 5, 2017
1 parent 803cdfa commit 0bec320
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/yotpo/api/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def get_all_bottom_lines(params)
get("/apps/#{app_key}/bottom_lines", request)
end

def get_products_information(params)
app_key = params[:app_key]
get("/v1/widget/#{app_key}/products/products_information", { domain_keys: params[:domain_keys] })
end

#
# Retrieves the bottom line of a product
# @param params [Hash]
Expand Down
18 changes: 18 additions & 0 deletions spec/api/product_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
require 'helper'

describe Yotpo::Product do
describe '#get_product_information' do
before(:all) do
products_params = {
app_key: 'vzStmYud6bHLto5ksn5DoGoA7ghM0kzjMdH2DS5T',
domain_keys: ['1', '2']
}
VCR.use_cassette('check_products_information') do
@response = Yotpo.get_products_information(products_params)
end
end

subject { @response.body.products['1'] }
it { should be_a ::Hashie::Mash }
it { should respond_to :domain_key }
it { should respond_to :product_link }
it { should respond_to :name }
end

describe '#get_all_bottom_lines' do
before(:all) do
get_app_bottom_lines_params = {
Expand Down
55 changes: 55 additions & 0 deletions spec/cassettes/check_products_information.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0bec320

Please sign in to comment.