ghost-ruby 1.1.0 → 1.2.0
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 +4 -4
- data/lib/ghost/client.rb +6 -5
- data/lib/ghost/resources/base.rb +4 -4
- data/lib/ghost/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: 4e6d77ddadb5ad58487352c4440ff0d6d3aa32f83832bd6fa3831a4dbb0ee819
|
|
4
|
+
data.tar.gz: d8265e6e960c224da91e6b732c93e62380d155a07b59d49bff603749a6e1fd5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d2b6465cbd106149e38070bab275eb51e0d83e17cafa4b5f1ebab20c55a5bbeefc64c6fead309dddb3c47638508cd97d91c9f42115d00f375e5578369eee782
|
|
7
|
+
data.tar.gz: a0f16c865639f8299baa9b64fd5bcda499c9c998e3d181d5f272f7748625da5e31485013231a6da54b73e3a220cadde405dedf7be2243d372e1594967a1c4102
|
data/lib/ghost/client.rb
CHANGED
|
@@ -16,12 +16,12 @@ module Ghost
|
|
|
16
16
|
request(:get, url, params)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def post(url, body = {})
|
|
20
|
-
request(:post, url, body)
|
|
19
|
+
def post(url, body = {}, query_params: {})
|
|
20
|
+
request(:post, url, body, query_params: query_params)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def put(url, body = {})
|
|
24
|
-
request(:put, url, body)
|
|
23
|
+
def put(url, body = {}, query_params: {})
|
|
24
|
+
request(:put, url, body, query_params: query_params)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def delete(url)
|
|
@@ -54,11 +54,12 @@ module Ghost
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
def request(method, url, params_or_body = nil)
|
|
57
|
+
def request(method, url, params_or_body = nil, query_params: {})
|
|
58
58
|
response = @connection.send(method, url) do |req|
|
|
59
59
|
@authenticator.apply(req)
|
|
60
60
|
req.headers["Accept-Version"] = @config.version
|
|
61
61
|
req.headers["Content-Type"] = "application/json" if %i[post put].include?(method)
|
|
62
|
+
req.params.merge!(query_params) if query_params.any?
|
|
62
63
|
|
|
63
64
|
case method
|
|
64
65
|
when :get
|
data/lib/ghost/resources/base.rb
CHANGED
|
@@ -55,20 +55,20 @@ module Ghost
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def define_add
|
|
58
|
-
define_method(:add) do
|
|
58
|
+
define_method(:add) do |query_params: {}, **params|
|
|
59
59
|
url = @config.resource_url(resource_name)
|
|
60
60
|
payload = { resource_name => [params] }
|
|
61
|
-
body = @client.post(url, payload)
|
|
61
|
+
body = @client.post(url, payload, query_params: query_params)
|
|
62
62
|
Ghost::Response.new(body)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def define_edit
|
|
67
|
-
define_method(:edit) do
|
|
67
|
+
define_method(:edit) do |query_params: {}, **params|
|
|
68
68
|
id = params.delete(:id) || raise(Ghost::Error, "edit requires an id")
|
|
69
69
|
url = @config.resource_id_url(resource_name, id)
|
|
70
70
|
payload = { resource_name => [params] }
|
|
71
|
-
body = @client.put(url, payload)
|
|
71
|
+
body = @client.put(url, payload, query_params: query_params)
|
|
72
72
|
Ghost::Response.new(body)
|
|
73
73
|
end
|
|
74
74
|
end
|
data/lib/ghost/version.rb
CHANGED