webflow-ruby 0.3.0 → 0.3.1

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
2
  SHA1:
3
- metadata.gz: 2df995b45bc57f7941d8fae264b58e29593d69d3
4
- data.tar.gz: 25abadb527e7ae8360da648bf5f55ed174f67b9d
3
+ metadata.gz: 5335df9034568611d6cbf005de8171ac5a3812cb
4
+ data.tar.gz: 181c5a8e4bff8a0ca6e84c40c572ab5b4083b092
5
5
  SHA512:
6
- metadata.gz: a72d46c3803b36dc9484a15b2bad0a6b2304d036c74ccc00a90e5b680a7306afe21ca9fc7da4f7adeb2fe293501763ba349c0fd436b572d6f6592fce3a70539b
7
- data.tar.gz: 8193ed9ec0fba4bd6ca28f67e9d5860b7ed73ec9c982ef5b155da0929b96fa901fa1d0d4c6382c0b4aa2a3887db4531c56759147b71860b031d4b8e61906ac81
6
+ metadata.gz: 34f29de017d55f7bdf779993280998c4b3f98d14647ac4bb34fb52e6a5ecad4c108ea23bcf73655f620eb5a5fc4f0eb8293bc58ef4f2d2ca5e2aa8feef64961e
7
+ data.tar.gz: 3200e5ce2ab1025fa3fdafbb643b19201112b5d9797d3ebcb057a311eb3f53ef4192875b20ba46217808ad3d24ea11d2bda8e0e991e5b00af8d7f3dcced91916
data/README.md CHANGED
@@ -18,13 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Have a look at the tests!
21
+ Have a look at the tests, seriously!
22
22
 
23
- ## Development
23
+ ## Todo
24
24
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
25
+ * Error handling, it's all JSON for now
26
+ * Resource mapping, it's plain hashes for now
27
+ * Proper docs
28
28
 
29
29
  ## Contributing
30
30
 
@@ -1,5 +1,4 @@
1
1
  require 'typhoeus'
2
- require 'nokogiri'
3
2
  require 'oj'
4
3
 
5
4
  module Webflow
@@ -71,25 +70,29 @@ module Webflow
71
70
  end
72
71
 
73
72
  def post(path, data)
74
- request(path, method: :post, body: data)
73
+ request(path, method: :post, data: data)
75
74
  end
76
75
 
77
76
  def put(path, data)
78
- request(path, method: :put, body: data)
77
+ request(path, method: :put, data: data)
79
78
  end
80
79
 
81
80
  def delete(path)
82
81
  request(path, method: :delete)
83
82
  end
84
83
 
85
- def request(path, method: :get, params: nil, body: nil)
86
- body = Oj.dump(body, OJ_OPTIONS) if body
87
- json = http(path, method: method, params: params, headers: request_headers, body: body)
88
- Oj.load(json, OJ_OPTIONS)
84
+ def request(path, method: :get, params: nil, data: nil)
85
+ json = Oj.dump(data, OJ_OPTIONS) if data
86
+
87
+ response = http(path, method: method, params: params, headers: request_headers, body: json)
88
+ track_rate_limit(response.headers)
89
+
90
+ Oj.load(response.body, OJ_OPTIONS)
89
91
  end
90
92
 
91
93
  def http(path, method: :get, params: nil, headers: nil, body: nil)
92
94
  url = File.join(HOST, path)
95
+
93
96
  request = Typhoeus::Request.new(
94
97
  url,
95
98
  method: method,
@@ -97,17 +100,12 @@ module Webflow
97
100
  headers: headers,
98
101
  body: body,
99
102
  )
100
- response = request.run
101
-
102
- track_rate_limit(response.headers)
103
-
104
- response.body
103
+ request.run
105
104
  end
106
105
 
107
106
  def track_rate_limit(headers)
108
107
  rate_limit = headers.select { |key, value| key =~ /X-Ratelimit/ }
109
108
  @rate_limit = rate_limit unless rate_limit.empty?
110
- # byebug
111
109
  end
112
110
 
113
111
  def request_headers
@@ -118,14 +116,14 @@ module Webflow
118
116
  }
119
117
  end
120
118
 
121
- def error_codes
122
- # https://developers.webflow.com/#errors
119
+ # https://developers.webflow.com/#errors
120
+ def self.error_codes
123
121
  {
124
122
  [400, SyntaxError] => 'Request body was incorrectly formatted. Likely invalid JSON being sent up.',
125
123
  [400, InvalidAPIVersion] => 'Requested an invalid API version',
126
124
  [400, UnsupportedVersion] => 'Requested an API version that in unsupported by the requested route',
127
125
  [400, NotImplemented] => 'This feature is not currently implemented',
128
- [400, ValidationError] => 'Validation failure (see problems field in the response)',
126
+ [400, ValidationError] => 'Validation failure (see err field in the response)',
129
127
  [400, Conflict] => 'Request has a conflict with existing data.',
130
128
  [401, Unauthorized] => 'Provided access token is invalid or does not have access to requested resource',
131
129
  [404, NotFound] => 'Requested resource not found',
@@ -1,3 +1,3 @@
1
1
  module Webflow
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_dependency "typhoeus"
25
- spec.add_dependency "nokogiri"
26
25
  spec.add_dependency "oj"
27
26
 
28
27
  spec.add_development_dependency "bundler", "~> 1.13"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webflow-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - phoet
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: nokogiri
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: oj
43
29
  requirement: !ruby/object:Gem::Requirement