webflow-ruby 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86911a03c1684d161e4308f07197af038ebdb175369b1c75e1d62eaf9143de4a
4
- data.tar.gz: 9df52553d7211783fdd1145a90dbbcec7dbaf398435a516eff8ba5c0990cd11f
3
+ metadata.gz: ec3eb0466136191f723a1714584f052984a86a27fc73850646566c1f2bb63652
4
+ data.tar.gz: 2c6a7c5206ba2917036cf5d3b5a48665d07bc755d7a7330ccb67b2522dd98300
5
5
  SHA512:
6
- metadata.gz: '081549aad5ce13361cca07e0537263493484d7de30383697ec6d0185754c7f2c4215bcfe1ff00b444aa3e46edc957ad61942cf34265fcf3653b65d675e976c45'
7
- data.tar.gz: 433cf0bf095bc151b342738bef6bc6373286fda23a6688e3ae72e6b690e569249731dc74af4d9f37b0c6db2c6d8bf7fefb29799808ec3917e416244c06ddae5d
6
+ metadata.gz: be6e8dc8f380bd15362efbaf1fbb26e2ae05fc43fded354ddb71738a0975a6dda1d83904d6d00199491d8e6000f8e9e02eac5d6a4dab7f487af40b72d8a512dc
7
+ data.tar.gz: ae3fe066e832f4a0eb5b44be996a405e3fe705219c8102b5f4c06db2f150babbcc216860178b24db9d6d4591e8595c4ba98bc358afc5b042858c054e85f47064
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.1.0
2
+
3
+ * [FEATURE] Allow passing a block to `items` that yields the results by page https://github.com/penseo/webflow-ruby/issues/9 😍 @emilesilvis
4
+ * [FEATURE] Handle Webflow live feature https://github.com/penseo/webflow-ruby/pull/8 😍 @emilesilvis
5
+
1
6
  ## 1.0.0
2
7
 
3
8
  * [BREAKING] Raise errors when status > 200, see also https://github.com/penseo/webflow-ruby/pull/7 😍 @sega
@@ -10,7 +10,15 @@ module Webflow
10
10
  end
11
11
 
12
12
  def rate_limit
13
- @rate_limit
13
+ @rate_limit || {}
14
+ end
15
+
16
+ def limit
17
+ rate_limit['X-Ratelimit-Limit'].to_i
18
+ end
19
+
20
+ def remaining
21
+ rate_limit['X-Ratelimit-Remaining'].to_i
14
22
  end
15
23
 
16
24
  def info
@@ -67,7 +75,9 @@ module Webflow
67
75
 
68
76
  num_pages.times do |i|
69
77
  resp = paginate_items(collection_id, per_page: per_page, page: i+1)
70
- fetched_items += resp['items']
78
+ items = resp['items']
79
+ yield(items) if block_given?
80
+ fetched_items += items
71
81
  limit -= resp['count']
72
82
  break if limit <= 0 || resp['total'] <= fetched_items.length
73
83
  end
@@ -80,14 +90,14 @@ module Webflow
80
90
  json['items'].first
81
91
  end
82
92
 
83
- def create_item(collection_id, data)
84
- post("/collections/#{collection_id}/items", fields: data)
93
+ def create_item(collection_id, data, live: false)
94
+ post("/collections/#{collection_id}/items", {fields: data}, live: live)
85
95
  end
86
96
 
87
- def update_item(item, data)
97
+ def update_item(item, data, live: false)
88
98
  # FIXME: (PS) looks like the API does not have partial updates...
89
99
  base = item.reject {|key, _| ['_id', 'published-by', 'published-on', 'created-on', 'created-by', 'updated-by', 'updated-on', '_cid'].include?(key) }
90
- put("/collections/#{item['_cid']}/items/#{item['_id']}", fields: base.merge(data))
100
+ put("/collections/#{item['_cid']}/items/#{item['_id']}", {fields: base.merge(data)}, live: live)
91
101
  end
92
102
 
93
103
  def delete_item(item)
@@ -100,12 +110,14 @@ module Webflow
100
110
  request(path, method: :get, params: params)
101
111
  end
102
112
 
103
- def post(path, data)
104
- request(path, method: :post, data: data)
113
+ def post(path, data, live: nil)
114
+ params = { live: 'true' } if live
115
+ request(path, method: :post, params: params, data: data)
105
116
  end
106
117
 
107
- def put(path, data)
108
- request(path, method: :put, data: data)
118
+ def put(path, data, live: nil)
119
+ params = { live: 'true' } if live
120
+ request(path, method: :put, params: params, data: data)
109
121
  end
110
122
 
111
123
  def delete(path)
@@ -1,3 +1,3 @@
1
1
  module Webflow
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webflow-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - phoet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2019-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http