voog_api 0.0.13 → 0.0.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ec58e5122f42a27bde963293ac34eb0615987b26
4
- data.tar.gz: 4ee9bba8f00107cc58bb0f26133545dc228b3e46
2
+ SHA256:
3
+ metadata.gz: f85ae8aa46dd44c9603c22642230e6031d3211869c7040eaca8f1de9e610d8da
4
+ data.tar.gz: 4a7a8012e070a615d3c130d17c96612bb7c06b182213b0d22e4eeb00dfeb8244
5
5
  SHA512:
6
- metadata.gz: 705b1a7ec836bb870ad65e3dd79644846e120f46cf0c91bd1a1a50123973501e481b92505a59eefdb0fab1dc317269bf9533a184ff2a194a1bcc701e6a2edb88
7
- data.tar.gz: 70778160167e82c5ebdeadf69ffb3e40ea79ac283074548417bf3956a815937ac98cf2e728bf3bf4cce2f38b734f1f13b12c5fb9fa31cc31ba304addeff9adb5
6
+ metadata.gz: c11f5bc2af799cabcff5e8652a35133a25a098df075125201f1ffd59ff17aa5c9292385fc6ac04db334c7193a36dd78c185cb1ccb2d2d4fa5837ed0382110263
7
+ data.tar.gz: e15f1cfd517c7b52d615f359f725411fe34c4589bf959a036d208ef0a4e598ab9a290bcebfe716bbc8af7f33e1015d434b541c351bb19f72807e3ab92f723a4c
@@ -0,0 +1,30 @@
1
+ module Voog
2
+ class API
3
+ # Voog Buy Buttons API methods.
4
+ #
5
+ # @see https://www.voog.com/developers/api/resources/buy_buttons
6
+ module BuyButtons
7
+
8
+ # List buy_buttons
9
+ #
10
+ # @see https://www.voog.com/developers/api/resources/buy_buttons#get_buy_buttons
11
+ def buy_buttons(params = {})
12
+ paginate 'buy_buttons', {query: params}
13
+ end
14
+
15
+ # Get a single buy_button
16
+ #
17
+ # @see https://www.voog.com/developers/api/resources/buy_buttons#get_buy_button
18
+ def buy_button(id, params = {})
19
+ get "buy_buttons/#{id}", {query: params}
20
+ end
21
+
22
+ # Update a buy_button
23
+ #
24
+ # @see https://www.voog.com/developers/api/resources/buy_buttons#update_buy_button
25
+ def update_buy_button(id, data)
26
+ put "buy_buttons/#{id}", data
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ module Voog
2
+
3
+ class API
4
+ # Voog Product Widgets API methods.
5
+ #
6
+ # @see https://www.voog.com/developers/api/resources/product_widgets
7
+ module ProductWidgets
8
+
9
+ # List product_widgets
10
+ #
11
+ # @see https://www.voog.com/developers/api/resources/product_widgets#get_product_widgets
12
+ def product_widgets(params = {})
13
+ paginate 'product_widgets', {query: params}
14
+ end
15
+
16
+ # Get a single product_widget
17
+ #
18
+ # @see https://www.voog.com/developers/api/resources/product_widgets#get_product_widget
19
+ def product_widget(id, params = {})
20
+ get "product_widgets/#{id}", {query: params}
21
+ end
22
+
23
+ # Update a product_widget
24
+ #
25
+ # @see https://www.voog.com/developers/api/resources/product_widgets#update_product_widget
26
+ def update_product_widget(id, data)
27
+ put "product_widgets/#{id}", data
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,44 @@
1
+ module Voog
2
+ class API
3
+ # Voog Redirect Rules API methods.
4
+ #
5
+ # @see https://www.voog.com/developers/api/resources/redirect_rules
6
+ module RedirectRules
7
+
8
+ # List redirect_rules
9
+ #
10
+ # @see https://www.voog.com/developers/api/resources/redirect_rules#get_redirect_rules
11
+ def redirect_rules(params = {})
12
+ paginate 'redirect_rules', {query: params}
13
+ end
14
+
15
+ # Get a single redirect_rule
16
+ #
17
+ # @see https://www.voog.com/developers/api/resources/redirect_rules#get_redirect_rule
18
+ def redirect_rule(id, params = {})
19
+ get "redirect_rules/#{id}", {query: params}
20
+ end
21
+
22
+ # Create a new redirect_rule
23
+ #
24
+ # @see https://www.voog.com/developers/api/resources/redirect_rules#create_redirect_rules
25
+ def create_redirect_rule(data)
26
+ post 'redirect_rules', data
27
+ end
28
+
29
+ # Update a redirect_rule
30
+ #
31
+ # @see https://www.voog.com/developers/api/resources/redirect_rules#update_redirect_rule
32
+ def update_redirect_rule(id, data)
33
+ put "redirect_rules/#{id}", data
34
+ end
35
+
36
+ # Delete a redirect_rule
37
+ #
38
+ # @see https://www.voog.com/developers/api/resources/redirect_rules#delete_redirect_rule
39
+ def delete_redirect_rule(id)
40
+ delete "redirect_rules/#{id}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -5,6 +5,7 @@ require 'voog_api/error'
5
5
 
6
6
  require 'voog_api/api/articles'
7
7
  require 'voog_api/api/assets'
8
+ require 'voog_api/api/buy_buttons'
8
9
  require 'voog_api/api/comments'
9
10
  require 'voog_api/api/content_partials'
10
11
  require 'voog_api/api/contents'
@@ -12,15 +13,17 @@ require 'voog_api/api/element_definitions'
12
13
  require 'voog_api/api/elements'
13
14
  require 'voog_api/api/forms'
14
15
  require 'voog_api/api/languages'
15
- require 'voog_api/api/layouts'
16
16
  require 'voog_api/api/layout_assets'
17
+ require 'voog_api/api/layouts'
17
18
  require 'voog_api/api/media_sets'
18
19
  require 'voog_api/api/nodes'
19
- require 'voog_api/api/site'
20
20
  require 'voog_api/api/pages'
21
21
  require 'voog_api/api/people'
22
+ require 'voog_api/api/product_widgets'
23
+ require 'voog_api/api/redirect_rules'
22
24
  require 'voog_api/api/search'
23
25
  require 'voog_api/api/site_users'
26
+ require 'voog_api/api/site'
24
27
  require 'voog_api/api/tags'
25
28
  require 'voog_api/api/texts'
26
29
  require 'voog_api/api/tickets'
@@ -36,6 +39,7 @@ module Voog
36
39
 
37
40
  include Voog::API::Articles
38
41
  include Voog::API::Assets
42
+ include Voog::API::BuyButtons
39
43
  include Voog::API::Comments
40
44
  include Voog::API::ContentPartials
41
45
  include Voog::API::Contents
@@ -43,12 +47,14 @@ module Voog
43
47
  include Voog::API::Elements
44
48
  include Voog::API::Forms
45
49
  include Voog::API::Languages
46
- include Voog::API::Layouts
47
50
  include Voog::API::LayoutAssets
51
+ include Voog::API::Layouts
48
52
  include Voog::API::MediaSets
49
53
  include Voog::API::Nodes
50
54
  include Voog::API::Pages
51
55
  include Voog::API::People
56
+ include Voog::API::ProductWidgets
57
+ include Voog::API::RedirectRules
52
58
  include Voog::API::Search
53
59
  include Voog::API::Site
54
60
  include Voog::API::SiteUsers
@@ -81,7 +87,7 @@ module Voog
81
87
  def get(url, options = {})
82
88
  request :get, url, nil, options
83
89
  end
84
-
90
+
85
91
  def post(url, data, options = {})
86
92
  request :post, url, data, options
87
93
  end
@@ -101,7 +107,7 @@ module Voog
101
107
  def head(url, options = {})
102
108
  request :head, url, nil, options
103
109
  end
104
-
110
+
105
111
  def api_endpoint
106
112
  "#{host_with_protocol}/admin/api".freeze
107
113
  end
@@ -109,7 +115,7 @@ module Voog
109
115
  def host_with_protocol
110
116
  "#{protocol}://#{host}".freeze
111
117
  end
112
-
118
+
113
119
  def agent
114
120
  @agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
115
121
  http.headers[:content_type] = 'application/json'
@@ -129,7 +135,7 @@ module Voog
129
135
  faraday.headers[:user_agent] = 'Voog.rb Ruby wrapper'
130
136
  end
131
137
  end
132
-
138
+
133
139
  def last_response
134
140
  @last_response
135
141
  end
@@ -144,6 +150,7 @@ module Voog
144
150
  def paginate(url, options = {}, &block)
145
151
  opts = options.dup
146
152
  if @auto_paginate || @per_page
153
+ opts[:query] ||= {}
147
154
  opts[:query][:per_page] ||= @per_page || (@auto_paginate ? MAX_PER_PAGE : nil)
148
155
  end
149
156
 
@@ -161,16 +168,16 @@ module Voog
161
168
  end
162
169
 
163
170
  data
164
- end
171
+ end
165
172
 
166
173
  private
167
-
174
+
168
175
  def request(method, path, data, options = {})
169
176
  multipart = options.fetch(:multipart, false) && (method == :post)
170
177
 
171
178
  @last_response = response = multipart ? \
172
179
  multipart_agent.post("#{api_endpoint}/#{path}", data) : \
173
- agent.call(method, URI.encode(path.to_s), data, options.dup)
180
+ agent.call(method, URI.parse(path.to_s), data, options.dup)
174
181
 
175
182
  raise Voog::MovedPermanently.new(response, host_with_protocol) if response.status == 301
176
183
 
@@ -1,3 +1,3 @@
1
1
  module Voog
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.15'
3
3
  end
@@ -0,0 +1,38 @@
1
+ {
2
+ "id": 2,
3
+ "created_at": "2023-11-17T12:56:36.000Z",
4
+ "updated_at": "2023-11-17T12:56:36.000Z",
5
+ "settings": {
6
+ "title": "Add to cart",
7
+ "button_style": "with_price"
8
+ },
9
+ "url": "http://voog.test/admin/api/buy_buttons/2",
10
+ "content": {
11
+ "id": 2,
12
+ "name": "body",
13
+ "created_at": "2023-11-17T12:56:36.000Z",
14
+ "updated_at": "2023-11-17T12:56:36.000Z",
15
+ "position": 1,
16
+ "url": "http://voog.test/admin/api/pages/1/contents/2"
17
+ },
18
+ "parent": {
19
+ "id": 1,
20
+ "title": "Home",
21
+ "created_at": "2023-11-17T12:55:36.000Z",
22
+ "updated_at": "2023-11-17T12:55:36.000Z",
23
+ "type": "page",
24
+ "url": "http://voog.test/admin/api/pages/1"
25
+ },
26
+ "product": {
27
+ "id": 1,
28
+ "name": "Product",
29
+ "price": "100.0",
30
+ "status": "live",
31
+ "created_at": "2023-11-17T12:55:36.000Z",
32
+ "updated_at": "2023-11-17T12:55:36.000Z",
33
+ "sku": "product-sku",
34
+ "uses_variants": false,
35
+ "tax_rate": "20.0",
36
+ "in_stock": true
37
+ }
38
+ }
@@ -0,0 +1,78 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "created_at": "2023-11-17T12:55:36.000Z",
5
+ "updated_at": "2023-11-17T12:55:36.000Z",
6
+ "settings": {
7
+ "title": "Add to cart",
8
+ "button_style": "with_price"
9
+ },
10
+ "url": "http://voog.test/admin/api/buy_buttons/1",
11
+ "content": {
12
+ "id": 1,
13
+ "name": "body",
14
+ "created_at": "2023-11-17T12:55:36.000Z",
15
+ "updated_at": "2023-11-17T12:55:36.000Z",
16
+ "position": 1,
17
+ "url": "http://voog.test/admin/api/pages/1/contents/1"
18
+ },
19
+ "parent": {
20
+ "id": 1,
21
+ "title": "Home",
22
+ "created_at": "2023-11-17T12:55:36.000Z",
23
+ "updated_at": "2023-11-17T12:55:36.000Z",
24
+ "type": "page",
25
+ "url": "http://voog.test/admin/api/pages/1"
26
+ },
27
+ "product": {
28
+ "id": 1,
29
+ "name": "Product",
30
+ "price": "100.0",
31
+ "status": "live",
32
+ "created_at": "2023-11-17T12:55:36.000Z",
33
+ "updated_at": "2023-11-17T12:55:36.000Z",
34
+ "sku": "product-sku",
35
+ "uses_variants": false,
36
+ "tax_rate": "20.0",
37
+ "in_stock": true
38
+ }
39
+ },
40
+ {
41
+ "id": 2,
42
+ "created_at": "2023-11-17T12:56:36.000Z",
43
+ "updated_at": "2023-11-17T12:56:36.000Z",
44
+ "settings": {
45
+ "title": "Add to cart",
46
+ "button_style": "with_price"
47
+ },
48
+ "url": "http://voog.test/admin/api/buy_buttons/2",
49
+ "content": {
50
+ "id": 2,
51
+ "name": "body",
52
+ "created_at": "2023-11-17T12:56:36.000Z",
53
+ "updated_at": "2023-11-17T12:56:36.000Z",
54
+ "position": 1,
55
+ "url": "http://voog.test/admin/api/pages/1/contents/2"
56
+ },
57
+ "parent": {
58
+ "id": 1,
59
+ "title": "Home",
60
+ "created_at": "2023-11-17T12:55:36.000Z",
61
+ "updated_at": "2023-11-17T12:55:36.000Z",
62
+ "type": "page",
63
+ "url": "http://voog.test/admin/api/pages/1"
64
+ },
65
+ "product": {
66
+ "id": 1,
67
+ "name": "Product",
68
+ "price": "100.0",
69
+ "status": "live",
70
+ "created_at": "2023-11-17T12:55:36.000Z",
71
+ "updated_at": "2023-11-17T12:55:36.000Z",
72
+ "sku": "product-sku",
73
+ "uses_variants": false,
74
+ "tax_rate": "20.0",
75
+ "in_stock": true
76
+ }
77
+ }
78
+ ]
@@ -0,0 +1,41 @@
1
+ {
2
+ "id": 2,
3
+ "created_at": "2023-11-17T13:26:47.000Z",
4
+ "updated_at": "2023-11-17T13:26:47.000Z",
5
+ "content_settings": {
6
+ "category_ids": [],
7
+ "sort_order": "created_at-desc"
8
+ },
9
+ "design_settings": {
10
+ "layout": "grid",
11
+ "columns": 3,
12
+ "item_width": 300,
13
+ "item_height": 600,
14
+ "mask_content_overflow": true,
15
+ "show_navigation_buttons": true,
16
+ "mobile_columns": 2,
17
+ "show_cart_button": true,
18
+ "show_price": true,
19
+ "show_product_filters": true,
20
+ "product_count": 56,
21
+ "show_discount_label": false,
22
+ "show_discount_percentage": false
23
+ },
24
+ "url": "http://voog.test/admin/api/product_widgets/2",
25
+ "content": {
26
+ "id": 2,
27
+ "name": "body",
28
+ "created_at": "2023-11-17T12:56:36.000Z",
29
+ "updated_at": "2023-11-17T12:56:36.000Z",
30
+ "position": 1,
31
+ "url": "http://voog.test/admin/api/pages/1/contents/2"
32
+ },
33
+ "parent": {
34
+ "id": 1,
35
+ "title": "Home",
36
+ "created_at": "2023-11-17T12:55:36.000Z",
37
+ "updated_at": "2023-11-17T12:55:36.000Z",
38
+ "type": "page",
39
+ "url": "http://voog.test/admin/api/pages/1"
40
+ }
41
+ }
@@ -0,0 +1,84 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "created_at": "2023-11-17T13:25:47.000Z",
5
+ "updated_at": "2023-11-17T13:25:47.000Z",
6
+ "content_settings": {
7
+ "category_ids": [],
8
+ "sort_order": "created_at-desc"
9
+ },
10
+ "design_settings": {
11
+ "layout": "grid",
12
+ "columns": 3,
13
+ "item_width": 300,
14
+ "item_height": 600,
15
+ "mask_content_overflow": true,
16
+ "show_navigation_buttons": true,
17
+ "mobile_columns": 2,
18
+ "show_cart_button": true,
19
+ "show_price": true,
20
+ "show_product_filters": true,
21
+ "product_count": 56,
22
+ "show_discount_label": false,
23
+ "show_discount_percentage": false
24
+ },
25
+ "url": "http://voog.test/admin/api/product_widgets/1",
26
+ "content": {
27
+ "id": 1,
28
+ "name": "body",
29
+ "created_at": "2023-11-17T12:55:36.000Z",
30
+ "updated_at": "2023-11-17T12:55:36.000Z",
31
+ "position": 1,
32
+ "url": "http://voog.test/admin/api/pages/1/contents/1"
33
+ },
34
+ "parent": {
35
+ "id": 1,
36
+ "title": "Home",
37
+ "created_at": "2023-11-17T12:55:36.000Z",
38
+ "updated_at": "2023-11-17T12:55:36.000Z",
39
+ "type": "page",
40
+ "url": "http://voog.test/admin/api/pages/1"
41
+ }
42
+ },
43
+ {
44
+ "id": 2,
45
+ "created_at": "2023-11-17T13:26:47.000Z",
46
+ "updated_at": "2023-11-17T13:26:47.000Z",
47
+ "content_settings": {
48
+ "category_ids": [],
49
+ "sort_order": "created_at-desc"
50
+ },
51
+ "design_settings": {
52
+ "layout": "grid",
53
+ "columns": 3,
54
+ "item_width": 300,
55
+ "item_height": 600,
56
+ "mask_content_overflow": true,
57
+ "show_navigation_buttons": true,
58
+ "mobile_columns": 2,
59
+ "show_cart_button": true,
60
+ "show_price": true,
61
+ "show_product_filters": true,
62
+ "product_count": 56,
63
+ "show_discount_label": false,
64
+ "show_discount_percentage": false
65
+ },
66
+ "url": "http://voog.test/admin/api/product_widgets/2",
67
+ "content": {
68
+ "id": 2,
69
+ "name": "body",
70
+ "created_at": "2023-11-17T12:56:36.000Z",
71
+ "updated_at": "2023-11-17T12:56:36.000Z",
72
+ "position": 1,
73
+ "url": "http://voog.test/admin/api/pages/1/contents/2"
74
+ },
75
+ "parent": {
76
+ "id": 1,
77
+ "title": "Home",
78
+ "created_at": "2023-11-17T12:55:36.000Z",
79
+ "updated_at": "2023-11-17T12:55:36.000Z",
80
+ "type": "page",
81
+ "url": "http://voog.test/admin/api/pages/1"
82
+ }
83
+ }
84
+ ]
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": 2,
3
+ "active": true,
4
+ "regexp": false,
5
+ "source": "/other-page",
6
+ "destination": "/new-other-page",
7
+ "redirect_type": 301,
8
+ "complexity": 1005,
9
+ "created_at": "2023-11-24T10:23:49.000Z",
10
+ "updated_at": "2023-11-24T10:23:49.000Z",
11
+ "url": "http://voog.test/admin/api/redirect_rules/2"
12
+ }
@@ -0,0 +1,26 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "active": true,
5
+ "regexp": false,
6
+ "source": "/page",
7
+ "destination": "/new-page",
8
+ "redirect_type": 301,
9
+ "complexity": 1005,
10
+ "created_at": "2023-11-24T10:23:04.000Z",
11
+ "updated_at": "2023-11-24T10:23:04.000Z",
12
+ "url": "http://voog.test/admin/api/redirect_rules/1"
13
+ },
14
+ {
15
+ "id": 2,
16
+ "active": true,
17
+ "regexp": false,
18
+ "source": "/other-page",
19
+ "destination": "/new-other-page",
20
+ "redirect_type": 301,
21
+ "complexity": 1005,
22
+ "created_at": "2023-11-24T10:23:49.000Z",
23
+ "updated_at": "2023-11-24T10:23:49.000Z",
24
+ "url": "http://voog.test/admin/api/redirect_rules/2"
25
+ }
26
+ ]
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  require 'voog_api'
2
2
  require 'webmock/rspec'
3
+ require 'pathname'
3
4
 
4
5
  WebMock.disable_net_connect!
5
6
 
6
7
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
8
  RSpec.configure do |config|
8
-
9
+
9
10
  config.treat_symbols_as_metadata_keys_with_true_values = true
10
11
  config.run_all_when_everything_filtered = true
11
12
  config.filter_run :focus
@@ -30,14 +31,16 @@ def fixture(file)
30
31
  end
31
32
 
32
33
  def request_fixture(method, path, options = {})
33
- request = ({
34
- headers: {'X-API-TOKEN' => 'afcf30182aecfc8155d390d7d4552d14'}
35
- }).merge(options.fetch(:request, {}))
36
-
34
+ request = {
35
+ headers: {
36
+ 'X-API-TOKEN' => 'afcf30182aecfc8155d390d7d4552d14'
37
+ }
38
+ }
39
+
37
40
  response = ({headers: {'Content-Type' => 'application/json'}}).tap { |response|
38
41
  response[:body] = fixture(options[:fixture]) if options.has_key?(:fixture)
39
42
  }.merge(options.fetch(:response, {}))
40
-
43
+
41
44
  stub_request(method, voog_url(path)).with(request).to_return(response)
42
45
  end
43
46
 
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Voog::API::BuyButtons do
4
+ let(:client) { voog_client }
5
+
6
+ describe '#buy_buttons' do
7
+ before do
8
+ request_fixture(:get, 'buy_buttons', fixture: 'buy_buttons/buy_buttons')
9
+ end
10
+
11
+ it 'returns a list of buy_buttons' do
12
+ expect(client.buy_buttons.length).to eql(2)
13
+ end
14
+ end
15
+
16
+ describe '#buy_button' do
17
+ before do
18
+ request_fixture(:get, 'buy_buttons/2', fixture: 'buy_buttons/buy_button')
19
+ end
20
+
21
+ it 'returns a single buy_button' do
22
+ expect(client.buy_button(2).settings.title).to eq('Add to cart')
23
+ end
24
+
25
+ it 'returns a buy_button with the same id as in the request' do
26
+ expect(client.buy_button(2).id).to eq(2)
27
+ end
28
+ end
29
+
30
+ describe '#update_buy_button' do
31
+ let(:new_title) { 'New title' }
32
+
33
+ before do
34
+ request_fixture(
35
+ :put,
36
+ 'buy_buttons/2',
37
+ request: {
38
+ body: {
39
+ settings: {
40
+ title: new_title
41
+ }
42
+ }
43
+ },
44
+ response: {
45
+ body: "{\"id\": 2, \"settings\": {\"title\": \"#{new_title}\"}}"
46
+ }
47
+ )
48
+ end
49
+
50
+ it 'responds with new title' do
51
+ expect(
52
+ client.update_buy_button(2, settings: {title: new_title}).settings.title
53
+ ).to eq(new_title)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Voog::API::ProductWidgets do
4
+ let(:client) { voog_client }
5
+
6
+ describe '#product_widgets' do
7
+ before do
8
+ request_fixture(:get, 'product_widgets', fixture: 'product_widgets/product_widgets')
9
+ end
10
+
11
+ it 'returns a list of product_widgets' do
12
+ expect(client.product_widgets.length).to eql(2)
13
+ end
14
+ end
15
+
16
+ describe '#product_widget' do
17
+ before do
18
+ request_fixture(:get, 'product_widgets/2', fixture: 'product_widgets/product_widget')
19
+ end
20
+
21
+ it 'returns a single product_widget' do
22
+ expect(client.product_widget(2).design_settings.layout).to eq('grid')
23
+ end
24
+
25
+ it 'returns a product_widget with the same id as in the request' do
26
+ expect(client.product_widget(2).id).to eq(2)
27
+ end
28
+ end
29
+
30
+ describe '#update_product_widget' do
31
+ let(:new_layout) { 'list' }
32
+
33
+ before do
34
+ request_fixture(
35
+ :put,
36
+ 'product_widgets/2',
37
+ request: {
38
+ body: {
39
+ design_settings: {
40
+ layout: new_layout
41
+ }
42
+ }
43
+ },
44
+ response: {
45
+ body: "{\"id\": 2, \"design_settings\": {\"layout\": \"#{new_layout}\"}}"
46
+ }
47
+ )
48
+ end
49
+
50
+ it 'responds with new layout' do
51
+ expect(
52
+ client.update_product_widget(2, design_settings: {layout: new_layout}).design_settings.layout
53
+ ).to eq(new_layout)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe Voog::API::RedirectRules do
4
+
5
+ let(:client) { voog_client }
6
+
7
+ describe '#redirect_rules' do
8
+ before do
9
+ request_fixture(:get, 'redirect_rules', fixture: 'redirect_rules/redirect_rules')
10
+ end
11
+
12
+ it 'returns a list of redirect_rules' do
13
+ expect(client.redirect_rules.length).to eql(2)
14
+ end
15
+ end
16
+
17
+ describe '#redirect_rule' do
18
+ before do
19
+ request_fixture(:get, 'redirect_rules/2', fixture: 'redirect_rules/redirect_rule')
20
+ end
21
+
22
+ it 'returns a single redirect_rule' do
23
+ expect(client.redirect_rule(2).source).to eq('/other-page')
24
+ end
25
+
26
+ it 'returns a redirect_rule with the same id as in the request' do
27
+ expect(client.redirect_rule(2).id).to eq(2)
28
+ end
29
+ end
30
+
31
+ describe '#delete_redirect_rule' do
32
+ before do
33
+ request_fixture(:delete, 'redirect_rules/2')
34
+ end
35
+
36
+ it 'calls delete method on redirect_rule' do
37
+ client.delete_redirect_rule(2)
38
+
39
+ assert_requested :delete, 'http://voog.test/admin/api/redirect_rules/2'
40
+ end
41
+ end
42
+
43
+ describe '#update_redirect_rule' do
44
+ let(:new_source) { '/new-source' }
45
+ before do
46
+ request_fixture(
47
+ :put,
48
+ 'redirect_rules/2',
49
+ request: {
50
+ body: {source: new_source}
51
+ },
52
+ response: {
53
+ body: "{\"id\": 2, \"source\": \"#{new_source}\"}"
54
+ }
55
+ )
56
+ end
57
+
58
+ it 'responds with new source' do
59
+ expect(client.update_redirect_rule(2, source: new_source).source).to eq(new_source)
60
+ end
61
+ end
62
+ end
@@ -6,7 +6,7 @@ describe Voog::API::Search do
6
6
 
7
7
  describe '#people' do
8
8
  before do
9
- request_fixture(:get, 'search', request: {q: 'any kind of content'}, fixture: 'search/search')
9
+ request_fixture(:get, 'search', request: {query: {q: 'any kind of content'}}, fixture: 'search/search')
10
10
  end
11
11
 
12
12
  it 'returns a list of search results' do
data/voog_api.gemspec CHANGED
@@ -17,12 +17,10 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency 'bundler', '~> 1.3'
21
20
  spec.add_development_dependency 'guard-rspec', '~> 4.2.0'
22
- spec.add_development_dependency 'rspec', '~> 2.14.1'
23
- spec.add_development_dependency 'webmock', '1.16.0'
21
+ spec.add_development_dependency 'rspec', '~> 3.0'
22
+ spec.add_development_dependency 'webmock', '~> 3.18'
24
23
  spec.add_development_dependency 'rake'
25
- spec.add_development_dependency 'listen', '~> 3.0.8'
26
24
 
27
- spec.add_dependency 'sawyer', '~> 0.5.4'
25
+ spec.add_dependency 'sawyer', '~> 0.9'
28
26
  end
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voog_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Priit Haamer
8
8
  - Mikk Pristavka
9
9
  - Tanel Jakobsoo
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-11-16 00:00:00.000000000 Z
13
+ date: 2023-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: bundler
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: '1.3'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "~>"
27
- - !ruby/object:Gem::Version
28
- version: '1.3'
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: guard-rspec
31
17
  requirement: !ruby/object:Gem::Requirement
@@ -46,28 +32,28 @@ dependencies:
46
32
  requirements:
47
33
  - - "~>"
48
34
  - !ruby/object:Gem::Version
49
- version: 2.14.1
35
+ version: '3.0'
50
36
  type: :development
51
37
  prerelease: false
52
38
  version_requirements: !ruby/object:Gem::Requirement
53
39
  requirements:
54
40
  - - "~>"
55
41
  - !ruby/object:Gem::Version
56
- version: 2.14.1
42
+ version: '3.0'
57
43
  - !ruby/object:Gem::Dependency
58
44
  name: webmock
59
45
  requirement: !ruby/object:Gem::Requirement
60
46
  requirements:
61
- - - '='
47
+ - - "~>"
62
48
  - !ruby/object:Gem::Version
63
- version: 1.16.0
49
+ version: '3.18'
64
50
  type: :development
65
51
  prerelease: false
66
52
  version_requirements: !ruby/object:Gem::Requirement
67
53
  requirements:
68
- - - '='
54
+ - - "~>"
69
55
  - !ruby/object:Gem::Version
70
- version: 1.16.0
56
+ version: '3.18'
71
57
  - !ruby/object:Gem::Dependency
72
58
  name: rake
73
59
  requirement: !ruby/object:Gem::Requirement
@@ -82,34 +68,20 @@ dependencies:
82
68
  - - ">="
83
69
  - !ruby/object:Gem::Version
84
70
  version: '0'
85
- - !ruby/object:Gem::Dependency
86
- name: listen
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - "~>"
90
- - !ruby/object:Gem::Version
91
- version: 3.0.8
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - "~>"
97
- - !ruby/object:Gem::Version
98
- version: 3.0.8
99
71
  - !ruby/object:Gem::Dependency
100
72
  name: sawyer
101
73
  requirement: !ruby/object:Gem::Requirement
102
74
  requirements:
103
75
  - - "~>"
104
76
  - !ruby/object:Gem::Version
105
- version: 0.5.4
77
+ version: '0.9'
106
78
  type: :runtime
107
79
  prerelease: false
108
80
  version_requirements: !ruby/object:Gem::Requirement
109
81
  requirements:
110
82
  - - "~>"
111
83
  - !ruby/object:Gem::Version
112
- version: 0.5.4
84
+ version: '0.9'
113
85
  description: Best API wrapper for the best website builder
114
86
  email:
115
87
  - priit@edicy.com
@@ -129,6 +101,7 @@ files:
129
101
  - lib/voog_api.rb
130
102
  - lib/voog_api/api/articles.rb
131
103
  - lib/voog_api/api/assets.rb
104
+ - lib/voog_api/api/buy_buttons.rb
132
105
  - lib/voog_api/api/comments.rb
133
106
  - lib/voog_api/api/content_partials.rb
134
107
  - lib/voog_api/api/contents.rb
@@ -142,6 +115,8 @@ files:
142
115
  - lib/voog_api/api/nodes.rb
143
116
  - lib/voog_api/api/pages.rb
144
117
  - lib/voog_api/api/people.rb
118
+ - lib/voog_api/api/product_widgets.rb
119
+ - lib/voog_api/api/redirect_rules.rb
145
120
  - lib/voog_api/api/search.rb
146
121
  - lib/voog_api/api/site.rb
147
122
  - lib/voog_api/api/site_users.rb
@@ -155,6 +130,8 @@ files:
155
130
  - spec/fixtures/articles/articles.json
156
131
  - spec/fixtures/assets/asset.json
157
132
  - spec/fixtures/assets/assets.json
133
+ - spec/fixtures/buy_buttons/buy_button.json
134
+ - spec/fixtures/buy_buttons/buy_buttons.json
158
135
  - spec/fixtures/comments/comment.json
159
136
  - spec/fixtures/comments/comments.json
160
137
  - spec/fixtures/content_partials/content_partial.json
@@ -181,6 +158,10 @@ files:
181
158
  - spec/fixtures/pages/pages.json
182
159
  - spec/fixtures/people/people.json
183
160
  - spec/fixtures/people/person.json
161
+ - spec/fixtures/product_widgets/product_widget.json
162
+ - spec/fixtures/product_widgets/product_widgets.json
163
+ - spec/fixtures/redirect_rules/redirect_rule.json
164
+ - spec/fixtures/redirect_rules/redirect_rules.json
184
165
  - spec/fixtures/search/search.json
185
166
  - spec/fixtures/site/site.json
186
167
  - spec/fixtures/site_users/site_user.json
@@ -194,6 +175,7 @@ files:
194
175
  - spec/spec_helper.rb
195
176
  - spec/voog_api/api/articles_spec.rb
196
177
  - spec/voog_api/api/assets_spec.rb
178
+ - spec/voog_api/api/buy_buttons_spec.rb
197
179
  - spec/voog_api/api/comments_spec.rb
198
180
  - spec/voog_api/api/content_partials_spec.rb
199
181
  - spec/voog_api/api/contents_spec.rb
@@ -207,6 +189,8 @@ files:
207
189
  - spec/voog_api/api/nodes_spec.rb
208
190
  - spec/voog_api/api/pages_spec.rb
209
191
  - spec/voog_api/api/people_spec.rb
192
+ - spec/voog_api/api/product_widgets_spec.rb
193
+ - spec/voog_api/api/redirect_rules_spec.rb
210
194
  - spec/voog_api/api/search_spec.rb
211
195
  - spec/voog_api/api/site_spec.rb
212
196
  - spec/voog_api/api/site_users_spec.rb
@@ -219,7 +203,7 @@ homepage: https://github.com/Edicy/voog.rb
219
203
  licenses:
220
204
  - MIT
221
205
  metadata: {}
222
- post_install_message:
206
+ post_install_message:
223
207
  rdoc_options: []
224
208
  require_paths:
225
209
  - lib
@@ -234,9 +218,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
218
  - !ruby/object:Gem::Version
235
219
  version: '0'
236
220
  requirements: []
237
- rubyforge_project:
238
- rubygems_version: 2.2.2
239
- signing_key:
221
+ rubygems_version: 3.4.10
222
+ signing_key:
240
223
  specification_version: 4
241
224
  summary: Ruby toolkit for the Voog API
242
225
  test_files:
@@ -244,6 +227,8 @@ test_files:
244
227
  - spec/fixtures/articles/articles.json
245
228
  - spec/fixtures/assets/asset.json
246
229
  - spec/fixtures/assets/assets.json
230
+ - spec/fixtures/buy_buttons/buy_button.json
231
+ - spec/fixtures/buy_buttons/buy_buttons.json
247
232
  - spec/fixtures/comments/comment.json
248
233
  - spec/fixtures/comments/comments.json
249
234
  - spec/fixtures/content_partials/content_partial.json
@@ -270,6 +255,10 @@ test_files:
270
255
  - spec/fixtures/pages/pages.json
271
256
  - spec/fixtures/people/people.json
272
257
  - spec/fixtures/people/person.json
258
+ - spec/fixtures/product_widgets/product_widget.json
259
+ - spec/fixtures/product_widgets/product_widgets.json
260
+ - spec/fixtures/redirect_rules/redirect_rule.json
261
+ - spec/fixtures/redirect_rules/redirect_rules.json
273
262
  - spec/fixtures/search/search.json
274
263
  - spec/fixtures/site/site.json
275
264
  - spec/fixtures/site_users/site_user.json
@@ -283,6 +272,7 @@ test_files:
283
272
  - spec/spec_helper.rb
284
273
  - spec/voog_api/api/articles_spec.rb
285
274
  - spec/voog_api/api/assets_spec.rb
275
+ - spec/voog_api/api/buy_buttons_spec.rb
286
276
  - spec/voog_api/api/comments_spec.rb
287
277
  - spec/voog_api/api/content_partials_spec.rb
288
278
  - spec/voog_api/api/contents_spec.rb
@@ -296,6 +286,8 @@ test_files:
296
286
  - spec/voog_api/api/nodes_spec.rb
297
287
  - spec/voog_api/api/pages_spec.rb
298
288
  - spec/voog_api/api/people_spec.rb
289
+ - spec/voog_api/api/product_widgets_spec.rb
290
+ - spec/voog_api/api/redirect_rules_spec.rb
299
291
  - spec/voog_api/api/search_spec.rb
300
292
  - spec/voog_api/api/site_spec.rb
301
293
  - spec/voog_api/api/site_users_spec.rb