Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.4
2.7.1
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.1.1
* [FEATURE] Add patch support for updating items https://github.com/penseo/webflow-ruby/issues/10 😍 @ukd1

## 1.1.0

* [FEATURE] Allow passing a block to `items` that yields the results by page https://github.com/penseo/webflow-ruby/issues/9 😍 @emilesilvis
Expand Down
30 changes: 15 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
PATH
remote: .
specs:
webflow-ruby (1.1.0)
webflow-ruby (1.1.1)
http

GEM
remote: https://rubygems.org/
specs:
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
byebug (11.0.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
byebug (11.1.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
ffi (1.11.3)
ffi (1.12.2)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
hashdiff (1.0.0)
http (4.2.0)
hashdiff (1.0.1)
http (4.4.1)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 2.0)
http-form_data (~> 2.2)
http-parser (~> 1.2.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
http-form_data (2.1.1)
http-form_data (2.3.0)
http-parser (1.2.1)
ffi-compiler (>= 1.0, < 2.0)
minitest (5.11.3)
public_suffix (3.1.1)
rake (12.3.3)
minitest (5.14.0)
public_suffix (4.0.4)
rake (13.0.1)
safe_yaml (1.0.5)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
vcr (5.0.0)
webmock (3.6.0)
unf_ext (0.0.7.7)
vcr (5.1.0)
webmock (3.8.3)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Webflow [![Build Status](https://travis-ci.org/penseo/webflow-ruby.svg?branch=master)](https://travis-ci.org/penseo/webflow-ruby)

## Installation

Add this line to your application's Gemfile:

```ruby
Expand All @@ -10,32 +9,31 @@ gem 'webflow-ruby'

And then execute:

$ bundle
```bash
$ bundle
```

Or install it yourself as:

$ gem install webflow-ruby
```bash
$ gem install webflow-ruby
```

## Usage

Have a look at the tests, seriously!

### Quick Start
```ruby
client = Webflow::Client.new(WEBFLOW_API_TOKEN)
sites = client.sites
client = Webflow::Client.new(WEBFLOW_API_TOKEN)
sites = client.sites
```

## Todo

* Resource mapping, it's plain hashes for now
* Proper docs (please look at the tests for now)

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/penseo/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.


## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
10 changes: 4 additions & 6 deletions lib/webflow/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def domains(site_id)

def publish(site_id, domain_names: nil)
domain_names ||= domains(site_id).map { |domain| domain['name'] }
post("/sites/#{site_id}/publish", domains: domain_names)
post("/sites/#{site_id}/publish", {domains: domain_names})
end

def collections(site_id)
Expand Down Expand Up @@ -95,9 +95,7 @@ def create_item(collection_id, data, live: false)
end

def update_item(item, data, live: false)
# FIXME: (PS) looks like the API does not have partial updates...
base = item.reject {|key, _| ['_id', 'published-by', 'published-on', 'created-on', 'created-by', 'updated-by', 'updated-on', '_cid'].include?(key) }
put("/collections/#{item['_cid']}/items/#{item['_id']}", {fields: base.merge(data)}, live: live)
patch("/collections/#{item['_cid']}/items/#{item['_id']}", {fields: data}, live: live)
end

def delete_item(item)
Expand All @@ -115,9 +113,9 @@ def post(path, data, live: nil)
request(path, method: :post, params: params, data: data)
end

def put(path, data, live: nil)
def patch(path, data, live: nil)
params = { live: 'true' } if live
request(path, method: :put, params: params, data: data)
request(path, method: :patch, params: params, data: data)
end

def delete(path)
Expand Down
2 changes: 1 addition & 1 deletion lib/webflow/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Webflow
VERSION = "1.1.0"
VERSION = "1.1.1"
end
69 changes: 34 additions & 35 deletions test/fixtures/cassettes/test_it_creates_and_updates_items.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/webflow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_it_creates_and_updates_items
assert_equal(name, item['name'])

name = 'Test Item Name Update DEF'
item = client.update_item(item, name: name)
item = client.update_item(item, {name: name})
assert_equal(name, item['name'])
end
end
Expand Down