yotpo 0.1.0 → 1.0.0

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.
Files changed (55) hide show
  1. checksums.yaml +5 -13
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +0 -2
  4. data/lib/yotpo.rb +1 -1
  5. data/lib/yotpo/api/account_social.rb +39 -0
  6. data/lib/yotpo/api/answer.rb +16 -0
  7. data/lib/yotpo/api/comment.rb +38 -0
  8. data/lib/yotpo/api/feature.rb +12 -0
  9. data/lib/yotpo/api/oauth.rb +13 -0
  10. data/lib/yotpo/api/owner_feature.rb +48 -0
  11. data/lib/yotpo/api/owner_feature_setting.rb +37 -0
  12. data/lib/yotpo/api/product.rb +13 -0
  13. data/lib/yotpo/api/question.rb +44 -0
  14. data/lib/yotpo/api/review.rb +4 -1
  15. data/lib/yotpo/api/user.rb +5 -0
  16. data/lib/yotpo/client.rb +21 -5
  17. data/lib/yotpo/core/response_parser.rb +5 -3
  18. data/lib/yotpo/version.rb +1 -1
  19. data/spec/api/account_social_spec.rb +59 -0
  20. data/spec/api/answer_spec.rb +32 -0
  21. data/spec/api/comment_spec.rb +74 -0
  22. data/spec/api/feature_spec.rb +21 -0
  23. data/spec/api/oauth_spec.rb +22 -0
  24. data/spec/api/owner_feature_setting_spec.rb +79 -0
  25. data/spec/api/owner_feature_spec.rb +77 -0
  26. data/spec/api/product_spec.rb +18 -0
  27. data/spec/api/purchase_spec.rb +2 -2
  28. data/spec/api/question_spec.rb +53 -0
  29. data/spec/api/review_spec.rb +17 -0
  30. data/spec/api/user_spec.rb +14 -0
  31. data/spec/cassettes/add_features.yml +51 -0
  32. data/spec/cassettes/add_shop_owner_answer.yml +49 -0
  33. data/spec/cassettes/add_vote_to_review.yml +46 -0
  34. data/spec/cassettes/anonymous_user_confirmation.yml +49 -0
  35. data/spec/cassettes/create_account_social.yml +51 -0
  36. data/spec/cassettes/create_comment.yml +53 -0
  37. data/spec/cassettes/create_new_purchase.yml +23 -28
  38. data/spec/cassettes/get_account_social.yml +51 -0
  39. data/spec/cassettes/get_feature_settings.yml +50 -0
  40. data/spec/cassettes/get_features.yml +191 -0
  41. data/spec/cassettes/get_owner_features.yml +106 -0
  42. data/spec/cassettes/get_product_url.yml +93 -0
  43. data/spec/cassettes/mass_update_feature_settings.yml +48 -0
  44. data/spec/cassettes/owner_feature_settings.yml +49 -0
  45. data/spec/cassettes/question_create_by_token.yml +49 -0
  46. data/spec/cassettes/question_send_confirmation.yml +74 -0
  47. data/spec/cassettes/remove_feature.yml +49 -0
  48. data/spec/cassettes/update_account_social.yml +50 -0
  49. data/spec/cassettes/update_comment.yml +50 -0
  50. data/spec/cassettes/update_comment_avatar.yml +48 -0
  51. data/spec/cassettes/update_feature_settings.yml +48 -0
  52. data/spec/cassettes/user_enable_feature.yml +49 -0
  53. data/spec/cassettes/validate_token.yml +48 -0
  54. data/yotpo.gemspec +2 -2
  55. metadata +99 -26
@@ -0,0 +1,32 @@
1
+ require 'helper'
2
+
3
+ describe Yotpo::Answer do
4
+
5
+ describe '#add_shop_owner_answer' do
6
+ before(:all) do
7
+ answer_request = {
8
+ content: 'This is the answer',
9
+ public: true,
10
+ utoken: @utoken,
11
+ question_id: 451
12
+ }
13
+ VCR.use_cassette('add_shop_owner_answer') do
14
+ @response = Yotpo.add_shop_owner_answer(answer_request)
15
+ end
16
+ end
17
+
18
+ subject { @response.body.comment }
19
+ it { should be_a ::Hashie::Mash }
20
+ it { should respond_to :id }
21
+ it { should respond_to :commentable_id}
22
+ it { should respond_to :content}
23
+ it { should respond_to :commentable_type}
24
+ it { should respond_to :votes_up}
25
+ it { should respond_to :votes_down}
26
+ it { should respond_to :public}
27
+ it { should respond_to :approved}
28
+ it { should respond_to :created_at}
29
+ it { should respond_to :store_owner_comment}
30
+ it { should respond_to :answerer}
31
+ end
32
+ end
@@ -0,0 +1,74 @@
1
+ require 'helper'
2
+
3
+ describe Yotpo::Comment do
4
+ describe '#create_comment' do
5
+ before(:all) do
6
+ create_comment_params = {
7
+ utoken: @utoken,
8
+ review_id: 1,
9
+ content: 'Comment content',
10
+ public: true
11
+ }
12
+ VCR.use_cassette('create_comment') do
13
+ @response = Yotpo.create_comment(create_comment_params)
14
+ end
15
+ end
16
+
17
+ subject { @response.body.comment }
18
+ it { should be_a ::Hashie::Mash }
19
+ it { should respond_to :id }
20
+ it { should respond_to :commentable_id }
21
+ it { should respond_to :commentable_type }
22
+ it { should respond_to :content }
23
+ it { should respond_to :public }
24
+ it { should respond_to :created_at }
25
+ end
26
+
27
+ describe '#update_comment' do
28
+ before(:all) do
29
+ create_comment_params = {
30
+ utoken: @utoken,
31
+ review_id: 1,
32
+ comment_id: 695,
33
+ content: 'Comment content',
34
+ public: true
35
+ }
36
+ VCR.use_cassette('update_comment') do
37
+ @response = Yotpo.update_comment(create_comment_params)
38
+ end
39
+ end
40
+
41
+ subject { @response.body.comment }
42
+ it { should be_a ::Hashie::Mash }
43
+ it { should respond_to :id }
44
+ it { should respond_to :commentable_id }
45
+ it { should respond_to :commentable_type }
46
+ it { should respond_to :content }
47
+ it { should respond_to :public }
48
+ it { should respond_to :created_at }
49
+ end
50
+
51
+ describe '#update_comment_avatar' do
52
+ before(:all) do
53
+ update_avatar_params = {
54
+ utoken: @utoken,
55
+ app_key: @app_key,
56
+ comments_avatar_data: {
57
+ 'original_filename' => 'image',
58
+ 'data' => Base64.encode64('image'),
59
+ content_type: 'image/jpg'
60
+ },
61
+ comments_display_name: 'Tova'
62
+ }
63
+
64
+ VCR.use_cassette('update_comment_avatar') do
65
+ @response = Yotpo.update_comment_avatar(update_avatar_params)
66
+ end
67
+ end
68
+
69
+ subject { @response.body }
70
+ it { should be_a ::Hashie::Mash }
71
+ it { should respond_to :code }
72
+ it { should respond_to :message}
73
+ end
74
+ end
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ describe Yotpo::Feature do
4
+ describe '#get_features' do
5
+ before(:all) do
6
+ get_features_params = {
7
+ utoken: @utoken
8
+ }
9
+ VCR.use_cassette('get_features') do
10
+ @response = Yotpo.get_features(get_features_params)
11
+ end
12
+ end
13
+
14
+ subject { @response.body.features[0] }
15
+ it { should be_a ::Hashie::Mash }
16
+ it { should respond_to :id }
17
+ it { should respond_to :name }
18
+ it { should respond_to :description }
19
+ it { should respond_to :owner_type }
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'helper'
2
+
3
+ describe Yotpo::Oauth do
4
+ describe '#validate_token' do
5
+ before(:all) do
6
+ validate_token_params = {
7
+ utoken: @utoken,
8
+ app_key: @app_key
9
+ }
10
+ VCR.use_cassette('validate_token') do
11
+ @response = Yotpo.validate_token(validate_token_params)
12
+ end
13
+ end
14
+
15
+ subject { @response.body }
16
+ it { should be_a ::Hashie::Mash }
17
+ it { should respond_to :Status }
18
+ it { should respond_to :user_id }
19
+ it { should respond_to :user_has_access_to_account }
20
+ it { should respond_to :application_id }
21
+ end
22
+ end
@@ -0,0 +1,79 @@
1
+ require 'helper'
2
+
3
+ describe Yotpo::OwnerFeatureSetting do
4
+
5
+ describe '#get_feature_settings' do
6
+ before(:all) do
7
+ get_settings_params = {
8
+ utoken: @utoken,
9
+ feature_id: 11,
10
+ owner_ids: [300]
11
+ }
12
+ VCR.use_cassette('get_feature_settings') do
13
+ @response = Yotpo.get_feature_settings(get_settings_params)
14
+ end
15
+ end
16
+
17
+ subject { @response.body['300'] }
18
+ it { should be_a ::Hashie::Mash }
19
+ it { should respond_to :font_size }
20
+ end
21
+
22
+ describe '#mass_update_feature_settings' do
23
+ before(:all) do
24
+ feature_update_params = {
25
+ utoken: @utoken,
26
+ settings: { font_size: '12' },
27
+ feature_id: 11,
28
+ owner_id: 7
29
+ }
30
+ VCR.use_cassette('mass_update_feature_settings') do
31
+ @response = Yotpo.mass_update_feature_settings(feature_update_params)
32
+ end
33
+ end
34
+
35
+ subject { @response.body }
36
+ it { should be_a ::Hashie::Mash }
37
+ it { should respond_to :code }
38
+ it { should respond_to :message }
39
+ end
40
+
41
+ describe '#owner_feature_settings' do
42
+ before(:all) do
43
+ feature_settings_params = {
44
+ utoken: @utoken,
45
+ feature_id: 11,
46
+ app_key: @app_key
47
+ }
48
+ VCR.use_cassette('owner_feature_settings') do
49
+ @response = Yotpo.owner_feature_settings(feature_settings_params)
50
+ end
51
+ end
52
+
53
+ subject { @response.body }
54
+ it { should be_a ::Hashie::Mash }
55
+ it { should respond_to :font_size }
56
+ end
57
+
58
+ describe '#update_feature_settings' do
59
+ before(:all) do
60
+ feature_update_params = {
61
+ utoken: @utoken,
62
+ value: 10,
63
+ key: 'font_size',
64
+ app_key: @app_key,
65
+ feature_id: 11,
66
+ feature_settings_id: 38
67
+ }
68
+ VCR.use_cassette('update_feature_settings') do
69
+ @response = Yotpo.update_feature_settings(feature_update_params)
70
+ end
71
+ end
72
+
73
+ subject { @response.body }
74
+ it { should be_a ::Hashie::Mash }
75
+ it { should respond_to :code }
76
+ it { should respond_to :message }
77
+ end
78
+
79
+ end
@@ -0,0 +1,77 @@
1
+ require 'helper'
2
+
3
+ describe Yotpo::OwnerFeature do
4
+ describe '#add_feature' do
5
+ before(:all) do
6
+ add_feature_params = {
7
+ owner_type: :account,
8
+ owner_id: @app_key,
9
+ feature_id: 1,
10
+ utoken: @utoken
11
+ }
12
+ VCR.use_cassette('add_features') do
13
+ @response = Yotpo.add_feature(add_feature_params)
14
+ end
15
+ end
16
+
17
+ subject { @response.body }
18
+ it { should be_a ::Hashie::Mash }
19
+ it { should respond_to :code }
20
+ it { should respond_to :message }
21
+ end
22
+
23
+ describe '#remove_feature' do
24
+ before(:all) do
25
+ remove_feature_params = {
26
+ owner_type: :account,
27
+ owner_id: @app_key,
28
+ feature_id: 1,
29
+ utoken: @utoken
30
+ }
31
+ VCR.use_cassette('remove_feature') do
32
+ @response = Yotpo.remove_feature(remove_feature_params)
33
+ end
34
+ end
35
+
36
+ subject { @response.body }
37
+ it { should be_a ::Hashie::Mash }
38
+ it { should respond_to :code }
39
+ it { should respond_to :message }
40
+ end
41
+
42
+ describe '#get_owner_features' do
43
+ before(:all) do
44
+ get_owner_features_params = {
45
+ utoken: @utoken,
46
+ app_key: @app_key
47
+ }
48
+ VCR.use_cassette('get_owner_features') do
49
+ @response = Yotpo.get_owner_features(get_owner_features_params)
50
+ end
51
+ end
52
+
53
+ subject { @response.body }
54
+ it { should be_a ::Hashie::Mash }
55
+ it { should respond_to :features }
56
+ end
57
+
58
+ describe '#user_enable_feature' do
59
+ before(:all) do
60
+ user_enable_feature_params = {
61
+ utoken: @utoken,
62
+ app_key: @app_key,
63
+ feature_id: 5,
64
+ user_enabled: true
65
+ }
66
+ VCR.use_cassette('user_enable_feature') do
67
+ @response = Yotpo.user_enable_feature(user_enable_feature_params)
68
+ end
69
+ end
70
+
71
+ subject { @response.body.feature }
72
+ it { should be_a ::Hashie::Mash }
73
+ it { should respond_to :name }
74
+ it { should respond_to :description }
75
+ end
76
+
77
+ end
@@ -35,4 +35,22 @@ describe Yotpo::Product do
35
35
  it { should respond_to :average_score }
36
36
  it { should respond_to :total_reviews }
37
37
  end
38
+
39
+ describe '#get_product_url' do
40
+ before(:all) do
41
+ product_url_params = {
42
+ utoken: @utoken,
43
+ reference: 'instagram_comment',
44
+ product_id: '120915246',
45
+ app_key: 'vzStmYud6bHLto5ksn5DoGoA7ghM0kzjMdH2DS5T',
46
+ sub_reference: '10'
47
+ }
48
+ VCR.use_cassette('get_product_url') do
49
+ @response = Yotpo.get_product_url(product_url_params)
50
+ end
51
+ end
52
+
53
+ subject { @response.body }
54
+ it { should be_a ::Hashie::Mash }
55
+ end
38
56
  end
@@ -8,14 +8,14 @@ describe Yotpo::Purchase do
8
8
  customer_name: 'Customer Name',
9
9
  order_id: '123',
10
10
  platform: 'shopify',
11
- products: [
11
+ products: {
12
12
  p1: {
13
13
  url: 'http://example_product_url1.com',
14
14
  name: 'product1',
15
15
  image: 'http://example_product_image_url1.com',
16
16
  description: 'this is the description of a product'
17
17
  }
18
- ],
18
+ },
19
19
  utoken: @utoken,
20
20
  app_key: @app_key
21
21
  }
@@ -0,0 +1,53 @@
1
+ require 'helper'
2
+
3
+ describe Yotpo::Question do
4
+
5
+ describe '#question_send_confirmation' do
6
+ before(:all) do
7
+ question = {
8
+ app_key: @app_key,
9
+ product_id: 'D-4771',
10
+ product_title: 'Product Title',
11
+ product_url: 'https://www.google.com/?q=pforducturl',
12
+ user_display_name: 'User Name',
13
+ user_email: 'user@email.com',
14
+ review_body: 'Integer feugiat nunc non leo vehicula bibendum. Nulla at tortor at nulla faucibus suscipit. Curabitur sodales est vel orci lobortis convallis. Vestibulum sit amet tellus neque, ac euismod arcu. Phasellus a nunc ultrices erat condimentum facilisis. Donec a odio in ligula vestibulum lobortis. Mauris posuere, justo tincidunt tincidunt interdum, felis velit venenatis augue, vel rhoncus purus turpis ut magna. Quisque consequat elit vitae enim molestie mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur adipiscing consequat lectus eu pulvinar. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae' ,
15
+ review_source: 'widget_v2',
16
+ product_description: 'Nullam ultrices purus a metus porttitor hendrerit. Vivamus accumsan congue urna a viverra. Nam molestie euismod est, vitae sollicitudin velit scelerisque vel. Quisque feugiat, metus sed tempus malesuada, quam erat volutpat metus, a tempor felis est id purus. Ut nec felis nunc, id cursus magna. Mauris sollicitudin ultrices velit vitae viverra. Nulla faucibus lacus id nisl euismod porta. Curabitur mi magna, tempus tristique commodo sit amet, imperdiet in eros. Proin eros arcu, ornare in lobortis eu, posuere ut risus. Quisque fermentum varius nibh, id aliquet lectus congue quis. In placerat arcu at libero posuere eleifend. Donec lacinia mollis lacus, at aliquam nisi molestie nec. Cras eleifend gravida nulla, vitae mollis eros varius eleifend. Pellentesque elit sem, lacinia eget fringilla vitae, condimentum eu quam. Proin quis orci arcu, ut suscipit arcu.',
17
+ product_image_url: 'https://www.google.com/images/srpr/logo4w.png',
18
+ }
19
+ VCR.use_cassette('question_send_confirmation') do
20
+ @response = Yotpo.question_send_confirmation(question)
21
+ end
22
+ end
23
+
24
+ subject { @response.body }
25
+ it { should be_a ::Hashie::Mash }
26
+ it { should respond_to :code }
27
+ it { should respond_to :message }
28
+ end
29
+
30
+ describe '#question_create_by_token' do
31
+ before(:all) do
32
+ question = {
33
+ content: 'Integer feugiat nunc non leo vehicula bibendum. Nulla at tortor at nulla faucibus suscipit. Curabitur sodales est vel orci lobortis convallis. Vestibulum sit amet tellus neque, ac euismod arcu. Phasellus a nunc ultrices erat condimentum facilisis. Donec a odio in ligula vestibulum lobortis. Mauris posuere, justo tincidunt tincidunt interdum, felis velit venenatis augue, vel rhoncus purus turpis ut magna. Quisque consequat elit vitae enim molestie mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur adipiscing consequat lectus eu pulvinar. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae' ,
34
+ product_description: 'Nullam ultrices purus a metus porttitor hendrerit. Vivamus accumsan congue urna a viverra. Nam molestie euismod est, vitae sollicitudin velit scelerisque vel. Quisque feugiat, metus sed tempus malesuada, quam erat volutpat metus, a tempor felis est id purus. Ut nec felis nunc, id cursus magna. Mauris sollicitudin ultrices velit vitae viverra. Nulla faucibus lacus id nisl euismod porta. Curabitur mi magna, tempus tristique commodo sit amet, imperdiet in eros. Proin eros arcu, ornare in lobortis eu, posuere ut risus. Quisque fermentum varius nibh, id aliquet lectus congue quis. In placerat arcu at libero posuere eleifend. Donec lacinia mollis lacus, at aliquam nisi molestie nec. Cras eleifend gravida nulla, vitae mollis eros varius eleifend. Pellentesque elit sem, lacinia eget fringilla vitae, condimentum eu quam. Proin quis orci arcu, ut suscipit arcu.',
35
+ product_image_url: 'https://www.google.com/images/srpr/logo4w.png',
36
+ product_name: 'Product Title',
37
+ product_url: 'https://www.google.com/?q=pforducturl',
38
+ product_id:'D-4771',
39
+ token: '430c58a5b4880d915ef1af941d315648289c8aad',
40
+ utm_campaign: 'general',
41
+ utm_medium: 'general',
42
+ utm_source: 'yotpo'
43
+ }
44
+ VCR.use_cassette('question_create_by_token') do
45
+ @response = Yotpo.question_create_by_token(question)
46
+ end
47
+ end
48
+
49
+ subject { @response.body }
50
+ it { should eq '<html><body>You are being <a href="https://landing-pages.yotpo.com/question?mail_language=en">redirected</a>.</body></html>' }
51
+ end
52
+
53
+ end
@@ -51,4 +51,21 @@ describe Yotpo::Review do
51
51
  it { should respond_to :content }
52
52
  it { should respond_to :title }
53
53
  end
54
+
55
+ describe '#add_vote_to_review' do
56
+ before(:all) do
57
+ add_vote_params = {
58
+ review_id: 2,
59
+ vote_value: 'up'
60
+ }
61
+ VCR.use_cassette('add_vote_to_review') do
62
+ @response = Yotpo.add_vote_to_review(add_vote_params)
63
+ end
64
+ end
65
+
66
+ subject { @response.body.vote }
67
+ it { should be_a ::Hashie::Mash }
68
+ it { should respond_to :id }
69
+
70
+ end
54
71
  end
@@ -61,4 +61,18 @@ describe Yotpo::User do
61
61
  it { should respond_to :signin_url }
62
62
 
63
63
  end
64
+
65
+ describe '#anonymous_user_confirmation' do
66
+ before(:all) do
67
+ request = {
68
+ token: 'PC3yqmddeS434jWW1bVi'
69
+ }
70
+ VCR.use_cassette('anonymous_user_confirmation') do
71
+ @response = Yotpo.anonymous_user_confirmation(request)
72
+ end
73
+ end
74
+ subject { @response.body }
75
+ it { should eq '<html><body>You are being <a href="https://www.yotpo.com/500.html">redirected</a>.</body></html>' }
76
+
77
+ end
64
78
  end