webflow-ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -6
- data/lib/webflow/client.rb +12 -21
- data/lib/webflow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d81f96d9c3c1fb868731f75e2d018280de13d85e
|
4
|
+
data.tar.gz: d424e2465fa6a905a3b418595591798a22fc229d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a698b14be7efc40420829673334874e2a55ec5d4e969981daa86cef29add8956fa85906b8321b61d755be4564489ee6a66ed0cfced95edfc6e4a8e480fd232e9
|
7
|
+
data.tar.gz: 83394b6bb177bfc61d6800df8edc9f14d5ca9e7d6f2f1043af711aa6018beed58317da8ca60aa1964686cac6f308f73eef6f3b3d26cf42161a27d9d7cee6f15a
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# Webflow [![Build Status](https://travis-ci.org/phoet/webflow-ruby.svg?branch=master)](https://travis-ci.org/phoet/webflow-ruby)
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/webflow`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
@@ -22,7 +18,7 @@ Or install it yourself as:
|
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
21
|
+
Have a look at the tests!
|
26
22
|
|
27
23
|
## Development
|
28
24
|
|
@@ -32,7 +28,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
28
|
|
33
29
|
## Contributing
|
34
30
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/phoet/webflow-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
32
|
|
37
33
|
|
38
34
|
## License
|
data/lib/webflow/client.rb
CHANGED
@@ -26,19 +26,15 @@ module Webflow
|
|
26
26
|
get("/sites/#{site_id}/domains")
|
27
27
|
end
|
28
28
|
|
29
|
-
def publish(site_id)
|
30
|
-
|
31
|
-
post("/sites/#{site_id}/publish", domains:
|
29
|
+
def publish(site_id, domain_names: nil)
|
30
|
+
domain_names ||= domains(site_id).map { |domain| domain['name'] }
|
31
|
+
post("/sites/#{site_id}/publish", domains: domain_names)
|
32
32
|
end
|
33
33
|
|
34
34
|
def collections(site_id)
|
35
35
|
get("/sites/#{site_id}/collections")
|
36
36
|
end
|
37
37
|
|
38
|
-
def collection_by(key, value)
|
39
|
-
collections.find { |c| c[key.to_s] == value }
|
40
|
-
end
|
41
|
-
|
42
38
|
def items(collection_id, limit: 100)
|
43
39
|
json = get("/collections/#{collection_id}/items", params: {limit: limit})
|
44
40
|
json['items']
|
@@ -49,6 +45,7 @@ module Webflow
|
|
49
45
|
end
|
50
46
|
|
51
47
|
def update_item(collection_id, item, data)
|
48
|
+
# FIXME: (PS) looks like the API does not have partial updates...
|
52
49
|
base = item.reject {|key, _| ['_id', 'published-by', 'published-on', 'created-on', 'created-by', 'updated-by', 'updated-on', '_cid'].include?(key) }
|
53
50
|
put("/collections/#{collection_id}/items/#{item['_id']}", fields: base.merge(data))
|
54
51
|
end
|
@@ -60,30 +57,23 @@ module Webflow
|
|
60
57
|
private
|
61
58
|
|
62
59
|
def get(path, params: nil)
|
63
|
-
|
64
|
-
response = http(url, method: :get, headers: headers, params: params)
|
65
|
-
Oj.load(response)
|
60
|
+
http(path, method: :get, headers: headers, params: params)
|
66
61
|
end
|
67
62
|
|
68
63
|
def post(path, data)
|
69
|
-
|
70
|
-
response = http(url, method: :post, headers: headers, body: data)
|
71
|
-
Oj.load(response)
|
64
|
+
http(path, method: :post, headers: headers, body: data)
|
72
65
|
end
|
73
66
|
|
74
67
|
def put(path, data)
|
75
|
-
|
76
|
-
response = http(url, method: :put, headers: headers, body: data)
|
77
|
-
Oj.load(response)
|
68
|
+
http(path, method: :put, headers: headers, body: data)
|
78
69
|
end
|
79
70
|
|
80
71
|
def delete(path)
|
81
|
-
|
82
|
-
response = http(url, method: :delete, headers: headers)
|
83
|
-
Oj.load(response)
|
72
|
+
http(path, method: :delete, headers: headers)
|
84
73
|
end
|
85
74
|
|
86
|
-
def http(
|
75
|
+
def http(path, method: :get, params: nil, headers: nil, body: nil)
|
76
|
+
url = File.join(HOST, path)
|
87
77
|
request = Typhoeus::Request.new(
|
88
78
|
url,
|
89
79
|
method: method,
|
@@ -91,7 +81,8 @@ module Webflow
|
|
91
81
|
headers: headers,
|
92
82
|
body: (Oj.dump(body) if body),
|
93
83
|
)
|
94
|
-
request.run.body
|
84
|
+
body = request.run.body
|
85
|
+
Oj.load(body)
|
95
86
|
end
|
96
87
|
|
97
88
|
def headers
|
data/lib/webflow/version.rb
CHANGED