yotpo 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +20 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +11 -0
- data/lib/yotpo/api/account.rb +45 -0
- data/lib/yotpo/api/account_platform.rb +20 -0
- data/lib/yotpo/api/product.rb +25 -0
- data/lib/yotpo/api/purchase.rb +38 -0
- data/lib/yotpo/api/reminder.rb +14 -0
- data/lib/yotpo/api/review.rb +67 -0
- data/lib/yotpo/api/user.rb +64 -0
- data/lib/yotpo/client.rb +134 -0
- data/lib/yotpo/core/response_parser.rb +84 -0
- data/lib/yotpo/version.rb +3 -0
- data/lib/yotpo.rb +58 -0
- data/spec/api/account_platform_spec.rb +33 -0
- data/spec/api/account_spec.rb +45 -0
- data/spec/api/product_spec.rb +44 -0
- data/spec/api/purchase_spec.rb +100 -0
- data/spec/api/reminder_spec.rb +22 -0
- data/spec/api/review_spec.rb +55 -0
- data/spec/api/user_spec.rb +63 -0
- data/spec/fixtures/bearer_token.json +4 -0
- data/spec/fixtures/check_subdomain.json +12 -0
- data/spec/fixtures/get_all_bottom_lines.json +29 -0
- data/spec/fixtures/get_list_of_purchases.json +39 -0
- data/spec/fixtures/get_login_url.json +10 -0
- data/spec/fixtures/get_product_bottom_line.json +12 -0
- data/spec/fixtures/get_product_reviews.json +356 -0
- data/spec/fixtures/new_account_platform.json +23 -0
- data/spec/fixtures/new_purchase.json +4 -0
- data/spec/fixtures/new_review.json +64 -0
- data/spec/fixtures/new_user.json +12 -0
- data/spec/fixtures/send_test_email.json +6 -0
- data/spec/fixtures/update_account.json +53 -0
- data/spec/helper.rb +65 -0
- data/spec/yotpo_spec.rb +4 -0
- data/yotpo.gemspec +29 -0
- metadata +193 -0
data/lib/yotpo.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'yotpo/version'
|
2
|
+
require 'yotpo/client'
|
3
|
+
|
4
|
+
module Yotpo
|
5
|
+
class << self
|
6
|
+
# @!attribute url
|
7
|
+
# @return [String] the base url of the Yotpo Api
|
8
|
+
attr_accessor :url
|
9
|
+
|
10
|
+
# @!attribute parallel_requests
|
11
|
+
# @return [Integer String] defines the maximum parallel request for the gem to preform
|
12
|
+
attr_accessor :parallel_requests
|
13
|
+
|
14
|
+
# @!attribute app_key
|
15
|
+
# @return [String] the app key that is registered with Yotpo
|
16
|
+
attr_accessor :app_key
|
17
|
+
|
18
|
+
# @!attribute secret
|
19
|
+
# @return [String] the secret that is registered with Yotpo
|
20
|
+
attr_accessor :secret
|
21
|
+
|
22
|
+
# Configuration interface of the gem
|
23
|
+
#
|
24
|
+
# @yield [self] to accept configuration settings
|
25
|
+
def configure
|
26
|
+
yield self
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Makes sure that the method missing is checked with the Yotpo::Client instance
|
32
|
+
#
|
33
|
+
# @param method_name [String] the name of the method we want to run
|
34
|
+
# @param include_private [Boolean] defines wether to check for private functions as well
|
35
|
+
def respond_to_missing?(method_name, include_private=false)
|
36
|
+
client.respond_to?(method_name, include_private)
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# @return an instance of Yotpo::Client
|
41
|
+
#
|
42
|
+
def client
|
43
|
+
@client ||= Yotpo::Client.new()
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
#
|
49
|
+
# executes any function on the Yotpo::Client instance
|
50
|
+
#
|
51
|
+
# @param args [*] any argument that we want to pass to the client function
|
52
|
+
# @param block [Block] any block that is passed to the client function
|
53
|
+
def method_missing(method_name, *args, &block)
|
54
|
+
return super unless client.respond_to?(method_name)
|
55
|
+
client.send(method_name, *args, &block)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Yotpo::AccountPlatform do
|
4
|
+
describe '#create_account_platform' do
|
5
|
+
before(:all) do
|
6
|
+
create_account_platform_request = {
|
7
|
+
shop_token: 'asdasdadads',
|
8
|
+
shop_domain: Faker::Internet.domain_name,
|
9
|
+
plan_name: 'test plan',
|
10
|
+
platform_type_id: 1,
|
11
|
+
deleted: false,
|
12
|
+
utoken: 'asdeuh1di1udifn1309fn09',
|
13
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG'
|
14
|
+
}
|
15
|
+
stub_post("/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/account_platform").
|
16
|
+
with(:headers => {'User-Agent' => 'Faraday v0.8.7', 'Yotpo-Api-Connector' => '0.0.1'}).
|
17
|
+
to_return(:status => 200, :body => fixture('new_account_platform.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
18
|
+
|
19
|
+
@response = Yotpo.create_account_platform(create_account_platform_request)
|
20
|
+
end
|
21
|
+
|
22
|
+
subject { @response.body.account_platform }
|
23
|
+
it { should be_a ::Hashie::Rash }
|
24
|
+
it { should respond_to :id }
|
25
|
+
it { should respond_to :shop_token }
|
26
|
+
it { should respond_to :shop_domain }
|
27
|
+
it { should respond_to :shop_api_url }
|
28
|
+
it { should respond_to :plan_name }
|
29
|
+
it { should respond_to :platform_type }
|
30
|
+
it { should respond_to :deleted }
|
31
|
+
it { should respond_to :shop_user_name }
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Yotpo::Account do
|
4
|
+
describe '#update_account' do
|
5
|
+
before(:all) do
|
6
|
+
account_data = {
|
7
|
+
minisite_website_name: Faker::Internet.domain_word,
|
8
|
+
minisite_website: Faker::Internet.domain_name,
|
9
|
+
minisite_subdomain: Faker::Internet.domain_name,
|
10
|
+
minisite_cname: Faker::Internet.domain_name,
|
11
|
+
minisite_subdomain_active: [true, false].sample,
|
12
|
+
utoken: '12ei1rr1i3ufn23itfoijver903',
|
13
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG'
|
14
|
+
}
|
15
|
+
stub_put('/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG').
|
16
|
+
to_return(:status => 200, :body => fixture('update_account.json'), :headers => {})
|
17
|
+
@response = Yotpo.update_account(account_data)
|
18
|
+
end
|
19
|
+
subject { @response.body.app }
|
20
|
+
it { should be_a ::Hashie::Rash }
|
21
|
+
it { should respond_to :id }
|
22
|
+
it { should respond_to :app_key }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#check_minisite_subdomain' do
|
26
|
+
before(:all) do
|
27
|
+
sub_domain_data = {
|
28
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG',
|
29
|
+
subdomain: 'shalom1',
|
30
|
+
utoken: '12ei1rr1i3ufn23itfoijver903'
|
31
|
+
}
|
32
|
+
stub_get('/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/subomain_check/shalom1?utoken=12ei1rr1i3ufn23itfoijver903').
|
33
|
+
with(:headers => {'User-Agent'=>'Faraday v0.8.7', 'Yotpo-Api-Connector'=>'0.0.1'}).
|
34
|
+
to_return(:status => 200, :body => fixture('check_subdomain.json'), :headers => {})
|
35
|
+
|
36
|
+
@response = Yotpo.check_minisite_subdomain(sub_domain_data)
|
37
|
+
end
|
38
|
+
subject { @response.body.subdomain }
|
39
|
+
it { should be_a ::Hashie::Rash }
|
40
|
+
it { should respond_to :available }
|
41
|
+
it { should respond_to :subdomain }
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Yotpo::Product do
|
4
|
+
describe '#get_all_bottom_lines' do
|
5
|
+
before(:all) do
|
6
|
+
get_app_bottom_lines_params = {
|
7
|
+
utoken: 'asdeuh1di1udifn1309fn09',
|
8
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG'
|
9
|
+
|
10
|
+
}
|
11
|
+
stub_get("/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/bottom_lines?utoken=asdeuh1di1udifn1309fn09").
|
12
|
+
with(:headers => {'User-Agent'=>'Faraday v0.8.7', 'Yotpo-Api-Connector'=>'0.0.1'}).
|
13
|
+
to_return(:status => 200, :body => fixture('get_all_bottom_lines.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
14
|
+
|
15
|
+
@response = Yotpo.get_all_bottom_lines(get_app_bottom_lines_params)
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { @response.body.bottomlines[0] }
|
19
|
+
it { should be_a ::Hashie::Rash }
|
20
|
+
it { should respond_to :domain_key }
|
21
|
+
it { should respond_to :product_score }
|
22
|
+
it { should respond_to :total_reviews }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#get_product_bottom_line' do
|
26
|
+
before(:all) do
|
27
|
+
get_bottom_line_params = {
|
28
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG',
|
29
|
+
product_id: 'A12'
|
30
|
+
}
|
31
|
+
|
32
|
+
stub_get("/products/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/A12/bottomline").
|
33
|
+
with(:headers => {'User-Agent'=>'Faraday v0.8.7', 'Yotpo-Api-Connector'=>'0.0.1'}).
|
34
|
+
to_return(:status => 200, :body => fixture('get_product_bottom_line.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
35
|
+
|
36
|
+
@response = Yotpo.get_product_bottom_line(get_bottom_line_params)
|
37
|
+
end
|
38
|
+
|
39
|
+
subject { @response.body.bottomline }
|
40
|
+
it { should be_a ::Hashie::Rash }
|
41
|
+
it { should respond_to :average_score }
|
42
|
+
it { should respond_to :total_reviews }
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Yotpo::Purchase do
|
4
|
+
describe '#create_new_purchase' do
|
5
|
+
before(:all) do
|
6
|
+
create_new_purchase_request = {
|
7
|
+
email: Faker::Internet.email,
|
8
|
+
customer_name: Faker::Internet.user_name,
|
9
|
+
order_id: '123',
|
10
|
+
platform: 'shopify',
|
11
|
+
products: [
|
12
|
+
p1: {
|
13
|
+
url: 'http://example_product_url1.com',
|
14
|
+
name: 'product1',
|
15
|
+
image: 'http://example_product_image_url1.com',
|
16
|
+
description: 'this is the description of a product'
|
17
|
+
}
|
18
|
+
],
|
19
|
+
utoken: 'asdeuh1di1udifn1309fn09',
|
20
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG'
|
21
|
+
}
|
22
|
+
stub_post("/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/purchases").
|
23
|
+
with(:headers => {'User-Agent' => 'Faraday v0.8.7', 'Yotpo-Api-Connector' => '0.0.1'}).
|
24
|
+
to_return(:status => 200, :body => fixture('new_purchase.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
25
|
+
|
26
|
+
@response = Yotpo.create_new_purchase(create_new_purchase_request)
|
27
|
+
end
|
28
|
+
|
29
|
+
subject { @response.body }
|
30
|
+
it { should be_a ::Hashie::Rash }
|
31
|
+
it { should respond_to :code }
|
32
|
+
it { should respond_to :message }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#create_new_purchases' do
|
36
|
+
before(:all) do
|
37
|
+
create_new_purchase_request = {
|
38
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG',
|
39
|
+
utoken: 'asdeuh1di1udifn1309fn09',
|
40
|
+
orders: [
|
41
|
+
{
|
42
|
+
email: Faker::Internet.email,
|
43
|
+
customer_name: Faker::Internet.user_name,
|
44
|
+
order_id: '123',
|
45
|
+
platform: 'shopify',
|
46
|
+
products: [
|
47
|
+
p1: {
|
48
|
+
url: 'http://example_product_url1.com',
|
49
|
+
name: 'product1',
|
50
|
+
image: 'http://example_product_image_url1.com',
|
51
|
+
description: 'this is the description of a product'
|
52
|
+
}
|
53
|
+
]
|
54
|
+
|
55
|
+
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
stub_post("/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/purchases/mass_create").
|
60
|
+
with(:headers => {'User-Agent' => 'Faraday v0.8.7', 'Yotpo-Api-Connector' => '0.0.1'}).
|
61
|
+
to_return(:status => 200, :body => fixture('new_purchase.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
62
|
+
|
63
|
+
@response = Yotpo.create_new_purchases(create_new_purchase_request)
|
64
|
+
end
|
65
|
+
|
66
|
+
subject { @response.body }
|
67
|
+
it { should be_a ::Hashie::Rash }
|
68
|
+
it { should respond_to :code }
|
69
|
+
it { should respond_to :message }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#get_purchases' do
|
73
|
+
before(:all) do
|
74
|
+
get_purchases_request = {
|
75
|
+
utoken: 'asdeuh1di1udifn1309fn09',
|
76
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG'
|
77
|
+
}
|
78
|
+
stub_get('/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/purchases?count=10&page=1&utoken=asdeuh1di1udifn1309fn09').
|
79
|
+
with(:headers => {'User-Agent' => 'Faraday v0.8.7', 'Yotpo-Api-Connector' => '0.0.1'}).
|
80
|
+
to_return(:status => 200, :body => fixture('get_list_of_purchases.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
81
|
+
|
82
|
+
@response = Yotpo.get_purchases(get_purchases_request)
|
83
|
+
end
|
84
|
+
|
85
|
+
subject { @response.body.purchases[0] }
|
86
|
+
it { should be_a ::Hashie::Rash }
|
87
|
+
it { should respond_to :id }
|
88
|
+
it { should respond_to :user_email }
|
89
|
+
it { should respond_to :user_name }
|
90
|
+
it { should respond_to :product_sku }
|
91
|
+
it { should respond_to :order_id }
|
92
|
+
it { should respond_to :product_name }
|
93
|
+
it { should respond_to :product_url }
|
94
|
+
it { should respond_to :order_date }
|
95
|
+
it { should respond_to :product_description }
|
96
|
+
it { should respond_to :product_image }
|
97
|
+
it { should respond_to :delivery_date }
|
98
|
+
it { should respond_to :created_at }
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Yotpo::Reminder do
|
4
|
+
describe Yotpo::Product do
|
5
|
+
describe '#send_test_reminder' do
|
6
|
+
before(:all) do
|
7
|
+
request ={
|
8
|
+
utoken: 'asdeuh1di1udifn1309fn09',
|
9
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG',
|
10
|
+
email: 'vlad@yotpo.com'
|
11
|
+
}
|
12
|
+
stub_post('/apps/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/reminders/send_test_email').with(:body => Oj.dump({utoken: 'asdeuh1di1udifn1309fn09',
|
13
|
+
email: 'vlad@yotpo.com'})).
|
14
|
+
to_return(:body => fixture('send_test_email.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
15
|
+
@response = Yotpo.send_test_reminder(request)
|
16
|
+
end
|
17
|
+
subject { @response.body }
|
18
|
+
it { should be_a ::Hashie::Rash }
|
19
|
+
it { should respond_to :status }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Yotpo::Review do
|
4
|
+
|
5
|
+
describe '#create_review' do
|
6
|
+
before(:all) do
|
7
|
+
anonymous_review = {
|
8
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG',
|
9
|
+
sku: Faker::Product.model,
|
10
|
+
domain: Faker::Internet.domain_name,
|
11
|
+
product_title: Faker::Product.product,
|
12
|
+
product_description: Faker::Lorem.paragraph(3),
|
13
|
+
product_url: Faker::Internet.http_url,
|
14
|
+
product_image_url: 'https://www.google.com/images/srpr/logo4w.png',
|
15
|
+
display_name: Faker::Internet.user_name,
|
16
|
+
email: Faker::Internet.email,
|
17
|
+
review_content: Faker::Lorem.paragraph(3),
|
18
|
+
review_title: Faker::Lorem.sentence(5),
|
19
|
+
review_score: [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5].sample
|
20
|
+
}
|
21
|
+
stub_get('/reviews/dynamic_create').with(:query => hash_including({:app_key => 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG'})).to_return(:body => fixture('new_review.json'),
|
22
|
+
:headers => {:content_type => 'application/json; charset=utf-8'})
|
23
|
+
@response = Yotpo.create_review(anonymous_review)
|
24
|
+
end
|
25
|
+
|
26
|
+
subject { @response.body.reviews[0] }
|
27
|
+
it { should be_a ::Hashie::Rash }
|
28
|
+
it { should respond_to :id }
|
29
|
+
it { should respond_to :user }
|
30
|
+
it { should respond_to :content }
|
31
|
+
it { should respond_to :title }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#get_product_reviews' do
|
35
|
+
before(:all) do
|
36
|
+
get_reviews_params = {
|
37
|
+
page: 1,
|
38
|
+
count: 5,
|
39
|
+
app_key: 'nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG',
|
40
|
+
product_id: 'A12'
|
41
|
+
}
|
42
|
+
stub_get("/products/nNgGNA54ETOqaXQ7hRZymxqdtwwetJKDVs0v8qGG/A12/reviews?count=5&page=1").
|
43
|
+
with(:headers => {'User-Agent'=>'Faraday v0.8.7', 'Yotpo-Api-Connector'=>'0.0.1'}).
|
44
|
+
to_return(:status => 200, :body => fixture('get_product_reviews.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
45
|
+
@response = Yotpo.get_product_reviews(get_reviews_params)
|
46
|
+
end
|
47
|
+
|
48
|
+
subject { @response.body.reviews[0] }
|
49
|
+
it { should be_a ::Hashie::Rash }
|
50
|
+
it { should respond_to :id }
|
51
|
+
it { should respond_to :user }
|
52
|
+
it { should respond_to :content }
|
53
|
+
it { should respond_to :title }
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Yotpo::User do
|
4
|
+
|
5
|
+
describe '#create_user' do
|
6
|
+
before(:all) do
|
7
|
+
@user_info = {
|
8
|
+
email: Faker::Internet.email,
|
9
|
+
display_name: Faker::Internet.user_name,
|
10
|
+
first_name: Faker::Name.first_name,
|
11
|
+
last_name: Faker::Name.last_name,
|
12
|
+
website_name: Faker::Internet.domain_name,
|
13
|
+
password: Faker::Lorem.words(3).join(' '),
|
14
|
+
support_url: Faker::Internet.http_url,
|
15
|
+
callback_url: Faker::Internet.http_url,
|
16
|
+
url: Faker::Internet.http_url
|
17
|
+
}
|
18
|
+
stub_post('/users').with(:body => Oj.dump({:user => @user_info})).to_return(:body => fixture('new_user.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
19
|
+
@response = Yotpo.create_user(@user_info)
|
20
|
+
end
|
21
|
+
subject { @response.body }
|
22
|
+
it { should be_a ::Hashie::Rash }
|
23
|
+
it { should respond_to :app_key }
|
24
|
+
it { should respond_to :secret }
|
25
|
+
it { should respond_to :token }
|
26
|
+
it { should respond_to :id }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#get_oauth_token' do
|
30
|
+
before(:all) do
|
31
|
+
oauth_request = {
|
32
|
+
app_key: 'a3lmMnC3u4SNmz0ZcHf3lODeIYM9LEQwtTWXRdDP',
|
33
|
+
secret: 'NumuadvlCGOTwnCCvY5BRAhGib1LTCFptYxfvebm',
|
34
|
+
grant_type: "client_credentials"
|
35
|
+
}
|
36
|
+
stub_request(:post, "https://api.yotpo.com/oauth/token").
|
37
|
+
with(:body => "{\":client_id\":\"a3lmMnC3u4SNmz0ZcHf3lODeIYM9LEQwtTWXRdDP\",\":client_secret\":\"NumuadvlCGOTwnCCvY5BRAhGib1LTCFptYxfvebm\",\":grant_type\":\"client_credentials\"}",
|
38
|
+
:headers => {'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.8.7', 'Yotpo-Api-Connector'=>'0.0.1'}).
|
39
|
+
to_return(:status => 200, :body => fixture('bearer_token.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
40
|
+
@response = Yotpo.get_oauth_token(oauth_request)
|
41
|
+
end
|
42
|
+
subject { @response.body }
|
43
|
+
it { should be_a ::Hashie::Rash }
|
44
|
+
it { should respond_to :access_token }
|
45
|
+
it { should respond_to :token_type }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#get_login_url' do
|
49
|
+
before(:all) do
|
50
|
+
request = {
|
51
|
+
app_key: 'a3lmMnC3u4SNmz0ZcHf3lODeIYM9LEQwtTWXRdDP',
|
52
|
+
secret: 'NumuadvlCGOTwnCCvY5BRAhGib1LTCFptYxfvebm'
|
53
|
+
}
|
54
|
+
stub_get('/users/b2blogin').with(:query => hash_including(request)).to_return(:body => fixture('get_login_url.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
55
|
+
@response = Yotpo.get_login_url(request)
|
56
|
+
end
|
57
|
+
subject { @response.body }
|
58
|
+
it { should be_a ::Hashie::Rash }
|
59
|
+
it { should respond_to :code }
|
60
|
+
it { should respond_to :signin_url }
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"status" : {
|
3
|
+
"code" : 200,
|
4
|
+
"message" : "OK"
|
5
|
+
},
|
6
|
+
"response" : {
|
7
|
+
"bottomlines" : [ {
|
8
|
+
"domain_key" : "62050632",
|
9
|
+
"product_score" : "3.45",
|
10
|
+
"total_reviews" : 11
|
11
|
+
}, {
|
12
|
+
"domain_key" : "62050052",
|
13
|
+
"product_score" : "3.0",
|
14
|
+
"total_reviews" : 3
|
15
|
+
}, {
|
16
|
+
"domain_key" : "62050122",
|
17
|
+
"product_score" : "4.64",
|
18
|
+
"total_reviews" : 11
|
19
|
+
}, {
|
20
|
+
"domain_key" : "73503772",
|
21
|
+
"product_score" : "4.76",
|
22
|
+
"total_reviews" : 17
|
23
|
+
}, {
|
24
|
+
"domain_key" : "92431514",
|
25
|
+
"product_score" : "4.52",
|
26
|
+
"total_reviews" : 25
|
27
|
+
}]
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"status": {
|
3
|
+
"code": 200,
|
4
|
+
"message": "OK"
|
5
|
+
},
|
6
|
+
"response": {
|
7
|
+
"purchases": [
|
8
|
+
{
|
9
|
+
"id": 80,
|
10
|
+
"user_email": "test@use.com",
|
11
|
+
"user_name": "lamba",
|
12
|
+
"product_sku": "123",
|
13
|
+
"order_id": "100",
|
14
|
+
"product_name": "ttt",
|
15
|
+
"product_url": "http://www.google.com",
|
16
|
+
"order_date": "2013-05-06T16:45:40Z",
|
17
|
+
"product_description": "lalalala",
|
18
|
+
"product_image": "http://www.google.com/images/srpr/logo4w.png",
|
19
|
+
"delivery_date": "2013-05-19T21:00:00Z",
|
20
|
+
"created_at": "2013-05-20T16:45:40Z"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"id": 980,
|
24
|
+
"user_email": "test@use.com",
|
25
|
+
"user_name": "lamba",
|
26
|
+
"product_sku": "123",
|
27
|
+
"order_id": "1000",
|
28
|
+
"product_name": "ttt",
|
29
|
+
"product_url": "http://www.google.com",
|
30
|
+
"order_date": "2013-05-06T16:46:04Z",
|
31
|
+
"product_description": "lalalala",
|
32
|
+
"product_image": "http://www.google.com/images/srpr/logo4w.png",
|
33
|
+
"delivery_date": "2013-05-19T21:00:00Z",
|
34
|
+
"created_at": "2013-05-20T16:46:04Z"
|
35
|
+
}
|
36
|
+
],
|
37
|
+
"total_purchases": 1001
|
38
|
+
}
|
39
|
+
}
|