webflow_sync 6.1.0 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/webflow_sync/api.rb +13 -4
- data/lib/webflow_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3874cf42b829542c647a91935f17fe61d04072b8ad3f30ac8a483e8a019bb6ab
|
4
|
+
data.tar.gz: 32af885137c5c68b1720e6ec816adf584b4215540cc004fac9824fe71bcea3d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32209b9c2500d2ba13f229fc4826296ead24d002fd2ee429f2c4c71076c70f8a23fb3bad1b4386cf4253120a958bfef10bd832ab4c2496b3914a542282d3beca
|
7
|
+
data.tar.gz: d447ac378e5c6ceb3ee19e400e2e337baefbc152146a58b5a64a371fe49d18c1fc72f4e9e9328a924a37749e22608faadf1d449847ef55b32296f56902b4384e
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module WebflowSync
|
4
|
-
class Api
|
4
|
+
class Api # rubocop:disable Metrics/ClassLength
|
5
5
|
attr_reader :site_id
|
6
6
|
|
7
|
-
def initialize(site_id)
|
7
|
+
def initialize(site_id = nil)
|
8
8
|
@site_id = site_id
|
9
9
|
end
|
10
10
|
|
@@ -21,8 +21,7 @@ module WebflowSync
|
|
21
21
|
items = result['items']
|
22
22
|
|
23
23
|
(2..total_pages).each do |page_number|
|
24
|
-
next_page_items = make_request(:paginate_items, collection_id,
|
25
|
-
page: page_number, per_page: max_items_per_page)['items']
|
24
|
+
next_page_items = make_request(:paginate_items, collection_id, page: page_number, per_page: max_items_per_page)['items']
|
26
25
|
puts "Get all items from WebFlow for #{collection_slug} page: #{page_number}"
|
27
26
|
|
28
27
|
items.concat next_page_items
|
@@ -31,11 +30,14 @@ module WebflowSync
|
|
31
30
|
items
|
32
31
|
end
|
33
32
|
|
33
|
+
def self.get_all_items(collection_slug:, page_limit: 100) = new.get_all_items(collection_slug:, page_limit:)
|
34
|
+
|
34
35
|
def get_item(collection_slug, webflow_item_id)
|
35
36
|
collection = find_webflow_collection(collection_slug)
|
36
37
|
|
37
38
|
make_request(:item, collection['_id'], webflow_item_id)
|
38
39
|
end
|
40
|
+
def self.get_item(collection_slug, webflow_item_id) = new.get_item(collection_slug, webflow_item_id)
|
39
41
|
|
40
42
|
def create_item(record, collection_slug)
|
41
43
|
collection = find_webflow_collection(collection_slug)
|
@@ -51,6 +53,8 @@ module WebflowSync
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
56
|
+
def self.create_item(record, collection_slug) = new.create_item(record, collection_slug)
|
57
|
+
|
54
58
|
def update_item(record, collection_slug)
|
55
59
|
collection = find_webflow_collection(collection_slug)
|
56
60
|
response = make_request(:update_item, { '_cid' => collection['_id'], '_id' => record.webflow_item_id },
|
@@ -60,6 +64,8 @@ module WebflowSync
|
|
60
64
|
response
|
61
65
|
end
|
62
66
|
|
67
|
+
def self.update_item(record, collection_slug) = new.update_item(record, collection_slug)
|
68
|
+
|
63
69
|
def delete_item(collection_slug, webflow_item_id)
|
64
70
|
collection = find_webflow_collection(collection_slug)
|
65
71
|
# deleting items from Webflow doesn't work as expected.
|
@@ -73,6 +79,8 @@ module WebflowSync
|
|
73
79
|
response
|
74
80
|
end
|
75
81
|
|
82
|
+
def self.delete_item(collection_slug, webflow_item_id) = new.delete_item(collection_slug, webflow_item_id)
|
83
|
+
|
76
84
|
def publish
|
77
85
|
response = make_request(:publish, site_id, domain_names:)
|
78
86
|
|
@@ -81,6 +89,7 @@ module WebflowSync
|
|
81
89
|
end
|
82
90
|
|
83
91
|
def sites = make_request(:sites)
|
92
|
+
def self.sites = new.sites
|
84
93
|
|
85
94
|
private
|
86
95
|
|
data/lib/webflow_sync/version.rb
CHANGED